michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "TimeManager.h" michael@0: michael@0: #include "mozilla/dom/Date.h" michael@0: #include "mozilla/dom/MozTimeManagerBinding.h" michael@0: #include "nsITimeService.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: namespace time { michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeManager) michael@0: NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports) michael@0: NS_INTERFACE_MAP_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeManager) michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeManager) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TimeManager, mWindow) michael@0: michael@0: JSObject* michael@0: TimeManager::WrapObject(JSContext* aCx) michael@0: { michael@0: return MozTimeManagerBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: void michael@0: TimeManager::Set(Date& aDate) michael@0: { michael@0: Set(aDate.TimeStamp()); michael@0: } michael@0: michael@0: void michael@0: TimeManager::Set(double aTime) michael@0: { michael@0: nsCOMPtr timeService = do_GetService(TIMESERVICE_CONTRACTID); michael@0: if (timeService) { michael@0: timeService->Set(aTime); michael@0: } michael@0: } michael@0: michael@0: } // namespace time michael@0: } // namespace dom michael@0: } // namespace mozilla