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 |