2012-10-16 21:26:00 -07: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-13 23:56:21 -07:00
|
|
|
#include "jsapi.h"
|
2014-08-14 18:47:15 -07:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-13 23:56:21 -07:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/Hal.h"
|
2012-10-16 21:26:00 -07:00
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
|
|
|
|
using namespace mozilla::hal;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace time {
|
|
|
|
|
2012-10-23 00:15:43 -07:00
|
|
|
class DateCacheCleaner : public SystemTimezoneChangeObserver
|
2012-10-16 21:26:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DateCacheCleaner()
|
|
|
|
{
|
2012-10-23 00:15:43 -07:00
|
|
|
RegisterSystemTimezoneChangeObserver(this);
|
2012-10-16 21:26:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~DateCacheCleaner()
|
|
|
|
{
|
2012-10-23 00:15:43 -07:00
|
|
|
UnregisterSystemTimezoneChangeObserver(this);
|
2012-10-16 21:26:00 -07:00
|
|
|
}
|
2012-10-23 00:15:43 -07:00
|
|
|
void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
|
2012-10-16 21:26:00 -07:00
|
|
|
{
|
2013-05-06 06:04:17 -07:00
|
|
|
mozilla::AutoSafeJSContext cx;
|
2012-10-16 21:26:00 -07:00
|
|
|
JS_ClearDateCaches(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner;
|
|
|
|
|
|
|
|
void
|
|
|
|
InitializeDateCacheCleaner()
|
|
|
|
{
|
|
|
|
if (!sDateCacheCleaner) {
|
|
|
|
sDateCacheCleaner = new DateCacheCleaner();
|
|
|
|
ClearOnShutdown(&sDateCacheCleaner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace time
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|