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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 is_self_deleted_(false), | 552 is_self_deleted_(false), |
553 #endif | 553 #endif |
554 pending_views_(0), | 554 pending_views_(0), |
555 mojo_application_host_(new MojoApplicationHost), | 555 mojo_application_host_(new MojoApplicationHost), |
556 visible_widgets_(0), | 556 visible_widgets_(0), |
557 is_process_backgrounded_(false), | 557 is_process_backgrounded_(false), |
558 is_initialized_(false), | 558 is_initialized_(false), |
559 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 559 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
560 browser_context_(browser_context), | 560 browser_context_(browser_context), |
561 storage_partition_impl_(storage_partition_impl), | 561 storage_partition_impl_(storage_partition_impl), |
562 sudden_termination_allowed_(true), | 562 sudden_termination_blocking_refcount_(0), |
563 ignore_input_events_(false), | 563 ignore_input_events_(false), |
564 is_for_guests_only_(is_for_guests_only), | 564 is_for_guests_only_(is_for_guests_only), |
565 gpu_observer_registered_(false), | 565 gpu_observer_registered_(false), |
566 delayed_cleanup_needed_(false), | 566 delayed_cleanup_needed_(false), |
567 within_process_died_observer_(false), | 567 within_process_died_observer_(false), |
568 power_monitor_broadcaster_(this), | 568 power_monitor_broadcaster_(this), |
569 worker_ref_count_(0), | 569 worker_ref_count_(0), |
570 max_worker_count_(0), | 570 max_worker_count_(0), |
571 permission_service_context_(new PermissionServiceContext(this)), | 571 permission_service_context_(new PermissionServiceContext(this)), |
572 pending_valuebuffer_state_(new gpu::ValueStateMap()), | 572 pending_valuebuffer_state_(new gpu::ValueStateMap()), |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 #endif | 949 #endif |
950 #if defined(ENABLE_PLUGINS) | 950 #if defined(ENABLE_PLUGINS) |
951 AddFilter(new PepperRendererConnection(GetID())); | 951 AddFilter(new PepperRendererConnection(GetID())); |
952 #endif | 952 #endif |
953 AddFilter(new SpeechRecognitionDispatcherHost( | 953 AddFilter(new SpeechRecognitionDispatcherHost( |
954 GetID(), storage_partition_impl_->GetURLRequestContext())); | 954 GetID(), storage_partition_impl_->GetURLRequestContext())); |
955 AddFilter(new FileAPIMessageFilter( | 955 AddFilter(new FileAPIMessageFilter( |
956 GetID(), storage_partition_impl_->GetURLRequestContext(), | 956 GetID(), storage_partition_impl_->GetURLRequestContext(), |
957 storage_partition_impl_->GetFileSystemContext(), | 957 storage_partition_impl_->GetFileSystemContext(), |
958 blob_storage_context.get(), StreamContext::GetFor(browser_context))); | 958 blob_storage_context.get(), StreamContext::GetFor(browser_context))); |
959 AddFilter(new BlobDispatcherHost(blob_storage_context.get())); | 959 AddFilter(new BlobDispatcherHost( |
| 960 blob_storage_context.get(), |
| 961 base::Bind(&RenderProcessHostImpl::SetSuddenTerminationAllowed, |
| 962 base::Unretained(this)))); |
960 AddFilter(new FileUtilitiesMessageFilter(GetID())); | 963 AddFilter(new FileUtilitiesMessageFilter(GetID())); |
961 AddFilter(new MimeRegistryMessageFilter()); | 964 AddFilter(new MimeRegistryMessageFilter()); |
962 AddFilter( | 965 AddFilter( |
963 new DatabaseMessageFilter(storage_partition_impl_->GetDatabaseTracker())); | 966 new DatabaseMessageFilter(storage_partition_impl_->GetDatabaseTracker())); |
964 #if defined(OS_MACOSX) | 967 #if defined(OS_MACOSX) |
965 AddFilter(new TextInputClientMessageFilter(GetID())); | 968 AddFilter(new TextInputClientMessageFilter(GetID())); |
966 #elif defined(OS_WIN) | 969 #elif defined(OS_WIN) |
967 AddFilter(new DWriteFontProxyMessageFilter()); | 970 AddFilter(new DWriteFontProxyMessageFilter()); |
968 | 971 |
969 // The FontCacheDispatcher is required only when we're using GDI rendering. | 972 // The FontCacheDispatcher is required only when we're using GDI rendering. |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (run_renderer_in_process()) | 1676 if (run_renderer_in_process()) |
1674 return false; // Single process mode never shuts down the renderer. | 1677 return false; // Single process mode never shuts down the renderer. |
1675 | 1678 |
1676 if (!GetContentClient()->browser()->IsFastShutdownPossible()) | 1679 if (!GetContentClient()->browser()->IsFastShutdownPossible()) |
1677 return false; | 1680 return false; |
1678 | 1681 |
1679 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting() || | 1682 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting() || |
1680 !GetHandle()) | 1683 !GetHandle()) |
1681 return false; // Render process hasn't started or is probably crashed. | 1684 return false; // Render process hasn't started or is probably crashed. |
1682 | 1685 |
1683 // Test if there's an unload listener. | 1686 // Test if there's an unload listener or blobs waiting to be transferred. |
1684 // NOTE: It's possible that an onunload listener may be installed | 1687 // NOTE: It's possible that an onunload listener may be installed |
1685 // while we're shutting down, so there's a small race here. Given that | 1688 // while we're shutting down, so there's a small race here. Given that |
1686 // the window is small, it's unlikely that the web page has much | 1689 // the window is small, it's unlikely that the web page has much |
1687 // state that will be lost by not calling its unload handlers properly. | 1690 // state that will be lost by not calling its unload handlers properly. |
1688 if (!SuddenTerminationAllowed()) | 1691 if (!SuddenTerminationAllowed()) |
1689 return false; | 1692 return false; |
1690 | 1693 |
1691 if (worker_ref_count_ != 0) { | 1694 if (worker_ref_count_ != 0) { |
1692 if (survive_for_worker_start_time_.is_null()) | 1695 if (survive_for_worker_start_time_.is_null()) |
1693 survive_for_worker_start_time_ = base::TimeTicks::Now(); | 1696 survive_for_worker_start_time_ = base::TimeTicks::Now(); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 void RenderProcessHostImpl::AddPendingView() { | 1968 void RenderProcessHostImpl::AddPendingView() { |
1966 pending_views_++; | 1969 pending_views_++; |
1967 } | 1970 } |
1968 | 1971 |
1969 void RenderProcessHostImpl::RemovePendingView() { | 1972 void RenderProcessHostImpl::RemovePendingView() { |
1970 DCHECK(pending_views_); | 1973 DCHECK(pending_views_); |
1971 pending_views_--; | 1974 pending_views_--; |
1972 } | 1975 } |
1973 | 1976 |
1974 void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { | 1977 void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { |
1975 sudden_termination_allowed_ = enabled; | 1978 sudden_termination_blocking_refcount_ += enabled ? -1 : 1; |
1976 } | 1979 } |
1977 | 1980 |
1978 bool RenderProcessHostImpl::SuddenTerminationAllowed() const { | 1981 bool RenderProcessHostImpl::SuddenTerminationAllowed() const { |
1979 return sudden_termination_allowed_; | 1982 return sudden_termination_blocking_refcount_ <= 0; |
1980 } | 1983 } |
1981 | 1984 |
1982 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { | 1985 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { |
1983 return base::TimeTicks::Now() - child_process_activity_time_; | 1986 return base::TimeTicks::Now() - child_process_activity_time_; |
1984 } | 1987 } |
1985 | 1988 |
1986 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { | 1989 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { |
1987 FilterURL(this, empty_allowed, url); | 1990 FilterURL(this, empty_allowed, url); |
1988 } | 1991 } |
1989 | 1992 |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 | 2795 |
2793 // Skip widgets in other processes. | 2796 // Skip widgets in other processes. |
2794 if (rvh->GetProcess()->GetID() != GetID()) | 2797 if (rvh->GetProcess()->GetID() != GetID()) |
2795 continue; | 2798 continue; |
2796 | 2799 |
2797 rvh->OnWebkitPreferencesChanged(); | 2800 rvh->OnWebkitPreferencesChanged(); |
2798 } | 2801 } |
2799 } | 2802 } |
2800 | 2803 |
2801 } // namespace content | 2804 } // namespace content |
OLD | NEW |