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 "mozilla/Hal.h"
|
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "DateCacheCleaner.h"
|
|
|
|
|
2013-04-18 19:36:03 +04:00
|
|
|
#include "nsContentUtils.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-04-18 19:36:03 +04:00
|
|
|
mozilla::SafeAutoJSContext cx;
|
2012-12-14 03:35:40 +04:00
|
|
|
JSAutoRequest ar(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
|