michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "DateCacheCleaner.h" michael@0: michael@0: #include "jsapi.h" michael@0: #include "mozilla/ClearOnShutdown.h" michael@0: #include "mozilla/Hal.h" michael@0: #include "mozilla/StaticPtr.h" michael@0: #include "nsCxPusher.h" michael@0: michael@0: using namespace mozilla::hal; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: namespace time { michael@0: michael@0: class DateCacheCleaner : public SystemTimezoneChangeObserver michael@0: { michael@0: public: michael@0: DateCacheCleaner() michael@0: { michael@0: RegisterSystemTimezoneChangeObserver(this); michael@0: } michael@0: michael@0: ~DateCacheCleaner() michael@0: { michael@0: UnregisterSystemTimezoneChangeObserver(this); michael@0: } michael@0: void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) michael@0: { michael@0: mozilla::AutoSafeJSContext cx; michael@0: JS_ClearDateCaches(cx); michael@0: } michael@0: michael@0: }; michael@0: michael@0: StaticAutoPtr sDateCacheCleaner; michael@0: michael@0: void michael@0: InitializeDateCacheCleaner() michael@0: { michael@0: if (!sDateCacheCleaner) { michael@0: sDateCacheCleaner = new DateCacheCleaner(); michael@0: ClearOnShutdown(&sDateCacheCleaner); michael@0: } michael@0: } michael@0: michael@0: } // namespace time michael@0: } // namespace dom michael@0: } // namespace mozilla