OLD | NEW |
---|---|
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) | 434 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) |
434 #if defined(IPC_MESSAGE_LOG_ENABLED) | 435 #if defined(IPC_MESSAGE_LOG_ENABLED) |
435 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, | 436 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, |
436 OnSetIPCLoggingEnabled) | 437 OnSetIPCLoggingEnabled) |
437 #endif | 438 #endif |
438 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, | 439 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, |
439 OnSetProfilerStatus) | 440 OnSetProfilerStatus) |
440 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, | 441 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, |
441 OnGetChildProfilerData) | 442 OnGetChildProfilerData) |
442 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) | 443 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) |
443 #if defined(OS_WIN) | |
444 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, | 444 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, |
445 OnProcessBackgrounded) | 445 OnProcessBackgrounded) |
446 #endif | |
447 #if defined(USE_TCMALLOC) | 446 #if defined(USE_TCMALLOC) |
448 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) | 447 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats) |
449 #endif | 448 #endif |
450 IPC_MESSAGE_UNHANDLED(handled = false) | 449 IPC_MESSAGE_UNHANDLED(handled = false) |
451 IPC_END_MESSAGE_MAP() | 450 IPC_END_MESSAGE_MAP() |
452 | 451 |
453 if (handled) | 452 if (handled) |
454 return true; | 453 return true; |
455 | 454 |
456 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 455 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 // race conditions if the process refcount is 0 but there's an IPC message | 544 // race conditions if the process refcount is 0 but there's an IPC message |
546 // inflight that would addref it. | 545 // inflight that would addref it. |
547 Send(new ChildProcessHostMsg_ShutdownRequest); | 546 Send(new ChildProcessHostMsg_ShutdownRequest); |
548 } | 547 } |
549 | 548 |
550 void ChildThread::EnsureConnected() { | 549 void ChildThread::EnsureConnected() { |
551 VLOG(0) << "ChildThread::EnsureConnected()"; | 550 VLOG(0) << "ChildThread::EnsureConnected()"; |
552 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 551 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
553 } | 552 } |
554 | 553 |
555 #if defined(OS_WIN) | |
556 void ChildThread::OnProcessBackgrounded(bool background) { | 554 void ChildThread::OnProcessBackgrounded(bool background) { |
555 // Set timer slack to maximum on main thread when in background. | |
556 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | |
557 if (background) | |
558 timer_slack = base::TIMER_SLACK_MAXIMUM; | |
559 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
| |
560 | |
561 // Windows Vista+ has a fancy process backgrounding mode that can only be set | |
562 // from within the process. | |
tonyg
2014/05/29 14:06:00
nit: indent
jeremy
2014/06/02 10:21:28
Done.
| |
563 #ifdef OS_WIN | |
557 base::Process::Current().SetProcessBackgrounded(background); | 564 base::Process::Current().SetProcessBackgrounded(background); |
565 #endif // OS_WIN | |
558 } | 566 } |
559 #endif | |
560 | 567 |
561 } // namespace content | 568 } // namespace content |
OLD | NEW |