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 "base/basictypes.h" michael@0: #include "jsapi.h" michael@0: #include "mozilla/ClearOnShutdown.h" michael@0: #include "mozilla/Hal.h" michael@0: #include "TimeService.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: namespace time { michael@0: michael@0: NS_IMPL_ISUPPORTS(TimeService, nsITimeService) michael@0: michael@0: /* static */ StaticRefPtr TimeService::sSingleton; michael@0: michael@0: /* static */ already_AddRefed michael@0: TimeService::GetInstance() michael@0: { michael@0: if (!sSingleton) { michael@0: sSingleton = new TimeService(); michael@0: ClearOnShutdown(&sSingleton); michael@0: } michael@0: nsRefPtr service = sSingleton.get(); michael@0: return service.forget(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TimeService::Set(int64_t aTimeInMS) { michael@0: hal::AdjustSystemClock(aTimeInMS - (JS_Now() / PR_USEC_PER_MSEC)); michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace time michael@0: } // namespace dom michael@0: } // namespace mozilla