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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 return false; // Render process hasn't started or is probably crashed. | 1278 return false; // Render process hasn't started or is probably crashed. |
1279 | 1279 |
1280 // Test if there's an unload listener. | 1280 // Test if there's an unload listener. |
1281 // NOTE: It's possible that an onunload listener may be installed | 1281 // NOTE: It's possible that an onunload listener may be installed |
1282 // while we're shutting down, so there's a small race here. Given that | 1282 // while we're shutting down, so there's a small race here. Given that |
1283 // the window is small, it's unlikely that the web page has much | 1283 // the window is small, it's unlikely that the web page has much |
1284 // state that will be lost by not calling its unload handlers properly. | 1284 // state that will be lost by not calling its unload handlers properly. |
1285 if (!SuddenTerminationAllowed()) | 1285 if (!SuddenTerminationAllowed()) |
1286 return false; | 1286 return false; |
1287 | 1287 |
1288 if (worker_ref_count_ != 0) | 1288 if (worker_ref_count_ != 0) { |
| 1289 if (survive_for_worker_start_time_.is_null()) |
| 1290 survive_for_worker_start_time_ = base::TimeTicks::Now(); |
1289 return false; | 1291 return false; |
| 1292 } |
1290 | 1293 |
1291 // Set this before ProcessDied() so observers can tell if the render process | 1294 // Set this before ProcessDied() so observers can tell if the render process |
1292 // died due to fast shutdown versus another cause. | 1295 // died due to fast shutdown versus another cause. |
1293 fast_shutdown_started_ = true; | 1296 fast_shutdown_started_ = true; |
1294 | 1297 |
1295 ProcessDied(false /* already_dead */); | 1298 ProcessDied(false /* already_dead */); |
1296 return true; | 1299 return true; |
1297 } | 1300 } |
1298 | 1301 |
1299 void RenderProcessHostImpl::DumpHandles() { | 1302 void RenderProcessHostImpl::DumpHandles() { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, | 1507 // action that caused us to die (e.g. http://crbug.com/339504). Therefore, |
1505 // delay the destruction until all of the observer callbacks have been made, | 1508 // delay the destruction until all of the observer callbacks have been made, |
1506 // and guarantee that the RenderProcessHostDestroyed observer callback is | 1509 // and guarantee that the RenderProcessHostDestroyed observer callback is |
1507 // always the last callback fired. | 1510 // always the last callback fired. |
1508 if (within_process_died_observer_) { | 1511 if (within_process_died_observer_) { |
1509 delayed_cleanup_needed_ = true; | 1512 delayed_cleanup_needed_ = true; |
1510 return; | 1513 return; |
1511 } | 1514 } |
1512 delayed_cleanup_needed_ = false; | 1515 delayed_cleanup_needed_ = false; |
1513 | 1516 |
| 1517 // Records the time when the process starts surviving for workers for UMA. |
| 1518 if (listeners_.IsEmpty() && worker_ref_count_ > 0 && |
| 1519 survive_for_worker_start_time_.is_null()) { |
| 1520 survive_for_worker_start_time_ = base::TimeTicks::Now(); |
| 1521 } |
| 1522 |
1514 // When there are no other owners of this object, we can delete ourselves. | 1523 // When there are no other owners of this object, we can delete ourselves. |
1515 if (listeners_.IsEmpty() && worker_ref_count_ == 0) { | 1524 if (listeners_.IsEmpty() && worker_ref_count_ == 0) { |
| 1525 if (!survive_for_worker_start_time_.is_null()) { |
| 1526 UMA_HISTOGRAM_LONG_TIMES( |
| 1527 "SharedWorker.RendererSurviveForWorkerTime", |
| 1528 base::TimeTicks::Now() - survive_for_worker_start_time_); |
| 1529 } |
1516 // We cannot clean up twice; if this fails, there is an issue with our | 1530 // We cannot clean up twice; if this fails, there is an issue with our |
1517 // control flow. | 1531 // control flow. |
1518 DCHECK(!deleting_soon_); | 1532 DCHECK(!deleting_soon_); |
1519 | 1533 |
1520 DCHECK_EQ(0, pending_views_); | 1534 DCHECK_EQ(0, pending_views_); |
1521 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 1535 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
1522 observers_, | 1536 observers_, |
1523 RenderProcessHostDestroyed(this)); | 1537 RenderProcessHostDestroyed(this)); |
1524 NotificationService::current()->Notify( | 1538 NotificationService::current()->Notify( |
1525 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 1539 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 child_process_launcher_->GetHandle(); | 2186 child_process_launcher_->GetHandle(); |
2173 base::PlatformFile client_file = | 2187 base::PlatformFile client_file = |
2174 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle()); | 2188 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle()); |
2175 Send(new MojoMsg_ChannelCreated( | 2189 Send(new MojoMsg_ChannelCreated( |
2176 IPC::GetFileHandleForProcess(client_file, process_handle, true))); | 2190 IPC::GetFileHandleForProcess(client_file, process_handle, true))); |
2177 } | 2191 } |
2178 } | 2192 } |
2179 #endif | 2193 #endif |
2180 | 2194 |
2181 } // namespace content | 2195 } // namespace content |
OLD | NEW |