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

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

Issue 2914913002: [Mac] Enable AppNap for renderers (Closed)
Patch Set: Clean up Created 3 years, 7 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
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..1e09ddd3f0da0d2ded6ff213af7b084936014fd4 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,18 @@ AppNapActivity::~AppNapActivity() {
DCHECK(!assertion_->obj.get());
};
+void AppNapActivity::InitializeAppNapSupport() {
+ // Reason strings are the same as
+ // what macOS sends in the corresponding call.
+ //
+ // Normally happens during launch services check-in.
+ __CFRunLoopSetOptionsReason(
+ 1, @"Finished checking in as application - waiting for events", 0);
+ // Normally happens in a dispatch_once in the NSApplication event loop.
+ __CFRunLoopSetOptionsReason(
+ 0x3b000000, @"Finished delay after app launch and bundle check", 0);
shrike 2017/06/02 19:57:53 Can 0x3b000000 be defined as a constant with a rea
lgrey 2017/06/05 14:49:43 It's magic to us, unfortunately (as is the "1" in
shrike 2017/06/05 15:29:36 So is it an "or" of NSActivity flags? If so, can y
+}
+
void AppNapActivity::Begin() {
DCHECK(!assertion_->obj.get());
id assertion =

Powered by Google App Engine
This is Rietveld 408576698