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 route_provider_binding_(this), | 679 route_provider_binding_(this), |
679 associated_interface_provider_bindings_( | 680 associated_interface_provider_bindings_( |
680 mojo::BindingSetDispatchMode::WITH_CONTEXT), | 681 mojo::BindingSetDispatchMode::WITH_CONTEXT), |
681 visible_widgets_(0), | 682 visible_widgets_(0), |
682 is_process_backgrounded_(false), | 683 is_process_backgrounded_(false), |
683 is_initialized_(false), | 684 is_initialized_(false), |
684 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 685 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
685 browser_context_(browser_context), | 686 browser_context_(browser_context), |
686 storage_partition_impl_(storage_partition_impl), | 687 storage_partition_impl_(storage_partition_impl), |
687 sudden_termination_allowed_(true), | 688 sudden_termination_allowed_(true), |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 return manager->GetCdm(render_frame_id, cdm_id); | 1351 return manager->GetCdm(render_frame_id, cdm_id); |
1351 } | 1352 } |
1352 #endif | 1353 #endif |
1353 | 1354 |
1354 bool RenderProcessHostImpl::IsProcessBackgrounded() const { | 1355 bool RenderProcessHostImpl::IsProcessBackgrounded() const { |
1355 return is_process_backgrounded_; | 1356 return is_process_backgrounded_; |
1356 } | 1357 } |
1357 | 1358 |
1358 void RenderProcessHostImpl::IncrementServiceWorkerRefCount() { | 1359 void RenderProcessHostImpl::IncrementServiceWorkerRefCount() { |
1359 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1360 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1361 DCHECK(!is_worker_ref_count_disabled_); |
1360 ++service_worker_ref_count_; | 1362 ++service_worker_ref_count_; |
1361 if (worker_ref_count() > max_worker_count_) | 1363 if (worker_ref_count() > max_worker_count_) |
1362 max_worker_count_ = worker_ref_count(); | 1364 max_worker_count_ = worker_ref_count(); |
1363 } | 1365 } |
1364 | 1366 |
1365 void RenderProcessHostImpl::DecrementServiceWorkerRefCount() { | 1367 void RenderProcessHostImpl::DecrementServiceWorkerRefCount() { |
1366 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1368 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1367 DCHECK_GT(worker_ref_count(), 0UL); | 1369 DCHECK(!is_worker_ref_count_disabled_); |
| 1370 DCHECK_GT(worker_ref_count(), 0U); |
1368 --service_worker_ref_count_; | 1371 --service_worker_ref_count_; |
1369 if (worker_ref_count() == 0) | 1372 if (worker_ref_count() == 0) |
1370 Cleanup(); | 1373 Cleanup(); |
1371 } | 1374 } |
1372 | 1375 |
1373 void RenderProcessHostImpl::IncrementSharedWorkerRefCount() { | 1376 void RenderProcessHostImpl::IncrementSharedWorkerRefCount() { |
1374 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1377 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1378 DCHECK(!is_worker_ref_count_disabled_); |
1375 ++shared_worker_ref_count_; | 1379 ++shared_worker_ref_count_; |
1376 if (worker_ref_count() > max_worker_count_) | 1380 if (worker_ref_count() > max_worker_count_) |
1377 max_worker_count_ = worker_ref_count(); | 1381 max_worker_count_ = worker_ref_count(); |
1378 } | 1382 } |
1379 | 1383 |
1380 void RenderProcessHostImpl::DecrementSharedWorkerRefCount() { | 1384 void RenderProcessHostImpl::DecrementSharedWorkerRefCount() { |
1381 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1385 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1382 DCHECK_GT(worker_ref_count(), 0UL); | 1386 DCHECK(!is_worker_ref_count_disabled_); |
| 1387 DCHECK_GT(worker_ref_count(), 0U); |
1383 --shared_worker_ref_count_; | 1388 --shared_worker_ref_count_; |
1384 if (worker_ref_count() == 0) | 1389 if (worker_ref_count() == 0) |
1385 Cleanup(); | 1390 Cleanup(); |
1386 } | 1391 } |
1387 | 1392 |
| 1393 void RenderProcessHostImpl::ForceReleaseWorkerRefCounts() { |
| 1394 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1395 DCHECK(!is_worker_ref_count_disabled_); |
| 1396 is_worker_ref_count_disabled_ = true; |
| 1397 if (!worker_ref_count()) |
| 1398 return; |
| 1399 service_worker_ref_count_ = 0; |
| 1400 shared_worker_ref_count_ = 0; |
| 1401 Cleanup(); |
| 1402 } |
| 1403 |
| 1404 bool RenderProcessHostImpl::IsWorkerRefCountDisabled() { |
| 1405 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1406 return is_worker_ref_count_disabled_; |
| 1407 } |
| 1408 |
1388 void RenderProcessHostImpl::PurgeAndSuspend() { | 1409 void RenderProcessHostImpl::PurgeAndSuspend() { |
1389 Send(new ChildProcessMsg_PurgeAndSuspend()); | 1410 Send(new ChildProcessMsg_PurgeAndSuspend()); |
1390 } | 1411 } |
1391 | 1412 |
1392 mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() { | 1413 mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() { |
1393 if (!remote_route_provider_) { | 1414 if (!remote_route_provider_) { |
1394 DCHECK(channel_); | 1415 DCHECK(channel_); |
1395 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); | 1416 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); |
1396 } | 1417 } |
1397 return remote_route_provider_.get(); | 1418 return remote_route_provider_.get(); |
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3015 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2995 | 3016 |
2996 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 3017 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2997 // enough information here so that we can determine what the bad message was. | 3018 // enough information here so that we can determine what the bad message was. |
2998 base::debug::Alias(&error); | 3019 base::debug::Alias(&error); |
2999 bad_message::ReceivedBadMessage(process.get(), | 3020 bad_message::ReceivedBadMessage(process.get(), |
3000 bad_message::RPH_MOJO_PROCESS_ERROR); | 3021 bad_message::RPH_MOJO_PROCESS_ERROR); |
3001 } | 3022 } |
3002 | 3023 |
3003 } // namespace content | 3024 } // namespace content |
OLD | NEW |