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

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

Issue 2707243005: Discard compositor frames from unloaded web content (Closed)
Patch Set: Small changes for review comments 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_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 owned_by_render_frame_host_(false), 287 owned_by_render_frame_host_(false),
288 is_focused_(false), 288 is_focused_(false),
289 hung_renderer_delay_( 289 hung_renderer_delay_(
290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
291 hang_monitor_reason_( 291 hang_monitor_reason_(
292 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN), 292 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN),
293 hang_monitor_event_type_(blink::WebInputEvent::Undefined), 293 hang_monitor_event_type_(blink::WebInputEvent::Undefined),
294 last_event_type_(blink::WebInputEvent::Undefined), 294 last_event_type_(blink::WebInputEvent::Undefined),
295 new_content_rendering_delay_( 295 new_content_rendering_delay_(
296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), 296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
297 current_content_source_id_(0),
297 weak_factory_(this) { 298 weak_factory_(this) {
298 CHECK(delegate_); 299 CHECK(delegate_);
299 CHECK_NE(MSG_ROUTING_NONE, routing_id_); 300 CHECK_NE(MSG_ROUTING_NONE, routing_id_);
300 latency_tracker_.SetDelegate(delegate_); 301 latency_tracker_.SetDelegate(delegate_);
301 302
302 #if defined(OS_WIN) 303 #if defined(OS_WIN)
303 // Update the display color profile cache so that it is likely to be up to 304 // Update the display color profile cache so that it is likely to be up to
304 // date when the renderer process requests the color profile. 305 // date when the renderer process requests the color profile.
305 if (gfx::ICCProfile::CachedProfilesNeedUpdate()) { 306 if (gfx::ICCProfile::CachedProfilesNeedUpdate()) {
306 base::PostTaskWithTraits( 307 base::PostTaskWithTraits(
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1004
1004 void RenderWidgetHostImpl::StopHangMonitorTimeout() { 1005 void RenderWidgetHostImpl::StopHangMonitorTimeout() {
1005 if (hang_monitor_timeout_) { 1006 if (hang_monitor_timeout_) {
1006 hang_monitor_timeout_->Stop(); 1007 hang_monitor_timeout_->Stop();
1007 hang_monitor_reason_ = 1008 hang_monitor_reason_ =
1008 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN; 1009 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN;
1009 } 1010 }
1010 RendererIsResponsive(); 1011 RendererIsResponsive();
1011 } 1012 }
1012 1013
1013 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { 1014 void RenderWidgetHostImpl::StartNewContentRenderingTimeout(
1015 uint32_t next_source_id) {
1016 current_content_source_id_ = next_source_id;
1014 // It is possible for a compositor frame to arrive before the browser is 1017 // It is possible for a compositor frame to arrive before the browser is
1015 // notified about the page being committed, in which case no timer is 1018 // notified about the page being committed, in which case no timer is
1016 // necessary. 1019 // necessary.
1017 if (received_paint_after_load_) { 1020 if (received_paint_after_load_) {
1018 received_paint_after_load_ = false; 1021 received_paint_after_load_ = false;
1019 return; 1022 return;
1020 } 1023 }
1021 1024
1022 new_content_rendering_timeout_->Start(new_content_rendering_delay_); 1025 new_content_rendering_timeout_->Start(new_content_rendering_delay_);
1023 } 1026 }
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 std::vector<IPC::Message> messages_to_deliver_with_frame; 1845 std::vector<IPC::Message> messages_to_deliver_with_frame;
1843 messages_to_deliver_with_frame.swap(std::get<2>(param)); 1846 messages_to_deliver_with_frame.swap(std::get<2>(param));
1844 1847
1845 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, 1848 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info,
1846 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { 1849 "RenderWidgetHostImpl::OnSwapCompositorFrame")) {
1847 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); 1850 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info);
1848 } 1851 }
1849 1852
1850 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info); 1853 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info);
1851 1854
1855 // Ignore this frame if its content has already been unloaded.
enne (OOO) 2017/02/28 22:23:21 I agree that maybe the mobile optimized and double
kenrb 2017/03/01 15:32:47 Done.
1856 if (frame.metadata.content_source_id < current_content_source_id_)
1857 return false;
1858
1852 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata); 1859 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata);
1853 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized); 1860 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized);
1854 if (touch_emulator_) 1861 if (touch_emulator_)
1855 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); 1862 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
1856 1863
1857 if (view_) { 1864 if (view_) {
1858 view_->OnSwapCompositorFrame(compositor_frame_sink_id, std::move(frame)); 1865 view_->OnSwapCompositorFrame(compositor_frame_sink_id, std::move(frame));
1859 view_->DidReceiveRendererFrame(); 1866 view_->DidReceiveRendererFrame();
1860 } else { 1867 } else {
1861 cc::ReturnedResourceArray resources; 1868 cc::ReturnedResourceArray resources;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 // different from the receiver's. 2537 // different from the receiver's.
2531 file_system_file.url = 2538 file_system_file.url =
2532 GURL(storage::GetIsolatedFileSystemRootURIString( 2539 GURL(storage::GetIsolatedFileSystemRootURIString(
2533 file_system_url.origin(), filesystem_id, std::string()) 2540 file_system_url.origin(), filesystem_id, std::string())
2534 .append(register_name)); 2541 .append(register_name));
2535 file_system_file.filesystem_id = filesystem_id; 2542 file_system_file.filesystem_id = filesystem_id;
2536 } 2543 }
2537 } 2544 }
2538 2545
2539 } // namespace content 2546 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698