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

Side by Side 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: Really rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/child_thread.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/child_thread.h" 5 #include "content/child/child_thread.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/allocator/allocator_extension.h" 11 #include "base/allocator/allocator_extension.h"
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/debug/leak_annotations.h" 15 #include "base/debug/leak_annotations.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/message_loop/timer_slack.h"
19 #include "base/process/kill.h" 20 #include "base/process/kill.h"
20 #include "base/process/process_handle.h" 21 #include "base/process/process_handle.h"
21 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
22 #include "base/synchronization/condition_variable.h" 23 #include "base/synchronization/condition_variable.h"
23 #include "base/synchronization/lock.h" 24 #include "base/synchronization/lock.h"
24 #include "base/threading/thread_local.h" 25 #include "base/threading/thread_local.h"
25 #include "base/tracked_objects.h" 26 #include "base/tracked_objects.h"
26 #include "components/tracing/child_trace_message_filter.h" 27 #include "components/tracing/child_trace_message_filter.h"
27 #include "content/child/child_histogram_message_filter.h" 28 #include "content/child/child_histogram_message_filter.h"
28 #include "content/child/child_process.h" 29 #include "content/child/child_process.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 436 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
436 #if defined(IPC_MESSAGE_LOG_ENABLED) 437 #if defined(IPC_MESSAGE_LOG_ENABLED)
437 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 438 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
438 OnSetIPCLoggingEnabled) 439 OnSetIPCLoggingEnabled)
439 #endif 440 #endif
440 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, 441 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus,
441 OnSetProfilerStatus) 442 OnSetProfilerStatus)
442 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, 443 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
443 OnGetChildProfilerData) 444 OnGetChildProfilerData)
444 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) 445 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles)
445 #if defined(OS_WIN)
446 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, 446 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded,
447 OnProcessBackgrounded) 447 OnProcessBackgrounded)
448 #endif
449 #if defined(USE_TCMALLOC) 448 #if defined(USE_TCMALLOC)
450 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) 449 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats)
451 #endif 450 #endif
452 IPC_MESSAGE_UNHANDLED(handled = false) 451 IPC_MESSAGE_UNHANDLED(handled = false)
453 IPC_END_MESSAGE_MAP() 452 IPC_END_MESSAGE_MAP()
454 453
455 if (handled) 454 if (handled)
456 return true; 455 return true;
457 456
458 if (msg.routing_id() == MSG_ROUTING_CONTROL) 457 if (msg.routing_id() == MSG_ROUTING_CONTROL)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // race conditions if the process refcount is 0 but there's an IPC message 546 // race conditions if the process refcount is 0 but there's an IPC message
548 // inflight that would addref it. 547 // inflight that would addref it.
549 Send(new ChildProcessHostMsg_ShutdownRequest); 548 Send(new ChildProcessHostMsg_ShutdownRequest);
550 } 549 }
551 550
552 void ChildThread::EnsureConnected() { 551 void ChildThread::EnsureConnected() {
553 VLOG(0) << "ChildThread::EnsureConnected()"; 552 VLOG(0) << "ChildThread::EnsureConnected()";
554 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); 553 base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
555 } 554 }
556 555
557 #if defined(OS_WIN)
558 void ChildThread::OnProcessBackgrounded(bool background) { 556 void ChildThread::OnProcessBackgrounded(bool background) {
557 // Set timer slack to maximum on main thread when in background.
558 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
559 if (background)
560 timer_slack = base::TIMER_SLACK_MAXIMUM;
561 base::MessageLoop::current()->SetTimerSlack(timer_slack);
562
563 #ifdef OS_WIN
564 // Windows Vista+ has a fancy process backgrounding mode that can only be set
565 // from within the process.
559 base::Process::Current().SetProcessBackgrounded(background); 566 base::Process::Current().SetProcessBackgrounded(background);
567 #endif // OS_WIN
560 } 568 }
561 #endif
562 569
563 } // namespace content 570 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698