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

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

Issue 2780373002: Use observer pattern instead of sniffing SwapCompositorFrame IPC (Closed)
Patch Set: Addressed comments Created 3 years, 8 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 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 return; 2624 return;
2625 } 2625 }
2626 // |has_damage| is not transmitted. 2626 // |has_damage| is not transmitted.
2627 frame.metadata.begin_frame_ack.has_damage = true; 2627 frame.metadata.begin_frame_ack.has_damage = true;
2628 2628
2629 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, 2629 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info,
2630 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { 2630 "RenderWidgetHostImpl::OnSwapCompositorFrame")) {
2631 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); 2631 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info);
2632 } 2632 }
2633 2633
2634 last_frame_metadata_ = frame.metadata.Clone();
2635
2634 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info); 2636 latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info);
2635 2637
2636 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata); 2638 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata);
2637 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized); 2639 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized);
2638 if (touch_emulator_) 2640 if (touch_emulator_)
2639 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); 2641 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
2640 2642
2641 // Ignore this frame if its content has already been unloaded. Source ID 2643 // Ignore this frame if its content has already been unloaded. Source ID
2642 // is always zero for an OOPIF because we are only concerned with displaying 2644 // is always zero for an OOPIF because we are only concerned with displaying
2643 // stale graphics on top-level frames. We accept frames that have a source ID 2645 // stale graphics on top-level frames. We accept frames that have a source ID
2644 // greater than |current_content_source_id_| because in some cases the first 2646 // greater than |current_content_source_id_| because in some cases the first
2645 // compositor frame can arrive before the navigation commit message that 2647 // compositor frame can arrive before the navigation commit message that
2646 // updates that value. 2648 // updates that value.
2647 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) { 2649 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) {
2648 view_->SubmitCompositorFrame(local_surface_id, std::move(frame)); 2650 view_->SubmitCompositorFrame(local_surface_id, std::move(frame));
2649 view_->DidReceiveRendererFrame(); 2651 view_->DidReceiveRendererFrame();
2650 } else { 2652 } else {
2651 cc::ReturnedResourceArray resources; 2653 cc::ReturnedResourceArray resources;
2652 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); 2654 cc::TransferableResource::ReturnResources(frame.resource_list, &resources);
2653 SendReclaimCompositorResources(true /* is_swap_ack */, resources); 2655 SendReclaimCompositorResources(true /* is_swap_ack */, resources);
2654 } 2656 }
2655 2657
2656 // After navigation, if a frame belonging to the new page is received, stop 2658 // After navigation, if a frame belonging to the new page is received, stop
2657 // the timer that triggers clearing the graphics of the last page. 2659 // the timer that triggers clearing the graphics of the last page.
2658 if (last_received_content_source_id_ >= current_content_source_id_ && 2660 if (last_received_content_source_id_ >= current_content_source_id_ &&
2659 new_content_rendering_timeout_->IsRunning()) { 2661 new_content_rendering_timeout_->IsRunning()) {
2660 new_content_rendering_timeout_->Stop(); 2662 new_content_rendering_timeout_->Stop();
2661 } 2663 }
2664
2665 if (delegate_)
2666 delegate_->DidReceiveCompositorFrame();
2662 } 2667 }
2663 2668
2664 } // namespace content 2669 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_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