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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 sudden_termination_allowed_(true), | 391 sudden_termination_allowed_(true), |
392 ignore_input_events_(false), | 392 ignore_input_events_(false), |
393 supports_browser_plugin_(supports_browser_plugin), | 393 supports_browser_plugin_(supports_browser_plugin), |
394 is_guest_(is_guest), | 394 is_guest_(is_guest), |
395 gpu_observer_registered_(false), | 395 gpu_observer_registered_(false), |
396 delayed_cleanup_needed_(false), | 396 delayed_cleanup_needed_(false), |
397 within_process_died_observer_(false), | 397 within_process_died_observer_(false), |
398 power_monitor_broadcaster_(this), | 398 power_monitor_broadcaster_(this), |
399 geolocation_dispatcher_host_(NULL), | 399 geolocation_dispatcher_host_(NULL), |
400 weak_factory_(this), | 400 weak_factory_(this), |
401 screen_orientation_dispatcher_host_(NULL) { | 401 screen_orientation_dispatcher_host_(NULL), |
402 shared_worker_has_clients_(false) { | |
402 widget_helper_ = new RenderWidgetHelper(); | 403 widget_helper_ = new RenderWidgetHelper(); |
403 | 404 |
404 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 405 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
405 | 406 |
406 CHECK(!g_exited_main_message_loop); | 407 CHECK(!g_exited_main_message_loop); |
407 RegisterHost(GetID(), this); | 408 RegisterHost(GetID(), this); |
408 g_all_hosts.Get().set_check_on_null_data(true); | 409 g_all_hosts.Get().set_check_on_null_data(true); |
409 // Initialize |child_process_activity_time_| to a reasonable value. | 410 // Initialize |child_process_activity_time_| to a reasonable value. |
410 mark_child_process_activity_time(); | 411 mark_child_process_activity_time(); |
411 | 412 |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 return false; // Render process hasn't started or is probably crashed. | 1221 return false; // Render process hasn't started or is probably crashed. |
1221 | 1222 |
1222 // Test if there's an unload listener. | 1223 // Test if there's an unload listener. |
1223 // NOTE: It's possible that an onunload listener may be installed | 1224 // NOTE: It's possible that an onunload listener may be installed |
1224 // while we're shutting down, so there's a small race here. Given that | 1225 // while we're shutting down, so there's a small race here. Given that |
1225 // the window is small, it's unlikely that the web page has much | 1226 // the window is small, it's unlikely that the web page has much |
1226 // state that will be lost by not calling its unload handlers properly. | 1227 // state that will be lost by not calling its unload handlers properly. |
1227 if (!SuddenTerminationAllowed()) | 1228 if (!SuddenTerminationAllowed()) |
1228 return false; | 1229 return false; |
1229 | 1230 |
1231 if (shared_worker_has_clients_) | |
1232 return false; | |
1233 | |
1230 // Set this before ProcessDied() so observers can tell if the render process | 1234 // Set this before ProcessDied() so observers can tell if the render process |
1231 // died due to fast shutdown versus another cause. | 1235 // died due to fast shutdown versus another cause. |
1232 fast_shutdown_started_ = true; | 1236 fast_shutdown_started_ = true; |
1233 | 1237 |
1234 ProcessDied(false /* already_dead */); | 1238 ProcessDied(false /* already_dead */); |
1235 return true; | 1239 return true; |
1236 } | 1240 } |
1237 | 1241 |
1238 void RenderProcessHostImpl::DumpHandles() { | 1242 void RenderProcessHostImpl::DumpHandles() { |
1239 #if defined(OS_WIN) | 1243 #if defined(OS_WIN) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1445 // delay the destruction until all of the observer callbacks have been made, | 1449 // delay the destruction until all of the observer callbacks have been made, |
1446 // and guarantee that the RenderProcessHostDestroyed observer callback is | 1450 // and guarantee that the RenderProcessHostDestroyed observer callback is |
1447 // always the last callback fired. | 1451 // always the last callback fired. |
1448 if (within_process_died_observer_) { | 1452 if (within_process_died_observer_) { |
1449 delayed_cleanup_needed_ = true; | 1453 delayed_cleanup_needed_ = true; |
1450 return; | 1454 return; |
1451 } | 1455 } |
1452 delayed_cleanup_needed_ = false; | 1456 delayed_cleanup_needed_ = false; |
1453 | 1457 |
1454 // When there are no other owners of this object, we can delete ourselves. | 1458 // When there are no other owners of this object, we can delete ourselves. |
1455 if (listeners_.IsEmpty()) { | 1459 if (listeners_.IsEmpty() && !shared_worker_has_clients_) { |
1456 // We cannot clean up twice; if this fails, there is an issue with our | 1460 // We cannot clean up twice; if this fails, there is an issue with our |
1457 // control flow. | 1461 // control flow. |
1458 DCHECK(!deleting_soon_); | 1462 DCHECK(!deleting_soon_); |
1459 | 1463 |
1460 DCHECK_EQ(0, pending_views_); | 1464 DCHECK_EQ(0, pending_views_); |
1461 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 1465 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
1462 observers_, | 1466 observers_, |
1463 RenderProcessHostDestroyed(this)); | 1467 RenderProcessHostDestroyed(this)); |
1464 NotificationService::current()->Notify( | 1468 NotificationService::current()->Notify( |
1465 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 1469 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2076 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) | 2080 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) |
2077 return; | 2081 return; |
2078 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); | 2082 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); |
2079 } | 2083 } |
2080 | 2084 |
2081 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2085 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
2082 Send(new MediaStreamMsg_DisableAecDump()); | 2086 Send(new MediaStreamMsg_DisableAecDump()); |
2083 } | 2087 } |
2084 #endif | 2088 #endif |
2085 | 2089 |
2090 void RenderProcessHostImpl::NotifySharedWorkerHasClients( | |
2091 bool shared_worker_has_clients) { | |
jam
2014/03/04 17:14:41
nit: indentation
| |
2092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
2093 shared_worker_has_clients_ = shared_worker_has_clients; | |
2094 if (!shared_worker_has_clients_) | |
2095 Cleanup(); | |
2096 } | |
2097 | |
2086 } // namespace content | 2098 } // namespace content |
OLD | NEW |