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

Unified Diff: content/child/child_thread.cc

Issue 289863005: [Mac] Maximise timer slack for background tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A few small fixes Created 6 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/child/child_thread.cc
diff --git a/content/child/child_thread.cc b/content/child/child_thread.cc
index c66b7d42d4fddb2e579c0458e5d4ef48fea21163..9a23ad6597a011deecf6ac4a25e9af8c6ac064df 100644
--- a/content/child/child_thread.cc
+++ b/content/child/child_thread.cc
@@ -16,6 +16,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/timer_slack.h"
#include "base/process/kill.h"
#include "base/process/process_handle.h"
#include "base/strings/string_util.h"
@@ -440,10 +441,8 @@ bool ChildThread::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
OnGetChildProfilerData)
IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles)
-#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded,
OnProcessBackgrounded)
-#endif
#if defined(USE_TCMALLOC)
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats)
#endif
@@ -552,10 +551,18 @@ void ChildThread::EnsureConnected() {
base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
}
-#if defined(OS_WIN)
void ChildThread::OnProcessBackgrounded(bool background) {
+ // Set timer slack to maximum on main thread when in background.
+ base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
+ if (background)
+ timer_slack = base::TIMER_SLACK_MAXIMUM;
+ base::MessageLoop::current()->SetTimerSlack(timer_slack);
Avi (use Gerrit) 2014/05/29 14:24:16 Only the current thread?
jeremy 2014/06/02 10:21:28 In the current CL only the main renderer thread c
+
+ // Windows Vista+ has a fancy process backgrounding mode that can only be set
+ // from within the process.
tonyg 2014/05/29 14:06:00 nit: indent
jeremy 2014/06/02 10:21:28 Done.
+#ifdef OS_WIN
base::Process::Current().SetProcessBackgrounded(background);
+#endif // OS_WIN
}
-#endif
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698