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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2643723007: time metric: record elapsed time from when the backgrounded and purged renderer is foregrounded unti (Closed)
Patch Set: Add NeedsToRecordFirstActivePaint to RenderThreadImpl Created 3 years, 10 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 popup_origin_scale_for_emulation_(0.f), 368 popup_origin_scale_for_emulation_(0.f),
369 frame_swap_message_queue_(new FrameSwapMessageQueue()), 369 frame_swap_message_queue_(new FrameSwapMessageQueue()),
370 resizing_mode_selector_(new ResizingModeSelector()), 370 resizing_mode_selector_(new ResizingModeSelector()),
371 has_host_context_menu_location_(false), 371 has_host_context_menu_location_(false),
372 has_added_input_handler_(false), 372 has_added_input_handler_(false),
373 has_focus_(false), 373 has_focus_(false),
374 #if defined(OS_MACOSX) 374 #if defined(OS_MACOSX)
375 text_input_client_observer_(new TextInputClientObserver(this)), 375 text_input_client_observer_(new TextInputClientObserver(this)),
376 #endif 376 #endif
377 focused_pepper_plugin_(nullptr), 377 focused_pepper_plugin_(nullptr),
378 time_to_first_active_paint_recorded_(true),
379 was_shown_time_(base::TimeTicks::Now()),
378 weak_ptr_factory_(this) { 380 weak_ptr_factory_(this) {
379 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); 381 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
380 if (!swapped_out) 382 if (!swapped_out)
381 RenderProcess::current()->AddRefProcess(); 383 RenderProcess::current()->AddRefProcess();
382 DCHECK(RenderThread::Get()); 384 DCHECK(RenderThread::Get());
383 385
384 // In tests there may not be a RenderThreadImpl. 386 // In tests there may not be a RenderThreadImpl.
385 if (RenderThreadImpl::current()) { 387 if (RenderThreadImpl::current()) {
386 render_widget_scheduling_state_ = RenderThreadImpl::current() 388 render_widget_scheduling_state_ = RenderThreadImpl::current()
387 ->GetRendererScheduler() 389 ->GetRendererScheduler()
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 observer.WasHidden(); 768 observer.WasHidden();
767 } 769 }
768 770
769 void RenderWidget::OnWasShown(bool needs_repainting, 771 void RenderWidget::OnWasShown(bool needs_repainting,
770 const ui::LatencyInfo& latency_info) { 772 const ui::LatencyInfo& latency_info) {
771 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); 773 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
772 // During shutdown we can just ignore this message. 774 // During shutdown we can just ignore this message.
773 if (!GetWebWidget()) 775 if (!GetWebWidget())
774 return; 776 return;
775 777
778 was_shown_time_ = base::TimeTicks::Now();
776 // See OnWasHidden 779 // See OnWasHidden
777 SetHidden(false); 780 SetHidden(false);
778 for (auto& observer : render_frames_) 781 for (auto& observer : render_frames_)
779 observer.WasShown(); 782 observer.WasShown();
780 783
781 if (!needs_repainting) 784 if (!needs_repainting)
782 return; 785 return;
783 786
784 // Generate a full repaint. 787 // Generate a full repaint.
785 if (compositor_) { 788 if (compositor_) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 bool RenderWidget::IsClosing() const { 925 bool RenderWidget::IsClosing() const {
923 return host_closing_; 926 return host_closing_;
924 } 927 }
925 928
926 void RenderWidget::RequestScheduleAnimation() { 929 void RenderWidget::RequestScheduleAnimation() {
927 scheduleAnimation(); 930 scheduleAnimation();
928 } 931 }
929 932
930 void RenderWidget::UpdateVisualState() { 933 void RenderWidget::UpdateVisualState() {
931 GetWebWidget()->updateAllLifecyclePhases(); 934 GetWebWidget()->updateAllLifecyclePhases();
935
936 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
937 if (!time_to_first_active_paint_recorded_ &&
esprehn 2017/02/08 06:23:06 You want to do the time_to_first_active_paint_reco
tasak 2017/02/08 06:49:07 Done.
938 render_thread_impl->NeedsToRecordFirstActivePaint()) {
939 time_to_first_active_paint_recorded_ = true;
940 base::TimeDelta sample = base::TimeTicks::Now() - was_shown_time_;
941 UMA_HISTOGRAM_TIMES("PurgeAndSuspend.Experimental.TimeToFirstActivePaint",
942 sample);
943 }
932 } 944 }
933 945
934 void RenderWidget::WillBeginCompositorFrame() { 946 void RenderWidget::WillBeginCompositorFrame() {
935 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 947 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
936 948
937 // The UpdateTextInputState can result in further layout and possibly 949 // The UpdateTextInputState can result in further layout and possibly
938 // enable GPU acceleration so they need to be called before any painting 950 // enable GPU acceleration so they need to be called before any painting
939 // is done. 951 // is done.
940 UpdateTextInputState(); 952 UpdateTextInputState();
941 UpdateSelectionBounds(); 953 UpdateSelectionBounds();
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 } 1887 }
1876 1888
1877 void RenderWidget::SetHidden(bool hidden) { 1889 void RenderWidget::SetHidden(bool hidden) {
1878 if (is_hidden_ == hidden) 1890 if (is_hidden_ == hidden)
1879 return; 1891 return;
1880 1892
1881 // The status has changed. Tell the RenderThread about it and ensure 1893 // The status has changed. Tell the RenderThread about it and ensure
1882 // throttled acks are released in case frame production ceases. 1894 // throttled acks are released in case frame production ceases.
1883 is_hidden_ = hidden; 1895 is_hidden_ = hidden;
1884 1896
1885 if (is_hidden_) 1897 if (is_hidden_) {
1886 RenderThreadImpl::current()->WidgetHidden(); 1898 RenderThreadImpl::current()->WidgetHidden();
1887 else 1899 time_to_first_active_paint_recorded_ = false;
1900 } else
1888 RenderThreadImpl::current()->WidgetRestored(); 1901 RenderThreadImpl::current()->WidgetRestored();
1889 1902
1890 if (render_widget_scheduling_state_) 1903 if (render_widget_scheduling_state_)
1891 render_widget_scheduling_state_->SetHidden(hidden); 1904 render_widget_scheduling_state_->SetHidden(hidden);
1892 } 1905 }
1893 1906
1894 void RenderWidget::DidToggleFullscreen() { 1907 void RenderWidget::DidToggleFullscreen() {
1895 if (!GetWebWidget()) 1908 if (!GetWebWidget())
1896 return; 1909 return;
1897 1910
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 // browser side (https://crbug.com/669219). 2306 // browser side (https://crbug.com/669219).
2294 // If there is no WebFrameWidget, then there will be no 2307 // If there is no WebFrameWidget, then there will be no
2295 // InputMethodControllers for a WebLocalFrame. 2308 // InputMethodControllers for a WebLocalFrame.
2296 return nullptr; 2309 return nullptr;
2297 } 2310 }
2298 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) 2311 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2299 ->getActiveWebInputMethodController(); 2312 ->getActiveWebInputMethodController();
2300 } 2313 }
2301 2314
2302 } // namespace content 2315 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698