2012-09-10 23:05: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/. */
|
|
|
|
|
|
|
|
#ifndef _mozilla_time_change_observer_h_
|
|
|
|
#define _mozilla_time_change_observer_h_
|
|
|
|
|
|
|
|
#include "mozilla/Hal.h"
|
|
|
|
#include "mozilla/Observer.h"
|
|
|
|
#include "mozilla/HalTypes.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsWeakPtr.h"
|
2013-02-15 13:57:18 -08:00
|
|
|
#include "nsTObserverArray.h"
|
2012-09-10 23:05:00 -07:00
|
|
|
|
2012-10-23 00:15:43 -07:00
|
|
|
typedef mozilla::Observer<int64_t> SystemClockChangeObserver;
|
|
|
|
typedef mozilla::Observer<mozilla::hal::SystemTimezoneChangeInformation> SystemTimezoneChangeObserver;
|
2012-09-10 23:05:00 -07:00
|
|
|
|
2012-10-23 00:15:43 -07:00
|
|
|
class nsSystemTimeChangeObserver : public SystemClockChangeObserver,
|
|
|
|
public SystemTimezoneChangeObserver
|
2012-09-10 23:05:00 -07:00
|
|
|
{
|
2013-02-15 13:57:18 -08:00
|
|
|
typedef nsTObserverArray<nsWeakPtr> ListenerArray;
|
2012-09-10 23:05:00 -07:00
|
|
|
public:
|
|
|
|
static nsSystemTimeChangeObserver* GetInstance();
|
|
|
|
virtual ~nsSystemTimeChangeObserver();
|
2012-10-23 00:15:43 -07:00
|
|
|
|
|
|
|
// Implementing hal::SystemClockChangeObserver::Notify()
|
|
|
|
void Notify(const int64_t& aClockDeltaMS);
|
|
|
|
|
|
|
|
// Implementing hal::SystemTimezoneChangeObserver::Notify()
|
|
|
|
void Notify(
|
|
|
|
const mozilla::hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo);
|
|
|
|
|
2013-02-15 14:03:18 -08:00
|
|
|
static nsresult AddWindowListener(nsPIDOMWindow* aWindow);
|
|
|
|
static nsresult RemoveWindowListener(nsPIDOMWindow* aWindow);
|
2012-09-10 23:05:00 -07:00
|
|
|
private:
|
2013-02-15 14:03:18 -08:00
|
|
|
nsresult AddWindowListenerImpl(nsPIDOMWindow* aWindow);
|
|
|
|
nsresult RemoveWindowListenerImpl(nsPIDOMWindow* aWindow);
|
2012-09-10 23:05:00 -07:00
|
|
|
nsSystemTimeChangeObserver() { };
|
2013-02-15 13:57:18 -08:00
|
|
|
ListenerArray mWindowListeners;
|
2012-10-23 00:15:43 -07:00
|
|
|
void FireMozTimeChangeEvent();
|
2012-09-10 23:05:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_mozilla_time_change_observer_h_
|