OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2198 // (and hence hasn't been created yet), we will set the process priority | 2198 // (and hence hasn't been created yet), we will set the process priority |
2199 // later when we create the process. | 2199 // later when we create the process. |
2200 backgrounded_ = backgrounded; | 2200 backgrounded_ = backgrounded; |
2201 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 2201 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
2202 return; | 2202 return; |
2203 | 2203 |
2204 // Don't background processes which have active audio streams. | 2204 // Don't background processes which have active audio streams. |
2205 if (backgrounded_ && audio_renderer_host_->HasActiveAudio()) | 2205 if (backgrounded_ && audio_renderer_host_->HasActiveAudio()) |
2206 return; | 2206 return; |
2207 | 2207 |
2208 const base::CommandLine* command_line = | |
2209 base::CommandLine::ForCurrentProcess(); | |
2210 if (command_line->HasSwitch(switches::kDisableRendererBackgrounding)) { | |
2211 return; | |
2212 } | |
gab
2015/06/01 19:34:20
nit: Avoid {} (I know you like putting it all the
shrike
2015/06/02 18:06:31
It feels wrong, but you are right. Fixed.
| |
2213 | |
2208 #if defined(OS_WIN) | 2214 #if defined(OS_WIN) |
2209 // The cbstext.dll loads as a global GetMessage hook in the browser process | 2215 // The cbstext.dll loads as a global GetMessage hook in the browser process |
2210 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a | 2216 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a |
2211 // background thread. If the UI thread invokes this API just when it is | 2217 // background thread. If the UI thread invokes this API just when it is |
2212 // intercepted the stack is messed up on return from the interceptor | 2218 // intercepted the stack is messed up on return from the interceptor |
2213 // which causes random crashes in the browser process. Our hack for now | 2219 // which causes random crashes in the browser process. Our hack for now |
2214 // is to not invoke the SetPriorityClass API if the dll is loaded. | 2220 // is to not invoke the SetPriorityClass API if the dll is loaded. |
2215 if (GetModuleHandle(L"cbstext.dll")) | 2221 if (GetModuleHandle(L"cbstext.dll")) |
2216 return; | 2222 return; |
2217 #endif // OS_WIN | 2223 #endif // OS_WIN |
2218 | 2224 |
2219 #if defined(OS_WIN) | 2225 #if defined(OS_WIN) || defined(OS_MACOSX) |
2220 // Same as below, but bound to an experiment (http://crbug.com/458594) | 2226 // Same as below, but bound to an experiment (http://crbug.com/458594 on |
2221 // initially on Windows. Enabled by default in the asbence of field trials to | 2227 // Windows, http://crbug.com/398103 on the Mac). Enabled by default in the |
2222 // get coverage on the perf waterfall. | 2228 // absence of field trials to get coverage on the perf waterfall. |
2223 base::FieldTrial* trial = | 2229 base::FieldTrial* trial = |
2224 base::FieldTrialList::Find("BackgroundRendererProcesses"); | 2230 base::FieldTrialList::Find("BackgroundRendererProcesses"); |
2225 if (!trial || trial->group_name() != "Disallow") | 2231 if (!trial || !StartsWithASCII(trial->group_name(), "Disallow", true)) { |
2226 child_process_launcher_->SetProcessBackgrounded(backgrounded); | 2232 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
2233 } | |
2227 #else | 2234 #else |
2228 // Control the background state from the browser process, otherwise the task | 2235 // Control the background state from the browser process, otherwise the task |
2229 // telling the renderer to "unbackground" itself may be preempted by other | 2236 // telling the renderer to "unbackground" itself may be preempted by other |
2230 // tasks executing at lowered priority ahead of it or simply by not being | 2237 // tasks executing at lowered priority ahead of it or simply by not being |
2231 // swiftly scheduled by the OS per the low process priority | 2238 // swiftly scheduled by the OS per the low process priority |
2232 // (http://crbug.com/398103). | 2239 // (http://crbug.com/398103). |
2233 child_process_launcher_->SetProcessBackgrounded(backgrounded); | 2240 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
2234 #endif // OS_WIN | 2241 #endif // OS_WIN |
2235 | 2242 |
2236 // Notify the child process of background state. | 2243 // Notify the child process of background state. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2458 if (worker_ref_count_ == 0) | 2465 if (worker_ref_count_ == 0) |
2459 Cleanup(); | 2466 Cleanup(); |
2460 } | 2467 } |
2461 | 2468 |
2462 void RenderProcessHostImpl::GetAudioOutputControllers( | 2469 void RenderProcessHostImpl::GetAudioOutputControllers( |
2463 const GetAudioOutputControllersCallback& callback) const { | 2470 const GetAudioOutputControllersCallback& callback) const { |
2464 audio_renderer_host()->GetOutputControllers(callback); | 2471 audio_renderer_host()->GetOutputControllers(callback); |
2465 } | 2472 } |
2466 | 2473 |
2467 } // namespace content | 2474 } // namespace content |
OLD | NEW |