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

Side by Side Diff: content/child/child_thread_impl.cc

Issue 926663002: Handle RenderProcessHostImpl::SetBackgrounded on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@908473002_ps2
Patch Set: Leave ChromeRenderProcessHostTest.Backgrounding disabled on Windows for now :-( Created 5 years, 10 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
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | no next file » | 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_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"
20 #include "base/process/kill.h" 21 #include "base/process/kill.h"
21 #include "base/process/process_handle.h" 22 #include "base/process/process_handle.h"
22 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/synchronization/condition_variable.h" 25 #include "base/synchronization/condition_variable.h"
25 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
26 #include "base/threading/thread_local.h" 27 #include "base/threading/thread_local.h"
27 #include "base/tracked_objects.h" 28 #include "base/tracked_objects.h"
28 #include "components/tracing/child_trace_message_filter.h" 29 #include "components/tracing/child_trace_message_filter.h"
29 #include "content/child/bluetooth/bluetooth_message_filter.h" 30 #include "content/child/bluetooth/bluetooth_message_filter.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 643 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
643 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); 644 base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
644 } 645 }
645 646
646 void ChildThreadImpl::OnProcessBackgrounded(bool background) { 647 void ChildThreadImpl::OnProcessBackgrounded(bool background) {
647 // Set timer slack to maximum on main thread when in background. 648 // Set timer slack to maximum on main thread when in background.
648 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 649 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
649 if (background) 650 if (background)
650 timer_slack = base::TIMER_SLACK_MAXIMUM; 651 timer_slack = base::TIMER_SLACK_MAXIMUM;
651 base::MessageLoop::current()->SetTimerSlack(timer_slack); 652 base::MessageLoop::current()->SetTimerSlack(timer_slack);
653
654 #ifdef OS_WIN
655 // Windows Vista+ has a fancy process backgrounding mode that can only be set
656 // from within the process. This used to be how chrome set its renderers into
657 // background mode on Windows but was removed due to http://crbug.com/398103.
658 // As we experiment with bringing back some other form of background mode for
659 // hidden renderers, add a bucket to allow us to trigger this undesired method
660 // of setting background state in order to confirm that the metrics which were
661 // added to prevent regressions on the aforementioned issue indeed catch such
662 // regressions and are thus a reliable way to confirm that our latest proposal
663 // doesn't cause such issues. TODO(gab): Remove this once the experiment is
664 // over (http://crbug.com/458594).
665 base::FieldTrial* trial =
666 base::FieldTrialList::Find("BackgroundRendererProcesses");
667 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer")
668 base::Process::Current().SetProcessBackgrounded(background);
669 #endif // OS_WIN
652 } 670 }
653 671
654 } // namespace content 672 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698