OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 bool is_for_guests_only) | 668 bool is_for_guests_only) |
669 : fast_shutdown_started_(false), | 669 : fast_shutdown_started_(false), |
670 deleting_soon_(false), | 670 deleting_soon_(false), |
671 #ifndef NDEBUG | 671 #ifndef NDEBUG |
672 is_self_deleted_(false), | 672 is_self_deleted_(false), |
673 #endif | 673 #endif |
674 pending_views_(0), | 674 pending_views_(0), |
675 child_token_(mojo::edk::GenerateRandomToken()), | 675 child_token_(mojo::edk::GenerateRandomToken()), |
676 service_worker_ref_count_(0), | 676 service_worker_ref_count_(0), |
677 shared_worker_ref_count_(0), | 677 shared_worker_ref_count_(0), |
678 is_worker_ref_count_disabled_(false), | |
678 visible_widgets_(0), | 679 visible_widgets_(0), |
679 is_process_backgrounded_(false), | 680 is_process_backgrounded_(false), |
680 is_initialized_(false), | 681 is_initialized_(false), |
681 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 682 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
682 browser_context_(browser_context), | 683 browser_context_(browser_context), |
683 storage_partition_impl_(storage_partition_impl), | 684 storage_partition_impl_(storage_partition_impl), |
684 sudden_termination_allowed_(true), | 685 sudden_termination_allowed_(true), |
685 ignore_input_events_(false), | 686 ignore_input_events_(false), |
686 is_for_guests_only_(is_for_guests_only), | 687 is_for_guests_only_(is_for_guests_only), |
687 gpu_observer_registered_(false), | 688 gpu_observer_registered_(false), |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1334 return manager->GetCdm(render_frame_id, cdm_id); | 1335 return manager->GetCdm(render_frame_id, cdm_id); |
1335 } | 1336 } |
1336 #endif | 1337 #endif |
1337 | 1338 |
1338 bool RenderProcessHostImpl::IsProcessBackgrounded() const { | 1339 bool RenderProcessHostImpl::IsProcessBackgrounded() const { |
1339 return is_process_backgrounded_; | 1340 return is_process_backgrounded_; |
1340 } | 1341 } |
1341 | 1342 |
1342 void RenderProcessHostImpl::IncrementServiceWorkerRefCount() { | 1343 void RenderProcessHostImpl::IncrementServiceWorkerRefCount() { |
1343 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1344 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1345 DCHECK(!is_worker_ref_count_disabled_); | |
1344 ++service_worker_ref_count_; | 1346 ++service_worker_ref_count_; |
1345 if (worker_ref_count() > max_worker_count_) | 1347 if (worker_ref_count() > max_worker_count_) |
1346 max_worker_count_ = worker_ref_count(); | 1348 max_worker_count_ = worker_ref_count(); |
1347 } | 1349 } |
1348 | 1350 |
1349 void RenderProcessHostImpl::DecrementServiceWorkerRefCount() { | 1351 void RenderProcessHostImpl::DecrementServiceWorkerRefCount() { |
1350 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1352 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1351 DCHECK_GT(worker_ref_count(), 0UL); | 1353 DCHECK(!is_worker_ref_count_disabled_); |
1354 DCHECK_GT(worker_ref_count(), 0U); | |
1352 --service_worker_ref_count_; | 1355 --service_worker_ref_count_; |
1353 if (worker_ref_count() == 0) | 1356 if (worker_ref_count() == 0) |
1354 Cleanup(); | 1357 Cleanup(); |
1355 } | 1358 } |
1356 | 1359 |
1357 void RenderProcessHostImpl::IncrementSharedWorkerRefCount() { | 1360 void RenderProcessHostImpl::IncrementSharedWorkerRefCount() { |
1358 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1361 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1362 DCHECK(!is_worker_ref_count_disabled_); | |
1359 ++shared_worker_ref_count_; | 1363 ++shared_worker_ref_count_; |
1360 if (worker_ref_count() > max_worker_count_) | 1364 if (worker_ref_count() > max_worker_count_) |
1361 max_worker_count_ = worker_ref_count(); | 1365 max_worker_count_ = worker_ref_count(); |
1362 } | 1366 } |
1363 | 1367 |
1364 void RenderProcessHostImpl::DecrementSharedWorkerRefCount() { | 1368 void RenderProcessHostImpl::DecrementSharedWorkerRefCount() { |
1365 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1369 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1366 DCHECK_GT(worker_ref_count(), 0UL); | 1370 DCHECK(!is_worker_ref_count_disabled_); |
1371 DCHECK_GT(worker_ref_count(), 0U); | |
1367 --shared_worker_ref_count_; | 1372 --shared_worker_ref_count_; |
1368 if (worker_ref_count() == 0) | 1373 if (worker_ref_count() == 0) |
1369 Cleanup(); | 1374 Cleanup(); |
1370 } | 1375 } |
1371 | 1376 |
1377 void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() { | |
1378 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
1379 is_worker_ref_count_disabled_ = true; | |
jam
2016/09/14 17:10:49
DCHECK(!is_worker_ref_count_disabled_); before thi
falken
2016/09/21 08:59:43
Done.
| |
1380 if (!worker_ref_count()) | |
1381 return; | |
1382 service_worker_ref_count_ = 0; | |
1383 shared_worker_ref_count_ = 0; | |
1384 Cleanup(); | |
1385 } | |
1386 | |
1387 bool RenderProcessHostImpl::IsWorkerRefCountDisabled() { | |
1388 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
1389 return is_worker_ref_count_disabled_; | |
1390 } | |
1391 | |
1372 void RenderProcessHostImpl::PurgeAndSuspend() { | 1392 void RenderProcessHostImpl::PurgeAndSuspend() { |
1373 Send(new ChildProcessMsg_PurgeAndSuspend()); | 1393 Send(new ChildProcessMsg_PurgeAndSuspend()); |
1374 } | 1394 } |
1375 | 1395 |
1376 void RenderProcessHostImpl::AddRoute(int32_t routing_id, | 1396 void RenderProcessHostImpl::AddRoute(int32_t routing_id, |
1377 IPC::Listener* listener) { | 1397 IPC::Listener* listener) { |
1378 CHECK(!listeners_.Lookup(routing_id)) << "Found Routing ID Conflict: " | 1398 CHECK(!listeners_.Lookup(routing_id)) << "Found Routing ID Conflict: " |
1379 << routing_id; | 1399 << routing_id; |
1380 listeners_.AddWithID(listener, routing_id); | 1400 listeners_.AddWithID(listener, routing_id); |
1381 } | 1401 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1864 return false; // Render process hasn't started or is probably crashed. | 1884 return false; // Render process hasn't started or is probably crashed. |
1865 | 1885 |
1866 // Test if there's an unload listener. | 1886 // Test if there's an unload listener. |
1867 // NOTE: It's possible that an onunload listener may be installed | 1887 // NOTE: It's possible that an onunload listener may be installed |
1868 // while we're shutting down, so there's a small race here. Given that | 1888 // while we're shutting down, so there's a small race here. Given that |
1869 // the window is small, it's unlikely that the web page has much | 1889 // the window is small, it's unlikely that the web page has much |
1870 // state that will be lost by not calling its unload handlers properly. | 1890 // state that will be lost by not calling its unload handlers properly. |
1871 if (!SuddenTerminationAllowed()) | 1891 if (!SuddenTerminationAllowed()) |
1872 return false; | 1892 return false; |
1873 | 1893 |
1874 if (worker_ref_count() != 0) { | 1894 if (worker_ref_count() != 0) { |
alokp
2016/09/16 04:47:53
should we still prevent fast shutdown for worker_r
falken
2016/09/21 08:59:43
I think we still need to because fast shutdown won
| |
1875 if (survive_for_worker_start_time_.is_null()) | 1895 if (survive_for_worker_start_time_.is_null()) |
1876 survive_for_worker_start_time_ = base::TimeTicks::Now(); | 1896 survive_for_worker_start_time_ = base::TimeTicks::Now(); |
1877 return false; | 1897 return false; |
1878 } | 1898 } |
1879 | 1899 |
1880 // Set this before ProcessDied() so observers can tell if the render process | 1900 // Set this before ProcessDied() so observers can tell if the render process |
1881 // died due to fast shutdown versus another cause. | 1901 // died due to fast shutdown versus another cause. |
1882 fast_shutdown_started_ = true; | 1902 fast_shutdown_started_ = true; |
1883 | 1903 |
1884 ProcessDied(false /* already_dead */, nullptr); | 1904 ProcessDied(false /* already_dead */, nullptr); |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2966 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2986 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2967 | 2987 |
2968 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2988 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2969 // enough information here so that we can determine what the bad message was. | 2989 // enough information here so that we can determine what the bad message was. |
2970 base::debug::Alias(&error); | 2990 base::debug::Alias(&error); |
2971 bad_message::ReceivedBadMessage(process.get(), | 2991 bad_message::ReceivedBadMessage(process.get(), |
2972 bad_message::RPH_MOJO_PROCESS_ERROR); | 2992 bad_message::RPH_MOJO_PROCESS_ERROR); |
2973 } | 2993 } |
2974 | 2994 |
2975 } // namespace content | 2995 } // namespace content |
OLD | NEW |