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