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 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 if (worker_ref_count_ != 0) { | 1431 if (worker_ref_count_ != 0) { |
1432 if (survive_for_worker_start_time_.is_null()) | 1432 if (survive_for_worker_start_time_.is_null()) |
1433 survive_for_worker_start_time_ = base::TimeTicks::Now(); | 1433 survive_for_worker_start_time_ = base::TimeTicks::Now(); |
1434 return false; | 1434 return false; |
1435 } | 1435 } |
1436 | 1436 |
1437 // Set this before ProcessDied() so observers can tell if the render process | 1437 // Set this before ProcessDied() so observers can tell if the render process |
1438 // died due to fast shutdown versus another cause. | 1438 // died due to fast shutdown versus another cause. |
1439 fast_shutdown_started_ = true; | 1439 fast_shutdown_started_ = true; |
1440 | 1440 |
1441 ProcessDied(false /* already_dead */); | 1441 ProcessDied(false /* already_dead */, nullptr); |
1442 return true; | 1442 return true; |
1443 } | 1443 } |
1444 | 1444 |
1445 void RenderProcessHostImpl::DumpHandles() { | 1445 void RenderProcessHostImpl::DumpHandles() { |
1446 #if defined(OS_WIN) | 1446 #if defined(OS_WIN) |
1447 Send(new ChildProcessMsg_DumpHandles()); | 1447 Send(new ChildProcessMsg_DumpHandles()); |
1448 #else | 1448 #else |
1449 NOTIMPLEMENTED(); | 1449 NOTIMPLEMENTED(); |
1450 #endif | 1450 #endif |
1451 } | 1451 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 1525 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
1526 IPC::Logging::GetInstance()->Enabled())); | 1526 IPC::Logging::GetInstance()->Enabled())); |
1527 #endif | 1527 #endif |
1528 | 1528 |
1529 tracked_objects::ThreadData::Status status = | 1529 tracked_objects::ThreadData::Status status = |
1530 tracked_objects::ThreadData::status(); | 1530 tracked_objects::ThreadData::status(); |
1531 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 1531 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
1532 } | 1532 } |
1533 | 1533 |
1534 void RenderProcessHostImpl::OnChannelError() { | 1534 void RenderProcessHostImpl::OnChannelError() { |
1535 ProcessDied(true /* already_dead */); | 1535 ProcessDied(true /* already_dead */, nullptr); |
1536 } | 1536 } |
1537 | 1537 |
1538 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { | 1538 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { |
1539 // Message de-serialization failed. We consider this a capital crime. Kill the | 1539 // Message de-serialization failed. We consider this a capital crime. Kill the |
1540 // renderer if we have one. | 1540 // renderer if we have one. |
1541 LOG(ERROR) << "bad message " << message.type() << " terminating renderer."; | 1541 LOG(ERROR) << "bad message " << message.type() << " terminating renderer."; |
1542 BrowserChildProcessHostImpl::HistogramBadMessageTerminated( | 1542 BrowserChildProcessHostImpl::HistogramBadMessageTerminated( |
1543 PROCESS_TYPE_RENDERER); | 1543 PROCESS_TYPE_RENDERER); |
1544 ReceivedBadMessage(); | 1544 ReceivedBadMessage(); |
1545 } | 1545 } |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 | 1996 |
1997 // Only register valid, non-empty sites. Empty or invalid sites will not | 1997 // Only register valid, non-empty sites. Empty or invalid sites will not |
1998 // use process-per-site mode. We cannot check whether the process has | 1998 // use process-per-site mode. We cannot check whether the process has |
1999 // appropriate bindings here, because the bindings have not yet been granted. | 1999 // appropriate bindings here, because the bindings have not yet been granted. |
2000 std::string site = SiteInstance::GetSiteForURL(browser_context, url) | 2000 std::string site = SiteInstance::GetSiteForURL(browser_context, url) |
2001 .possibly_invalid_spec(); | 2001 .possibly_invalid_spec(); |
2002 if (!site.empty()) | 2002 if (!site.empty()) |
2003 map->RegisterProcess(site, process); | 2003 map->RegisterProcess(site, process); |
2004 } | 2004 } |
2005 | 2005 |
2006 void RenderProcessHostImpl::ProcessDied(bool already_dead) { | 2006 void RenderProcessHostImpl::ProcessDied(bool already_dead, |
| 2007 RendererClosedDetails* known_details) { |
2007 // Our child process has died. If we didn't expect it, it's a crash. | 2008 // Our child process has died. If we didn't expect it, it's a crash. |
2008 // In any case, we need to let everyone know it's gone. | 2009 // In any case, we need to let everyone know it's gone. |
2009 // The OnChannelError notification can fire multiple times due to nested sync | 2010 // The OnChannelError notification can fire multiple times due to nested sync |
2010 // calls to a renderer. If we don't have a valid channel here it means we | 2011 // calls to a renderer. If we don't have a valid channel here it means we |
2011 // already handled the error. | 2012 // already handled the error. |
2012 | 2013 |
2013 // It should not be possible for us to be called re-entrantly. | 2014 // It should not be possible for us to be called re-entrantly. |
2014 DCHECK(!within_process_died_observer_); | 2015 DCHECK(!within_process_died_observer_); |
2015 | 2016 |
2016 // It should not be possible for a process death notification to come in while | 2017 // It should not be possible for a process death notification to come in while |
2017 // we are dying. | 2018 // we are dying. |
2018 DCHECK(!deleting_soon_); | 2019 DCHECK(!deleting_soon_); |
2019 | 2020 |
2020 // child_process_launcher_ can be NULL in single process mode or if fast | 2021 // child_process_launcher_ can be NULL in single process mode or if fast |
2021 // termination happened. | 2022 // termination happened. |
| 2023 base::TerminationStatus status = base::TERMINATION_STATUS_NORMAL_TERMINATION; |
2022 int exit_code = 0; | 2024 int exit_code = 0; |
2023 base::TerminationStatus status = | 2025 if (known_details) { |
2024 child_process_launcher_.get() ? | 2026 status = known_details->status; |
2025 child_process_launcher_->GetChildTerminationStatus(already_dead, | 2027 exit_code = known_details->exit_code; |
2026 &exit_code) : | 2028 } else if (child_process_launcher_.get()) { |
2027 base::TERMINATION_STATUS_NORMAL_TERMINATION; | 2029 status = child_process_launcher_->GetChildTerminationStatus(already_dead, |
| 2030 &exit_code); |
| 2031 } |
2028 | 2032 |
2029 RendererClosedDetails details(status, exit_code); | 2033 RendererClosedDetails details(status, exit_code); |
2030 mojo_application_host_->WillDestroySoon(); | 2034 mojo_application_host_->WillDestroySoon(); |
2031 | 2035 |
2032 child_process_launcher_.reset(); | 2036 child_process_launcher_.reset(); |
2033 channel_.reset(); | 2037 channel_.reset(); |
2034 | 2038 |
2035 within_process_died_observer_ = true; | 2039 within_process_died_observer_ = true; |
2036 NotificationService::current()->Notify( | 2040 NotificationService::current()->Notify( |
2037 NOTIFICATION_RENDERER_PROCESS_CLOSED, | 2041 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 Send(queued_messages_.front()); | 2234 Send(queued_messages_.front()); |
2231 queued_messages_.pop(); | 2235 queued_messages_.pop(); |
2232 } | 2236 } |
2233 | 2237 |
2234 #if defined(ENABLE_WEBRTC) | 2238 #if defined(ENABLE_WEBRTC) |
2235 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) | 2239 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) |
2236 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); | 2240 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); |
2237 #endif | 2241 #endif |
2238 } | 2242 } |
2239 | 2243 |
| 2244 void RenderProcessHostImpl::OnProcessLaunchFailed() { |
| 2245 RendererClosedDetails details { base::TERMINATION_STATUS_PROCESS_WAS_KILLED, |
| 2246 -1 }; |
| 2247 ProcessDied(true, &details); |
| 2248 } |
| 2249 |
2240 scoped_refptr<AudioRendererHost> | 2250 scoped_refptr<AudioRendererHost> |
2241 RenderProcessHostImpl::audio_renderer_host() const { | 2251 RenderProcessHostImpl::audio_renderer_host() const { |
2242 return audio_renderer_host_; | 2252 return audio_renderer_host_; |
2243 } | 2253 } |
2244 | 2254 |
2245 void RenderProcessHostImpl::OnUserMetricsRecordAction( | 2255 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
2246 const std::string& action) { | 2256 const std::string& action) { |
2247 RecordComputedAction(action); | 2257 RecordComputedAction(action); |
2248 } | 2258 } |
2249 | 2259 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2359 | 2369 |
2360 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2370 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2361 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2371 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2362 DCHECK_GT(worker_ref_count_, 0); | 2372 DCHECK_GT(worker_ref_count_, 0); |
2363 --worker_ref_count_; | 2373 --worker_ref_count_; |
2364 if (worker_ref_count_ == 0) | 2374 if (worker_ref_count_ == 0) |
2365 Cleanup(); | 2375 Cleanup(); |
2366 } | 2376 } |
2367 | 2377 |
2368 } // namespace content | 2378 } // namespace content |
OLD | NEW |