/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et ft=cpp : */ /* 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/. */
staticbool MayCancelVibration(const WindowIdentifier& aId) { // Although only active windows may start vibrations, a window may // cancel its own vibration even if it's no longer active. // // After a window is marked as inactive, it sends a CancelVibrate // request. We want this request to cancel a playing vibration // started by that window, so we certainly don't want to reject the // cancellation request because the window is now inactive. // // But it could be the case that, after this window became inactive, // some other window came along and started a vibration. We don't // want this window's cancellation request to cancel that window's // actively-playing vibration! // // To solve this problem, we keep track of the id of the last window // to start a vibration, and only accepts cancellation requests from // the same window. All other cancellation requests are ignored.
// Only active windows may start vibrations. If |id| hasn't gone // through the IPC layer -- that is, if our caller is the outside // world, not hal_proxy -- check whether the window is active. If // |id| has gone through IPC, don't check the window's visibility; // only the window corresponding to the bottommost process has its // visibility state set correctly. if (!id.HasTraveledThroughIPC() && !WindowIsActive(id.GetWindow())) {
HAL_LOG("Vibrate: Window is inactive, dropping vibrate."); return;
}
RecordLastIDToVibrate(id);
// Don't forward our ID if we are not in the sandbox, because hal_impl // doesn't need it, and we don't want it to be tempted to read it. The // empty identifier will assert if it's used.
PROXY_IF_SANDBOXED(
Vibrate(pattern, InSandbox() ? std::move(id) : WindowIdentifier()));
}
if (MayCancelVibration(id)) { // Don't forward our ID if we are not in the sandbox, because hal_impl // doesn't need it, and we don't want it to be tempted to read it. The // empty identifier will assert if it's used.
PROXY_IF_SANDBOXED(
CancelVibrate(InSandbox() ? std::move(id) : WindowIdentifier()));
}
}
class BatteryObserversManager final
: public CachingObserversManager<BatteryInformation> { protected: void EnableNotifications() override {
PROXY_IF_SANDBOXED(EnableBatteryNotifications());
}
class NetworkObserversManager final
: public CachingObserversManager<NetworkInformation> { protected: void EnableNotifications() override {
PROXY_IF_SANDBOXED(EnableNetworkNotifications());
}
class WakeLockObserversManager final
: public ObserversManager<WakeLockInformation> { protected: void EnableNotifications() override {
PROXY_IF_SANDBOXED(EnableWakeLockNotifications());
}
void SetProcessPriority(int aPid, ProcessPriority aPriority) { // n.b. The sandboxed implementation crashes; SetProcessPriority works only // from the main process.
PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority));
}
// From HalTypes.h. constchar* ProcessPriorityToString(ProcessPriority aPriority) { switch (aPriority) { case PROCESS_PRIORITY_PARENT_PROCESS: return"PARENT_PROCESS"; case PROCESS_PRIORITY_PREALLOC: return"PREALLOC"; case PROCESS_PRIORITY_FOREGROUND_HIGH: return"FOREGROUND_HIGH"; case PROCESS_PRIORITY_FOREGROUND: return"FOREGROUND"; case PROCESS_PRIORITY_FOREGROUND_KEYBOARD: return"FOREGROUND_KEYBOARD"; case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: return"BACKGROUND_PERCEIVABLE"; case PROCESS_PRIORITY_BACKGROUND: return"BACKGROUND"; case PROCESS_PRIORITY_UNKNOWN: return"UNKNOWN"; default:
MOZ_ASSERT(false); return"???";
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.