Commit 816d9a93 authored by Steven Lee's avatar Steven Lee
Browse files

Bug 792443 - hal::RegisterSystemTimeChangeObserver should register the...

Bug 792443 - hal::RegisterSystemTimeChangeObserver should register the observer through sandbox, r=jlebar
parent ade089d9
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -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 
+10 −0
Original line number Diff line number Diff line
@@ -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

+9 −0
Original line number Diff line number Diff line
@@ -24,5 +24,14 @@ GetTimezone()
  return EmptyCString();
}

void
EnableSystemTimeChangeNotifications()
{
}

void
DisableSystemTimeChangeNotifications()
{
}
} // namespace hal_impl
} // namespace mozilla
+10 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ parent:
    SetTimezone(nsCString aTimezoneSpec);
    sync GetTimezone()
      returns (nsCString aTimezoneSpec);
    EnableSystemTimeChangeNotifications();
    DisableSystemTimeChangeNotifications();

    sync SetLight(LightType light, LightConfiguration aConfig)
      returns (bool status);
Loading