1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/time/DateCacheCleaner.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "DateCacheCleaner.h" 1.10 + 1.11 +#include "jsapi.h" 1.12 +#include "mozilla/ClearOnShutdown.h" 1.13 +#include "mozilla/Hal.h" 1.14 +#include "mozilla/StaticPtr.h" 1.15 +#include "nsCxPusher.h" 1.16 + 1.17 +using namespace mozilla::hal; 1.18 + 1.19 +namespace mozilla { 1.20 +namespace dom { 1.21 +namespace time { 1.22 + 1.23 +class DateCacheCleaner : public SystemTimezoneChangeObserver 1.24 +{ 1.25 +public: 1.26 + DateCacheCleaner() 1.27 + { 1.28 + RegisterSystemTimezoneChangeObserver(this); 1.29 + } 1.30 + 1.31 + ~DateCacheCleaner() 1.32 + { 1.33 + UnregisterSystemTimezoneChangeObserver(this); 1.34 + } 1.35 + void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) 1.36 + { 1.37 + mozilla::AutoSafeJSContext cx; 1.38 + JS_ClearDateCaches(cx); 1.39 + } 1.40 + 1.41 +}; 1.42 + 1.43 +StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner; 1.44 + 1.45 +void 1.46 +InitializeDateCacheCleaner() 1.47 +{ 1.48 + if (!sDateCacheCleaner) { 1.49 + sDateCacheCleaner = new DateCacheCleaner(); 1.50 + ClearOnShutdown(&sDateCacheCleaner); 1.51 + } 1.52 +} 1.53 + 1.54 +} // namespace time 1.55 +} // namespace dom 1.56 +} // namespace mozilla