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 // 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> |
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 // The cbstext.dll loads as a global GetMessage hook in the browser process | 2200 // The cbstext.dll loads as a global GetMessage hook in the browser process |
2201 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a | 2201 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a |
2202 // background thread. If the UI thread invokes this API just when it is | 2202 // background thread. If the UI thread invokes this API just when it is |
2203 // intercepted the stack is messed up on return from the interceptor | 2203 // intercepted the stack is messed up on return from the interceptor |
2204 // which causes random crashes in the browser process. Our hack for now | 2204 // which causes random crashes in the browser process. Our hack for now |
2205 // is to not invoke the SetPriorityClass API if the dll is loaded. | 2205 // is to not invoke the SetPriorityClass API if the dll is loaded. |
2206 if (GetModuleHandle(L"cbstext.dll")) | 2206 if (GetModuleHandle(L"cbstext.dll")) |
2207 return; | 2207 return; |
2208 #endif // OS_WIN | 2208 #endif // OS_WIN |
2209 | 2209 |
2210 #if defined(OS_WIN) | |
2211 // Same as below, but bound to an experiment (http://crbug.com/458594) | |
2212 // initially on Windows. Enabled by default in the asbence of field trials to | |
2213 // get coverage on the perf waterfall. | |
2214 base::FieldTrial* trial = | |
2215 base::FieldTrialList::Find("BackgroundRendererProcesses"); | |
2216 if (!trial || (trial->group_name() != "Disallow" && | |
2217 trial->group_name() != "AllowBackgroundModeFromRenderer")) { | |
2218 child_process_launcher_->SetProcessBackgrounded(backgrounded); | |
2219 } | |
2220 #else | |
2221 // Control the background state from the browser process, otherwise the task | |
2222 // telling the renderer to "unbackground" itself may be preempted by other | |
2223 // tasks executing at lowered priority ahead of it or simply by not being | |
2224 // swiftly scheduled by the OS per the low process priority | |
2225 // (http://crbug.com/398103). | |
2226 child_process_launcher_->SetProcessBackgrounded(backgrounded); | |
2227 #endif // OS_WIN | |
2228 | |
2229 // Notify the child process of background state. | 2210 // Notify the child process of background state. |
2230 Send(new ChildProcessMsg_SetProcessBackgrounded(backgrounded)); | 2211 Send(new ChildProcessMsg_SetProcessBackgrounded(backgrounded)); |
| 2212 |
| 2213 #if !defined(OS_WIN) |
| 2214 // Backgrounding may require elevated privileges not available to renderer |
| 2215 // processes, so control backgrounding from the process host. |
| 2216 |
| 2217 // Windows Vista+ has a fancy process backgrounding mode that can only be set |
| 2218 // from within the process. |
| 2219 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
| 2220 #endif // !OS_WIN |
2231 } | 2221 } |
2232 | 2222 |
2233 void RenderProcessHostImpl::OnProcessLaunched() { | 2223 void RenderProcessHostImpl::OnProcessLaunched() { |
2234 // No point doing anything, since this object will be destructed soon. We | 2224 // No point doing anything, since this object will be destructed soon. We |
2235 // especially don't want to send the RENDERER_PROCESS_CREATED notification, | 2225 // especially don't want to send the RENDERER_PROCESS_CREATED notification, |
2236 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to | 2226 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to |
2237 // properly cleanup. | 2227 // properly cleanup. |
2238 if (deleting_soon_) | 2228 if (deleting_soon_) |
2239 return; | 2229 return; |
2240 | 2230 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 if (worker_ref_count_ == 0) | 2399 if (worker_ref_count_ == 0) |
2410 Cleanup(); | 2400 Cleanup(); |
2411 } | 2401 } |
2412 | 2402 |
2413 void RenderProcessHostImpl::GetAudioOutputControllers( | 2403 void RenderProcessHostImpl::GetAudioOutputControllers( |
2414 const GetAudioOutputControllersCallback& callback) const { | 2404 const GetAudioOutputControllersCallback& callback) const { |
2415 audio_renderer_host()->GetOutputControllers(callback); | 2405 audio_renderer_host()->GetOutputControllers(callback); |
2416 } | 2406 } |
2417 | 2407 |
2418 } // namespace content | 2408 } // namespace content |
OLD | NEW |