| 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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 return false; // Render process hasn't started or is probably crashed. | 887 return false; // Render process hasn't started or is probably crashed. |
| 888 | 888 |
| 889 // Test if there's an unload listener. | 889 // Test if there's an unload listener. |
| 890 // NOTE: It's possible that an onunload listener may be installed | 890 // NOTE: It's possible that an onunload listener may be installed |
| 891 // while we're shutting down, so there's a small race here. Given that | 891 // while we're shutting down, so there's a small race here. Given that |
| 892 // the window is small, it's unlikely that the web page has much | 892 // the window is small, it's unlikely that the web page has much |
| 893 // state that will be lost by not calling its unload handlers properly. | 893 // state that will be lost by not calling its unload handlers properly. |
| 894 if (!SuddenTerminationAllowed()) | 894 if (!SuddenTerminationAllowed()) |
| 895 return false; | 895 return false; |
| 896 | 896 |
| 897 ProcessDied(); | 897 ProcessDied(false /* already_dead */); |
| 898 fast_shutdown_started_ = true; | 898 fast_shutdown_started_ = true; |
| 899 return true; | 899 return true; |
| 900 } | 900 } |
| 901 | 901 |
| 902 void RenderProcessHostImpl::DumpHandles() { | 902 void RenderProcessHostImpl::DumpHandles() { |
| 903 #if defined(OS_WIN) | 903 #if defined(OS_WIN) |
| 904 Send(new ChildProcessMsg_DumpHandles()); | 904 Send(new ChildProcessMsg_DumpHandles()); |
| 905 return; | 905 return; |
| 906 #endif | 906 #endif |
| 907 | 907 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 1068 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| 1069 IPC::Logging::GetInstance()->Enabled())); | 1069 IPC::Logging::GetInstance()->Enabled())); |
| 1070 #endif | 1070 #endif |
| 1071 | 1071 |
| 1072 tracked_objects::ThreadData::Status status = | 1072 tracked_objects::ThreadData::Status status = |
| 1073 tracked_objects::ThreadData::status(); | 1073 tracked_objects::ThreadData::status(); |
| 1074 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 1074 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 void RenderProcessHostImpl::OnChannelError() { | 1077 void RenderProcessHostImpl::OnChannelError() { |
| 1078 ProcessDied(); | 1078 ProcessDied(true /* already_dead */); |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { | 1081 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { |
| 1082 return browser_context_; | 1082 return browser_context_; |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 bool RenderProcessHostImpl::InSameStoragePartition( | 1085 bool RenderProcessHostImpl::InSameStoragePartition( |
| 1086 StoragePartition* partition) const { | 1086 StoragePartition* partition) const { |
| 1087 return storage_partition_impl_ == partition; | 1087 return storage_partition_impl_ == partition; |
| 1088 } | 1088 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 GetSiteProcessMapForBrowserContext(browser_context); | 1411 GetSiteProcessMapForBrowserContext(browser_context); |
| 1412 | 1412 |
| 1413 // TODO(creis): Determine if it's better to allow registration of | 1413 // TODO(creis): Determine if it's better to allow registration of |
| 1414 // empty sites or not. For now, group anything from which we can't parse | 1414 // empty sites or not. For now, group anything from which we can't parse |
| 1415 // a site into the same process, when using --process-per-site. | 1415 // a site into the same process, when using --process-per-site. |
| 1416 std::string site = SiteInstanceImpl::GetSiteForURL(browser_context, url) | 1416 std::string site = SiteInstanceImpl::GetSiteForURL(browser_context, url) |
| 1417 .possibly_invalid_spec(); | 1417 .possibly_invalid_spec(); |
| 1418 map->RegisterProcess(site, process); | 1418 map->RegisterProcess(site, process); |
| 1419 } | 1419 } |
| 1420 | 1420 |
| 1421 void RenderProcessHostImpl::ProcessDied() { | 1421 void RenderProcessHostImpl::ProcessDied(bool already_dead) { |
| 1422 // Our child process has died. If we didn't expect it, it's a crash. | 1422 // Our child process has died. If we didn't expect it, it's a crash. |
| 1423 // In any case, we need to let everyone know it's gone. | 1423 // In any case, we need to let everyone know it's gone. |
| 1424 // The OnChannelError notification can fire multiple times due to nested sync | 1424 // The OnChannelError notification can fire multiple times due to nested sync |
| 1425 // calls to a renderer. If we don't have a valid channel here it means we | 1425 // calls to a renderer. If we don't have a valid channel here it means we |
| 1426 // already handled the error. | 1426 // already handled the error. |
| 1427 | 1427 |
| 1428 // child_process_launcher_ can be NULL in single process mode or if fast | 1428 // child_process_launcher_ can be NULL in single process mode or if fast |
| 1429 // termination happened. | 1429 // termination happened. |
| 1430 int exit_code = 0; | 1430 int exit_code = 0; |
| 1431 base::TerminationStatus status = | 1431 base::TerminationStatus status = |
| 1432 child_process_launcher_.get() ? | 1432 child_process_launcher_.get() ? |
| 1433 child_process_launcher_->GetChildTerminationStatus(&exit_code) : | 1433 child_process_launcher_->GetChildTerminationStatus(already_dead, |
| 1434 &exit_code) : |
| 1434 base::TERMINATION_STATUS_NORMAL_TERMINATION; | 1435 base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 1435 | 1436 |
| 1436 RendererClosedDetails details(GetHandle(), status, exit_code); | 1437 RendererClosedDetails details(GetHandle(), status, exit_code); |
| 1437 NotificationService::current()->Notify( | 1438 NotificationService::current()->Notify( |
| 1438 NOTIFICATION_RENDERER_PROCESS_CLOSED, | 1439 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 1439 Source<RenderProcessHost>(this), | 1440 Source<RenderProcessHost>(this), |
| 1440 Details<RendererClosedDetails>(&details)); | 1441 Details<RendererClosedDetails>(&details)); |
| 1441 | 1442 |
| 1442 child_process_launcher_.reset(); | 1443 child_process_launcher_.reset(); |
| 1443 channel_.reset(); | 1444 channel_.reset(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 int32 gpu_process_host_id) { | 1583 int32 gpu_process_host_id) { |
| 1583 TRACE_EVENT0("renderer_host", | 1584 TRACE_EVENT0("renderer_host", |
| 1584 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1585 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1585 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1586 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 1586 gpu_process_host_id, | 1587 gpu_process_host_id, |
| 1587 false, | 1588 false, |
| 1588 0); | 1589 0); |
| 1589 } | 1590 } |
| 1590 | 1591 |
| 1591 } // namespace content | 1592 } // namespace content |
| OLD | NEW |