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

Unified Diff: content/child/child_thread_impl.cc

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/child/child_thread_impl.h ('k') | content/common/mac/app_nap_activity.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_thread_impl.cc
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
index a349241e2a05556b88f1e052404486f2f57d44e3..90e1e698856c11fe28eb36ee3f3320d3feceac77 100644
--- a/content/child/child_thread_impl.cc
+++ b/content/child/child_thread_impl.cc
@@ -80,6 +80,8 @@
#if defined(OS_MACOSX)
#include "base/allocator/allocator_interception_mac.h"
+#include "base/process/process.h"
+#include "content/common/mac/app_nap_activity.h"
#endif
using tracked_objects::ThreadData;
@@ -563,6 +565,10 @@ void ChildThreadImpl::Init(const Options& options) {
switches::kEnableHeapProfiling)) {
base::allocator::PeriodicallyShimNewMallocZones();
}
+ if (base::Process::IsAppNapEnabled()) {
+ app_nap_activity_.reset(new AppNapActivity());
+ app_nap_activity_->Begin();
+ };
#endif
message_loop_->task_runner()->PostDelayedTask(
@@ -757,6 +763,15 @@ void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) {
if (backgrounded)
timer_slack = base::TIMER_SLACK_MAXIMUM;
base::MessageLoop::current()->SetTimerSlack(timer_slack);
+#if defined(OS_MACOSX)
+ if (base::Process::IsAppNapEnabled()) {
+ if (backgrounded) {
+ app_nap_activity_->End();
+ } else {
+ app_nap_activity_->Begin();
+ }
+ }
+#endif // defined(OS_MACOSX)
}
void ChildThreadImpl::OnProcessPurgeAndSuspend() {
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/mac/app_nap_activity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698