|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "TimeManager.h" |
|
6 |
|
7 #include "mozilla/dom/Date.h" |
|
8 #include "mozilla/dom/MozTimeManagerBinding.h" |
|
9 #include "nsITimeService.h" |
|
10 #include "nsServiceManagerUtils.h" |
|
11 |
|
12 namespace mozilla { |
|
13 namespace dom { |
|
14 namespace time { |
|
15 |
|
16 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeManager) |
|
17 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
|
18 NS_INTERFACE_MAP_ENTRY(nsISupports) |
|
19 NS_INTERFACE_MAP_END |
|
20 |
|
21 NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeManager) |
|
22 NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeManager) |
|
23 |
|
24 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TimeManager, mWindow) |
|
25 |
|
26 JSObject* |
|
27 TimeManager::WrapObject(JSContext* aCx) |
|
28 { |
|
29 return MozTimeManagerBinding::Wrap(aCx, this); |
|
30 } |
|
31 |
|
32 void |
|
33 TimeManager::Set(Date& aDate) |
|
34 { |
|
35 Set(aDate.TimeStamp()); |
|
36 } |
|
37 |
|
38 void |
|
39 TimeManager::Set(double aTime) |
|
40 { |
|
41 nsCOMPtr<nsITimeService> timeService = do_GetService(TIMESERVICE_CONTRACTID); |
|
42 if (timeService) { |
|
43 timeService->Set(aTime); |
|
44 } |
|
45 } |
|
46 |
|
47 } // namespace time |
|
48 } // namespace dom |
|
49 } // namespace mozilla |