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