зеркало из https://github.com/mozilla/gecko-dev.git
Bug 792443 - hal::RegisterSystemTimeChangeObserver should register the observer through sandbox, r=jlebar
This commit is contained in:
Родитель
ade089d9d0
Коммит
816d9a9358
27
hal/Hal.cpp
27
hal/Hal.cpp
|
@ -406,37 +406,38 @@ bool GetLight(LightType light, hal::LightConfiguration* aConfig)
|
|||
RETURN_PROXY_IF_SANDBOXED(GetLight(light, aConfig));
|
||||
}
|
||||
|
||||
static StaticAutoPtr<ObserverList<SystemTimeChange> > sSystemTimeObservers;
|
||||
|
||||
static void
|
||||
InitializeSystemTimeChangeObserver()
|
||||
class SystemTimeObserversManager : public ObserversManager<SystemTimeChange>
|
||||
{
|
||||
if (!sSystemTimeObservers) {
|
||||
sSystemTimeObservers = new ObserverList<SystemTimeChange>;
|
||||
ClearOnShutdown(&sSystemTimeObservers);
|
||||
protected:
|
||||
void EnableNotifications() {
|
||||
PROXY_IF_SANDBOXED(EnableSystemTimeChangeNotifications());
|
||||
}
|
||||
}
|
||||
|
||||
void DisableNotifications() {
|
||||
PROXY_IF_SANDBOXED(DisableSystemTimeChangeNotifications());
|
||||
}
|
||||
};
|
||||
|
||||
static SystemTimeObserversManager sSystemTimeObservers;
|
||||
|
||||
void
|
||||
RegisterSystemTimeChangeObserver(SystemTimeObserver *aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
InitializeSystemTimeChangeObserver();
|
||||
sSystemTimeObservers->AddObserver(aObserver);
|
||||
sSystemTimeObservers.AddObserver(aObserver);
|
||||
}
|
||||
|
||||
void
|
||||
UnregisterSystemTimeChangeObserver(SystemTimeObserver *aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
sSystemTimeObservers->RemoveObserver(aObserver);
|
||||
sSystemTimeObservers.RemoveObserver(aObserver);
|
||||
}
|
||||
|
||||
void
|
||||
NotifySystemTimeChange(const hal::SystemTimeChange& aReason)
|
||||
{
|
||||
InitializeSystemTimeChangeObserver();
|
||||
sSystemTimeObservers->Broadcast(aReason);
|
||||
sSystemTimeObservers.BroadcastInformation(aReason);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -74,6 +74,16 @@ bool EnableAlarm();
|
|||
*/
|
||||
void DisableAlarm();
|
||||
|
||||
/**
|
||||
* Enable system time change notifications from the backend.
|
||||
*/
|
||||
void EnableSystemTimeChangeNotifications();
|
||||
|
||||
/**
|
||||
* Disable system time change notifications from the backend.
|
||||
*/
|
||||
void DisableSystemTimeChangeNotifications();
|
||||
|
||||
} // namespace MOZ_HAL_NAMESPACE
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -24,5 +24,14 @@ GetTimezone()
|
|||
return EmptyCString();
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimeChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimeChangeNotifications()
|
||||
{
|
||||
}
|
||||
} // namespace hal_impl
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -670,6 +670,16 @@ GetTimezone()
|
|||
return nsCString(timezone);
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimeChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimeChangeNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
// Nothing to do here. Gonk widgetry always listens for screen
|
||||
// orientation changes.
|
||||
void
|
||||
|
|
|
@ -135,6 +135,8 @@ parent:
|
|||
SetTimezone(nsCString aTimezoneSpec);
|
||||
sync GetTimezone()
|
||||
returns (nsCString aTimezoneSpec);
|
||||
EnableSystemTimeChangeNotifications();
|
||||
DisableSystemTimeChangeNotifications();
|
||||
|
||||
sync SetLight(LightType light, LightConfiguration aConfig)
|
||||
returns (bool status);
|
||||
|
|
|
@ -203,6 +203,18 @@ GetTimezone()
|
|||
return timezone;
|
||||
}
|
||||
|
||||
void
|
||||
EnableSystemTimeChangeNotifications()
|
||||
{
|
||||
Hal()->SendEnableSystemTimeChangeNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableSystemTimeChangeNotifications()
|
||||
{
|
||||
Hal()->SendDisableSystemTimeChangeNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
Reboot()
|
||||
{
|
||||
|
@ -362,6 +374,7 @@ class HalParent : public PHalParent
|
|||
, public WakeLockObserver
|
||||
, public ScreenConfigurationObserver
|
||||
, public SwitchObserver
|
||||
, public SystemTimeObserver
|
||||
{
|
||||
public:
|
||||
virtual void
|
||||
|
@ -608,6 +621,20 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvEnableSystemTimeChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::RegisterSystemTimeChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvDisableSystemTimeChangeNotifications() MOZ_OVERRIDE
|
||||
{
|
||||
hal::UnregisterSystemTimeChangeObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
RecvReboot() MOZ_OVERRIDE
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче