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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 std::string value = | 1273 std::string value = |
1274 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); | 1274 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); |
1275 if (value.empty() || value == switches::kRendererProcess) { | 1275 if (value.empty() || value == switches::kRendererProcess) { |
1276 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); | 1276 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); |
1277 } | 1277 } |
1278 } | 1278 } |
1279 } | 1279 } |
1280 | 1280 |
1281 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { | 1281 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { |
1282 if (run_renderer_in_process()) | 1282 if (run_renderer_in_process()) |
1283 return base::Process::Current().handle(); | 1283 return base::GetCurrentProcessHandle(); |
1284 | 1284 |
1285 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) | 1285 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) |
1286 return base::kNullProcessHandle; | 1286 return base::kNullProcessHandle; |
1287 | 1287 |
1288 return child_process_launcher_->GetHandle(); | 1288 return child_process_launcher_->GetProcess().Handle(); |
1289 } | 1289 } |
1290 | 1290 |
1291 bool RenderProcessHostImpl::FastShutdownIfPossible() { | 1291 bool RenderProcessHostImpl::FastShutdownIfPossible() { |
1292 if (run_renderer_in_process()) | 1292 if (run_renderer_in_process()) |
1293 return false; // Single process mode never shutdown the renderer. | 1293 return false; // Single process mode never shutdown the renderer. |
1294 | 1294 |
1295 if (!GetContentClient()->browser()->IsFastShutdownPossible()) | 1295 if (!GetContentClient()->browser()->IsFastShutdownPossible()) |
1296 return false; | 1296 return false; |
1297 | 1297 |
1298 if (!child_process_launcher_.get() || | 1298 if (!child_process_launcher_.get() || |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 | 2066 |
2067 void RenderProcessHostImpl::OnProcessLaunched() { | 2067 void RenderProcessHostImpl::OnProcessLaunched() { |
2068 // No point doing anything, since this object will be destructed soon. We | 2068 // No point doing anything, since this object will be destructed soon. We |
2069 // especially don't want to send the RENDERER_PROCESS_CREATED notification, | 2069 // especially don't want to send the RENDERER_PROCESS_CREATED notification, |
2070 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to | 2070 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to |
2071 // properly cleanup. | 2071 // properly cleanup. |
2072 if (deleting_soon_) | 2072 if (deleting_soon_) |
2073 return; | 2073 return; |
2074 | 2074 |
2075 if (child_process_launcher_) { | 2075 if (child_process_launcher_) { |
2076 if (!child_process_launcher_->GetHandle()) { | 2076 DCHECK(child_process_launcher_->GetProcess().IsValid()); |
2077 OnChannelError(); | |
2078 return; | |
2079 } | |
2080 | |
2081 SetBackgrounded(backgrounded_); | 2077 SetBackgrounded(backgrounded_); |
2082 } | 2078 } |
2083 | 2079 |
2084 // NOTE: This needs to be before sending queued messages because | 2080 // NOTE: This needs to be before sending queued messages because |
2085 // ExtensionService uses this notification to initialize the renderer process | 2081 // ExtensionService uses this notification to initialize the renderer process |
2086 // with state that must be there before any JavaScript executes. | 2082 // with state that must be there before any JavaScript executes. |
2087 // | 2083 // |
2088 // The queued messages contain such things as "navigate". If this notification | 2084 // The queued messages contain such things as "navigate". If this notification |
2089 // was after, we can end up executing JavaScript before the initialization | 2085 // was after, we can end up executing JavaScript before the initialization |
2090 // happens. | 2086 // happens. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 | 2230 |
2235 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2231 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2236 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2232 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2237 DCHECK_GT(worker_ref_count_, 0); | 2233 DCHECK_GT(worker_ref_count_, 0); |
2238 --worker_ref_count_; | 2234 --worker_ref_count_; |
2239 if (worker_ref_count_ == 0) | 2235 if (worker_ref_count_ == 0) |
2240 Cleanup(); | 2236 Cleanup(); |
2241 } | 2237 } |
2242 | 2238 |
2243 } // namespace content | 2239 } // namespace content |
OLD | NEW |