Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1064)

Unified Diff: content/common/mac/app_nap_activity.mm

Issue 2914913002: [Mac] Enable AppNap for renderers (Closed)
Patch Set: Add comment for magic numbers Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/mac/app_nap_activity.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mac/app_nap_activity.mm
diff --git a/content/common/mac/app_nap_activity.mm b/content/common/mac/app_nap_activity.mm
index d2c82e80a8687d31ee4bbf1d4df96694d84facaf..4fa7b581e375ed305f04d38b5d76af622f81f475 100644
--- a/content/common/mac/app_nap_activity.mm
+++ b/content/common/mac/app_nap_activity.mm
@@ -8,6 +8,12 @@
#include "base/mac/scoped_nsobject.h"
+extern "C" {
+void __CFRunLoopSetOptionsReason(uint64_t options,
+ NSString* reason,
+ int unused);
+}
+
namespace content {
namespace {
@@ -33,6 +39,21 @@ AppNapActivity::~AppNapActivity() {
DCHECK(!assertion_->obj.get());
};
+void AppNapActivity::InitializeAppNapSupport() {
+ // Reason strings are the same as
+ // what macOS sends in the corresponding call.
+ // |options| (argument 1) are magic numbers as found in the
+ // callsites mentioned above.
+ //
+ // Normally happens during launch services check-in. (HIToolbox)
+ __CFRunLoopSetOptionsReason(
+ 1, @"Finished checking in as application - waiting for events", 0);
+ // Normally happens in a dispatch_once in the NSApplication event loop.
+ // (CoreFoundation).
+ __CFRunLoopSetOptionsReason(
+ 0x3b000000, @"Finished delay after app launch and bundle check", 0);
+}
+
void AppNapActivity::Begin() {
DCHECK(!assertion_->obj.get());
id assertion =
« no previous file with comments | « content/common/mac/app_nap_activity.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698