Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 2724203004: Test run for https://codereview.chromium.org/2725993002/ with the timer intentionally broken. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/browser/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 20 matching lines...) Expand all
31 #include "components/variations/variations_associated_data.h" 31 #include "components/variations/variations_associated_data.h"
32 #include "content/browser/bad_message.h" 32 #include "content/browser/bad_message.h"
33 #include "content/browser/child_process_security_policy_impl.h" 33 #include "content/browser/child_process_security_policy_impl.h"
34 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 34 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
35 #include "content/browser/frame_host/frame_tree.h" 35 #include "content/browser/frame_host/frame_tree.h"
36 #include "content/browser/gpu/compositor_util.h" 36 #include "content/browser/gpu/compositor_util.h"
37 #include "content/browser/gpu/gpu_data_manager_impl.h" 37 #include "content/browser/gpu/gpu_data_manager_impl.h"
38 #include "content/browser/gpu/gpu_process_host.h" 38 #include "content/browser/gpu/gpu_process_host.h"
39 #include "content/browser/host_zoom_map_impl.h" 39 #include "content/browser/host_zoom_map_impl.h"
40 #include "content/browser/loader/resource_dispatcher_host_impl.h" 40 #include "content/browser/loader/resource_dispatcher_host_impl.h"
41 #include "content/browser/renderer_host/input/timeout_monitor.h"
41 #include "content/browser/renderer_host/render_process_host_impl.h" 42 #include "content/browser/renderer_host/render_process_host_impl.h"
42 #include "content/browser/renderer_host/render_view_host_delegate.h" 43 #include "content/browser/renderer_host/render_view_host_delegate.h"
43 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 44 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
44 #include "content/browser/renderer_host/render_widget_host_delegate.h" 45 #include "content/browser/renderer_host/render_widget_host_delegate.h"
45 #include "content/browser/renderer_host/render_widget_host_view_base.h" 46 #include "content/browser/renderer_host/render_widget_host_view_base.h"
46 #include "content/common/browser_plugin/browser_plugin_messages.h" 47 #include "content/common/browser_plugin/browser_plugin_messages.h"
47 #include "content/common/content_switches_internal.h" 48 #include "content/common/content_switches_internal.h"
48 #include "content/common/frame_messages.h" 49 #include "content/common/frame_messages.h"
49 #include "content/common/input_messages.h" 50 #include "content/common/input_messages.h"
50 #include "content/common/inter_process_time_ticks_converter.h" 51 #include "content/common/inter_process_time_ticks_converter.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // make their way to the new renderer once its restarted. 223 // make their way to the new renderer once its restarted.
223 GetProcess()->EnableSendQueue(); 224 GetProcess()->EnableSendQueue();
224 225
225 if (ResourceDispatcherHostImpl::Get()) { 226 if (ResourceDispatcherHostImpl::Get()) {
226 BrowserThread::PostTask( 227 BrowserThread::PostTask(
227 BrowserThread::IO, FROM_HERE, 228 BrowserThread::IO, FROM_HERE,
228 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated, 229 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostCreated,
229 base::Unretained(ResourceDispatcherHostImpl::Get()), 230 base::Unretained(ResourceDispatcherHostImpl::Get()),
230 GetProcess()->GetID(), GetRoutingID())); 231 GetProcess()->GetID(), GetRoutingID()));
231 } 232 }
233
234 close_timeout_.reset(new TimeoutMonitor(base::Bind(
235 &RenderViewHostImpl::ClosePageTimeout, weak_factory_.GetWeakPtr())));
232 } 236 }
233 237
234 RenderViewHostImpl::~RenderViewHostImpl() { 238 RenderViewHostImpl::~RenderViewHostImpl() {
235 if (ResourceDispatcherHostImpl::Get()) { 239 if (ResourceDispatcherHostImpl::Get()) {
236 BrowserThread::PostTask( 240 BrowserThread::PostTask(
237 BrowserThread::IO, FROM_HERE, 241 BrowserThread::IO, FROM_HERE,
238 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted, 242 base::Bind(&ResourceDispatcherHostImpl::OnRenderViewHostDeleted,
239 base::Unretained(ResourceDispatcherHostImpl::Get()), 243 base::Unretained(ResourceDispatcherHostImpl::Get()),
240 GetProcess()->GetID(), GetRoutingID())); 244 GetProcess()->GetID(), GetRoutingID()));
241 } 245 }
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 &prefs.expensive_background_throttling_max_budget); 572 &prefs.expensive_background_throttling_max_budget);
569 SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_delay", 573 SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_delay",
570 &prefs.expensive_background_throttling_max_delay); 574 &prefs.expensive_background_throttling_max_delay);
571 575
572 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs); 576 GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs);
573 return prefs; 577 return prefs;
574 } 578 }
575 579
576 void RenderViewHostImpl::ClosePage() { 580 void RenderViewHostImpl::ClosePage() {
577 is_waiting_for_close_ack_ = true; 581 is_waiting_for_close_ack_ = true;
578 GetWidget()->StartHangMonitorTimeout(
579 TimeDelta::FromMilliseconds(kUnloadTimeoutMS),
580 blink::WebInputEvent::Undefined,
581 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE);
582 582
583 bool is_javascript_dialog_showing = delegate_->IsJavaScriptDialogShowing(); 583 bool is_javascript_dialog_showing = delegate_->IsJavaScriptDialogShowing();
584 584
585 // If there is a JavaScript dialog up, don't bother sending the renderer the 585 // If there is a JavaScript dialog up, don't bother sending the renderer the
586 // close event because it is known unresponsive, waiting for the reply from 586 // close event because it is known unresponsive, waiting for the reply from
587 // the dialog. 587 // the dialog.
588 if (IsRenderViewLive() && !is_javascript_dialog_showing) { 588 if (IsRenderViewLive() && !is_javascript_dialog_showing) {
589 // Since we are sending an IPC message to the renderer, increase the event 589 // Intentionally broken timer.
590 // count to prevent the hang monitor timeout from being stopped by input 590 // close_timeout_->Start(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
591 // event acknowledgments.
592 GetWidget()->increment_in_flight_event_count();
593 591
594 // TODO(creis): Should this be moved to Shutdown? It may not be called for 592 // TODO(creis): Should this be moved to Shutdown? It may not be called for
595 // RenderViewHosts that have been swapped out. 593 // RenderViewHosts that have been swapped out.
596 NotificationService::current()->Notify( 594 NotificationService::current()->Notify(
597 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 595 NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
598 Source<RenderViewHost>(this), 596 Source<RenderViewHost>(this),
599 NotificationService::NoDetails()); 597 NotificationService::NoDetails());
600 598
601 Send(new ViewMsg_ClosePage(GetRoutingID())); 599 Send(new ViewMsg_ClosePage(GetRoutingID()));
602 } else { 600 } else {
603 // This RenderViewHost doesn't have a live renderer, so just skip the close 601 // This RenderViewHost doesn't have a live renderer, so just skip the close
604 // event and close the page. 602 // event and close the page.
605 ClosePageIgnoringUnloadEvents(); 603 ClosePageIgnoringUnloadEvents();
606 } 604 }
607 } 605 }
608 606
609 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() { 607 void RenderViewHostImpl::ClosePageIgnoringUnloadEvents() {
610 GetWidget()->StopHangMonitorTimeout(); 608 close_timeout_->Stop();
611 is_waiting_for_close_ack_ = false; 609 is_waiting_for_close_ack_ = false;
612 610
613 sudden_termination_allowed_ = true; 611 sudden_termination_allowed_ = true;
614 delegate_->Close(this); 612 delegate_->Close(this);
615 } 613 }
616 614
617 void RenderViewHostImpl::RenderProcessReady(RenderProcessHost* host) { 615 void RenderViewHostImpl::RenderProcessReady(RenderProcessHost* host) {
618 if (render_view_ready_on_process_launch_) { 616 if (render_view_ready_on_process_launch_) {
619 render_view_ready_on_process_launch_ = false; 617 render_view_ready_on_process_launch_ = false;
620 RenderViewReady(); 618 RenderViewReady();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 delegate_->RouteCloseEvent(this); 844 delegate_->RouteCloseEvent(this);
847 } 845 }
848 846
849 void RenderViewHostImpl::OnTakeFocus(bool reverse) { 847 void RenderViewHostImpl::OnTakeFocus(bool reverse) {
850 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 848 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
851 if (view) 849 if (view)
852 view->TakeFocus(reverse); 850 view->TakeFocus(reverse);
853 } 851 }
854 852
855 void RenderViewHostImpl::OnClosePageACK() { 853 void RenderViewHostImpl::OnClosePageACK() {
856 GetWidget()->decrement_in_flight_event_count();
857 ClosePageIgnoringUnloadEvents(); 854 ClosePageIgnoringUnloadEvents();
858 } 855 }
859 856
860 void RenderViewHostImpl::OnFocus() { 857 void RenderViewHostImpl::OnFocus() {
861 // Note: We allow focus and blur from swapped out RenderViewHosts, even when 858 // Note: We allow focus and blur from swapped out RenderViewHosts, even when
862 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI). 859 // the active RenderViewHost is in a different BrowsingInstance (e.g., WebUI).
863 delegate_->Activate(); 860 delegate_->Activate();
864 } 861 }
865 862
866 void RenderViewHostImpl::RenderWidgetDidForwardMouseEvent( 863 void RenderViewHostImpl::RenderWidgetDidForwardMouseEvent(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 weak_factory_.GetWeakPtr())); 949 weak_factory_.GetWeakPtr()));
953 } else { 950 } else {
954 render_view_ready_on_process_launch_ = true; 951 render_view_ready_on_process_launch_ = true;
955 } 952 }
956 } 953 }
957 954
958 void RenderViewHostImpl::RenderViewReady() { 955 void RenderViewHostImpl::RenderViewReady() {
959 delegate_->RenderViewReady(this); 956 delegate_->RenderViewReady(this);
960 } 957 }
961 958
959 void RenderViewHostImpl::ClosePageTimeout() {
960 if (delegate_->ShouldIgnoreUnresponsiveRenderer())
961 return;
962
963 UMA_HISTOGRAM_ENUMERATION(
964 "ChildProcess.HangRendererType",
965 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_CLOSE_PAGE,
966 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_MAX);
967
968 ClosePageIgnoringUnloadEvents();
969 }
970
962 } // namespace content 971 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698