dom/time/DateCacheCleaner.cpp
author Wes Kocher <wkocher@mozilla.com>
Fri, 13 Jan 2017 17:02:57 -0800
changeset 374453 9e96ce6d55f78b62f9ccb47c1afbf48b750d9ea5
parent 327230 476c67fdc36c72c4d7efac7bb4506625093f29b1
child 451029 3d28ca7c05d8f9ba3ba6ff1cd5449dce42ae95c1
permissions -rw-r--r--
Backed out changeset 4dc794806128 (bug 1317374) for spidermonkey bustage a=backout MozReview-Commit-ID: EJDwWWtrHTb

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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"

#include "js/Date.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Hal.h"
#include "mozilla/StaticPtr.h"

using namespace mozilla::hal;

namespace mozilla {
namespace dom {
namespace time {

class DateCacheCleaner : public SystemTimezoneChangeObserver
{
public:
  DateCacheCleaner()
  {
    RegisterSystemTimezoneChangeObserver(this);
  }

  ~DateCacheCleaner()
  {
    UnregisterSystemTimezoneChangeObserver(this);
  }
  void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
  {
    JS::ResetTimeZone();
  }

};

StaticAutoPtr<DateCacheCleaner> sDateCacheCleaner;

void
InitializeDateCacheCleaner()
{
  if (!sDateCacheCleaner) {
    sDateCacheCleaner = new DateCacheCleaner();
    ClearOnShutdown(&sDateCacheCleaner);
  }
}

} // namespace time
} // namespace dom
} // namespace mozilla