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 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #include "ipc/ipc_switches.h" | 109 #include "ipc/ipc_switches.h" |
110 #include "media/base/media_switches.h" | 110 #include "media/base/media_switches.h" |
111 #include "net/url_request/url_request_context_getter.h" | 111 #include "net/url_request/url_request_context_getter.h" |
112 #include "ui/base/ui_base_switches.h" | 112 #include "ui/base/ui_base_switches.h" |
113 #include "ui/gl/gl_switches.h" | 113 #include "ui/gl/gl_switches.h" |
114 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 114 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
115 #include "webkit/glue/resource_type.h" | 115 #include "webkit/glue/resource_type.h" |
116 #include "webkit/plugins/plugin_switches.h" | 116 #include "webkit/plugins/plugin_switches.h" |
117 | 117 |
118 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
119 #include "base/synchronization/waitable_event.h" | |
120 #include "content/common/font_cache_dispatcher_win.h" | 119 #include "content/common/font_cache_dispatcher_win.h" |
121 #endif | 120 #endif |
122 | 121 |
123 #include "third_party/skia/include/core/SkBitmap.h" | 122 #include "third_party/skia/include/core/SkBitmap.h" |
124 | 123 |
125 extern bool g_exited_main_message_loop; | 124 extern bool g_exited_main_message_loop; |
126 | 125 |
127 static const char* kSiteProcessMapKeyName = "content_site_process_map"; | 126 static const char* kSiteProcessMapKeyName = "content_site_process_map"; |
128 | 127 |
129 namespace content { | 128 namespace content { |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 return false; // Render process hasn't started or is probably crashed. | 847 return false; // Render process hasn't started or is probably crashed. |
849 | 848 |
850 // Test if there's an unload listener. | 849 // Test if there's an unload listener. |
851 // NOTE: It's possible that an onunload listener may be installed | 850 // NOTE: It's possible that an onunload listener may be installed |
852 // while we're shutting down, so there's a small race here. Given that | 851 // while we're shutting down, so there's a small race here. Given that |
853 // the window is small, it's unlikely that the web page has much | 852 // the window is small, it's unlikely that the web page has much |
854 // state that will be lost by not calling its unload handlers properly. | 853 // state that will be lost by not calling its unload handlers properly. |
855 if (!SuddenTerminationAllowed()) | 854 if (!SuddenTerminationAllowed()) |
856 return false; | 855 return false; |
857 | 856 |
858 // Store the handle before it gets changed. | 857 ProcessDied(); |
859 base::ProcessHandle handle = GetHandle(); | |
860 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); | |
861 fast_shutdown_started_ = true; | 858 fast_shutdown_started_ = true; |
862 return true; | 859 return true; |
863 } | 860 } |
864 | 861 |
865 void RenderProcessHostImpl::DumpHandles() { | 862 void RenderProcessHostImpl::DumpHandles() { |
866 #if defined(OS_WIN) | 863 #if defined(OS_WIN) |
867 Send(new ChildProcessMsg_DumpHandles()); | 864 Send(new ChildProcessMsg_DumpHandles()); |
868 return; | 865 return; |
869 #endif | 866 #endif |
870 | 867 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 1017 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
1021 IPC::Logging::GetInstance()->Enabled())); | 1018 IPC::Logging::GetInstance()->Enabled())); |
1022 #endif | 1019 #endif |
1023 | 1020 |
1024 tracked_objects::ThreadData::Status status = | 1021 tracked_objects::ThreadData::Status status = |
1025 tracked_objects::ThreadData::status(); | 1022 tracked_objects::ThreadData::status(); |
1026 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 1023 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
1027 } | 1024 } |
1028 | 1025 |
1029 void RenderProcessHostImpl::OnChannelError() { | 1026 void RenderProcessHostImpl::OnChannelError() { |
1030 if (!channel_.get()) | 1027 ProcessDied(); |
1031 return; | |
1032 | |
1033 // Store the handle before it gets changed. | |
1034 base::ProcessHandle handle = GetHandle(); | |
1035 | |
1036 // child_process_launcher_ can be NULL in single process mode or if fast | |
1037 // termination happened. | |
1038 int exit_code = 0; | |
1039 base::TerminationStatus status = | |
1040 child_process_launcher_.get() ? | |
1041 child_process_launcher_->GetChildTerminationStatus(&exit_code) : | |
1042 base::TERMINATION_STATUS_NORMAL_TERMINATION; | |
1043 | |
1044 #if defined(OS_WIN) | |
1045 if (!run_renderer_in_process()) { | |
1046 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { | |
1047 HANDLE process = child_process_launcher_->GetHandle(); | |
1048 child_process_watcher_.StartWatching( | |
1049 new base::WaitableEvent(process), this); | |
1050 return; | |
1051 } | |
1052 } | |
1053 #endif | |
1054 ProcessDied(handle, status, exit_code, false); | |
1055 } | |
1056 | |
1057 // Called when the renderer process handle has been signaled. | |
1058 void RenderProcessHostImpl::OnWaitableEventSignaled( | |
1059 base::WaitableEvent* waitable_event) { | |
1060 #if defined (OS_WIN) | |
1061 base::ProcessHandle handle = GetHandle(); | |
1062 int exit_code = 0; | |
1063 base::TerminationStatus status = | |
1064 base::GetTerminationStatus(waitable_event->Release(), &exit_code); | |
1065 delete waitable_event; | |
1066 ProcessDied(handle, status, exit_code, true); | |
1067 #endif | |
1068 } | 1028 } |
1069 | 1029 |
1070 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { | 1030 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { |
1071 return browser_context_; | 1031 return browser_context_; |
1072 } | 1032 } |
1073 | 1033 |
1074 int RenderProcessHostImpl::GetID() const { | 1034 int RenderProcessHostImpl::GetID() const { |
1075 return id_; | 1035 return id_; |
1076 } | 1036 } |
1077 | 1037 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 GetSiteProcessMapForBrowserContext(browser_context); | 1331 GetSiteProcessMapForBrowserContext(browser_context); |
1372 | 1332 |
1373 // TODO(creis): Determine if it's better to allow registration of | 1333 // TODO(creis): Determine if it's better to allow registration of |
1374 // empty sites or not. For now, group anything from which we can't parse | 1334 // empty sites or not. For now, group anything from which we can't parse |
1375 // a site into the same process, when using --process-per-site. | 1335 // a site into the same process, when using --process-per-site. |
1376 std::string site = SiteInstanceImpl::GetSiteForURL(browser_context, url) | 1336 std::string site = SiteInstanceImpl::GetSiteForURL(browser_context, url) |
1377 .possibly_invalid_spec(); | 1337 .possibly_invalid_spec(); |
1378 map->RegisterProcess(site, process); | 1338 map->RegisterProcess(site, process); |
1379 } | 1339 } |
1380 | 1340 |
1381 void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, | 1341 void RenderProcessHostImpl::ProcessDied() { |
1382 base::TerminationStatus status, | |
1383 int exit_code, | |
1384 bool was_alive) { | |
1385 // Our child process has died. If we didn't expect it, it's a crash. | 1342 // Our child process has died. If we didn't expect it, it's a crash. |
1386 // In any case, we need to let everyone know it's gone. | 1343 // In any case, we need to let everyone know it's gone. |
1387 // The OnChannelError notification can fire multiple times due to nested sync | 1344 // The OnChannelError notification can fire multiple times due to nested sync |
1388 // calls to a renderer. If we don't have a valid channel here it means we | 1345 // calls to a renderer. If we don't have a valid channel here it means we |
1389 // already handled the error. | 1346 // already handled the error. |
1390 | 1347 |
1391 RendererClosedDetails details(handle, status, exit_code, was_alive); | 1348 // child_process_launcher_ can be NULL in single process mode or if fast |
| 1349 // termination happened. |
| 1350 int exit_code = 0; |
| 1351 base::TerminationStatus status = |
| 1352 child_process_launcher_.get() ? |
| 1353 child_process_launcher_->GetChildTerminationStatus(&exit_code) : |
| 1354 base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 1355 |
| 1356 RendererClosedDetails details(GetHandle(), status, exit_code); |
1392 NotificationService::current()->Notify( | 1357 NotificationService::current()->Notify( |
1393 NOTIFICATION_RENDERER_PROCESS_CLOSED, | 1358 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
1394 Source<RenderProcessHost>(this), | 1359 Source<RenderProcessHost>(this), |
1395 Details<RendererClosedDetails>(&details)); | 1360 Details<RendererClosedDetails>(&details)); |
1396 | 1361 |
1397 child_process_launcher_.reset(); | 1362 child_process_launcher_.reset(); |
1398 channel_.reset(); | 1363 channel_.reset(); |
1399 gpu_message_filter_ = NULL; | 1364 gpu_message_filter_ = NULL; |
1400 | 1365 |
1401 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_); | 1366 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 int32 route_id, | 1500 int32 route_id, |
1536 int32 gpu_process_host_id) { | 1501 int32 gpu_process_host_id) { |
1537 TRACE_EVENT0("renderer_host", | 1502 TRACE_EVENT0("renderer_host", |
1538 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1503 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
1539 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1504 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
1540 gpu_process_host_id, | 1505 gpu_process_host_id, |
1541 0); | 1506 0); |
1542 } | 1507 } |
1543 | 1508 |
1544 } // namespace content | 1509 } // namespace content |
OLD | NEW |