2012-10-17 08:26:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "DateCacheCleaner.h"
|
|
|
|
|
2013-08-14 10:56:21 +04:00
|
|
|
#include "jsapi.h"
|
2014-08-15 05:47:15 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/Hal.h"
|
2012-10-17 08:26:00 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
|
|
|
|
using namespace mozilla::hal;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace time {
|
|
|
|
|
2012-10-23 11:15:43 +04:00
|
|
|
class DateCacheCleaner : public SystemTimezoneChangeObserver
|
2012-10-17 08:26:00 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DateCacheCleaner()
|
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
RegisterSystemTimezoneChangeObserver(this);
|
2012-10-17 08:26:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
~DateCacheCleaner()
|
|
|
|
{
|
2012-10-23 11:15:43 +04:00
|
|
|
UnregisterSystemTimezoneChangeObserver(this);
|
2012-10-17 08:26:00 +04:00
|
|
|
}
|
2012-10-23 11:15:43 +04:00
|
|
|
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
2012-10-17 08:26:00 +04:00
|
|
|
{
|
2013-05-06 17:04:17 +04:00
|
|
|
mozilla::AutoSafeJSContext cx;
|
2012-10-17 08:26:00 +04:00
|
|
|
JS_ClearDateCaches(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner;
|
|
|
|
|
|
|
|
void
|
|
|
|
InitializeDateCacheCleaner()
|
|
|
|
{
|
|
|
|
if (!sDateCacheCleaner) {
|
|
|
|
sDateCacheCleaner = new DateCacheCleaner();
|
|
|
|
ClearOnShutdown(&sDateCacheCleaner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace time
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|