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_impl.h" | 5 #include "content/child/child_thread_impl.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/message_loop/timer_slack.h" |
20 #include "base/metrics/field_trial.h" | |
21 #include "base/process/kill.h" | 20 #include "base/process/kill.h" |
22 #include "base/process/process_handle.h" | 21 #include "base/process/process_handle.h" |
23 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
25 #include "base/synchronization/condition_variable.h" | 24 #include "base/synchronization/condition_variable.h" |
26 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
27 #include "base/threading/thread_local.h" | 26 #include "base/threading/thread_local.h" |
28 #include "base/tracked_objects.h" | 27 #include "base/tracked_objects.h" |
29 #include "components/tracing/child_trace_message_filter.h" | 28 #include "components/tracing/child_trace_message_filter.h" |
30 #include "content/child/bluetooth/bluetooth_message_filter.h" | 29 #include "content/child/bluetooth/bluetooth_message_filter.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 627 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
629 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 628 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
630 } | 629 } |
631 | 630 |
632 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | 631 void ChildThreadImpl::OnProcessBackgrounded(bool background) { |
633 // Set timer slack to maximum on main thread when in background. | 632 // Set timer slack to maximum on main thread when in background. |
634 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 633 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
635 if (background) | 634 if (background) |
636 timer_slack = base::TIMER_SLACK_MAXIMUM; | 635 timer_slack = base::TIMER_SLACK_MAXIMUM; |
637 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 636 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
638 | |
639 #ifdef OS_WIN | |
640 // Windows Vista+ has a fancy process backgrounding mode that can only be set | |
641 // from within the process. This used to be how chrome set its renderers into | |
642 // background mode on Windows but was removed due to http://crbug.com/398103. | |
643 // As we experiment with bringing back some other form of background mode for | |
644 // hidden renderers, add a bucket to allow us to trigger this undesired method | |
645 // of setting background state in order to confirm that the metrics which were | |
646 // added to prevent regressions on the aforementioned issue indeed catch such | |
647 // regressions and are thus a reliable way to confirm that our latest proposal | |
648 // doesn't cause such issues. TODO(gab): Remove this once the experiment is | |
649 // over (http://crbug.com/458594). | |
650 base::FieldTrial* trial = | |
651 base::FieldTrialList::Find("BackgroundRendererProcesses"); | |
652 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") | |
653 base::Process::Current().SetProcessBackgrounded(background); | |
654 #endif // OS_WIN | |
655 } | 637 } |
656 | 638 |
657 } // namespace content | 639 } // namespace content |
OLD | NEW |