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

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

Issue 6547001: Update the animation callback histogram to measure only the delay between post and invocation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing (to run through trybots, no review needed) Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/render_widget.h" 5 #include "chrome/renderer/render_widget.h"
6 6
7 #include "app/surface/transport_dib.h" 7 #include "app/surface/transport_dib.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 paint.setColor(colors[color_selector++ % arraysize(colors)]); 476 paint.setColor(colors[color_selector++ % arraysize(colors)]);
477 paint.setStrokeWidth(1); 477 paint.setStrokeWidth(1);
478 478
479 SkIRect irect; 479 SkIRect irect;
480 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); 480 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
481 canvas->drawIRect(irect, paint); 481 canvas->drawIRect(irect, paint);
482 } 482 }
483 483
484 void RenderWidget::AnimationCallback() { 484 void RenderWidget::AnimationCallback() {
485 animation_task_posted_ = false; 485 animation_task_posted_ = false;
486 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime", 0, 0, 16, 17); 486 if (!animation_update_pending_)
487 return;
488 if (!animation_floor_time_.is_null()) {
489 // Record when we fired (according to base::Time::Now()) relative to when
490 // we posted the task to quantify how much the base::Time/base::TimeTicks
491 // skew is affecting animations.
492 base::TimeDelta animation_callback_delay = base::Time::Now() -
493 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16));
494 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime",
495 animation_callback_delay,
496 base::TimeDelta::FromMilliseconds(0),
497 base::TimeDelta::FromMilliseconds(30),
498 25);
499 }
487 CallDoDeferredUpdate(); 500 CallDoDeferredUpdate();
488 } 501 }
489 502
490 void RenderWidget::AnimateIfNeeded() { 503 void RenderWidget::AnimateIfNeeded() {
491 if (animation_update_pending_) { 504 if (!animation_update_pending_)
492 base::Time now = base::Time::Now(); 505 return;
493 if (now >= animation_floor_time_) { 506 base::Time now = base::Time::Now();
494 animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16); 507 if (now >= animation_floor_time_) {
495 // Set a timer to call us back after 16ms (targetting 60FPS) before 508 animation_floor_time_ = now + base::TimeDelta::FromMilliseconds(16);
496 // running animation callbacks so that if a callback requests another 509 // Set a timer to call us back after 16ms (targetting 60FPS) before
497 // we'll be sure to run it at the proper time. 510 // running animation callbacks so that if a callback requests another
498 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( 511 // we'll be sure to run it at the proper time.
499 this, &RenderWidget::AnimationCallback), 16); 512 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
500 animation_task_posted_ = true; 513 this, &RenderWidget::AnimationCallback), 16);
501 animation_update_pending_ = false; 514 animation_task_posted_ = true;
502 webwidget_->animate(); 515 animation_update_pending_ = false;
503 } else if (!animation_task_posted_) { 516 webwidget_->animate();
504 // This code uses base::Time::Now() to calculate the floor and next fire 517 return;
505 // time because javascript's Date object uses base::Time::Now(). The
506 // message loop uses base::TimeTicks, which on windows can have a
507 // different granularity than base::Time.
508 // The upshot of all this is that this function might be called before
509 // base::Time::Now() has advanced past the animation_floor_time_. To
510 // avoid exposing this delay to javascript, we keep posting delayed
511 // tasks until base::Time::Now() has advanced far enough.
512 int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp();
513 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.AnimationDelayTime",
514 static_cast<int>(delay), 0, 16, 17);
515 animation_task_posted_ = true;
516 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
517 this, &RenderWidget::AnimationCallback), delay);
518 }
519 } 518 }
519 if (animation_task_posted_)
520 return;
521 // This code uses base::Time::Now() to calculate the floor and next fire
522 // time because javascript's Date object uses base::Time::Now(). The
523 // message loop uses base::TimeTicks, which on windows can have a
524 // different granularity than base::Time.
525 // The upshot of all this is that this function might be called before
526 // base::Time::Now() has advanced past the animation_floor_time_. To
527 // avoid exposing this delay to javascript, we keep posting delayed
528 // tasks until base::Time::Now() has advanced far enough.
529 int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp();
530 animation_task_posted_ = true;
531 MessageLoop::current()->PostDelayedTask(FROM_HERE,
532 NewRunnableMethod(this, &RenderWidget::AnimationCallback), delay);
520 } 533 }
521 534
522 void RenderWidget::CallDoDeferredUpdate() { 535 void RenderWidget::CallDoDeferredUpdate() {
523 DoDeferredUpdate(); 536 DoDeferredUpdate();
524 537
525 if (pending_input_event_ack_.get()) 538 if (pending_input_event_ack_.get())
526 Send(pending_input_event_ack_.release()); 539 Send(pending_input_event_ack_.release());
527 } 540 }
528 541
529 void RenderWidget::DoDeferredUpdate() { 542 void RenderWidget::DoDeferredUpdate() {
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1096
1084 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 1097 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1085 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 1098 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1086 i != plugin_window_moves_.end(); ++i) { 1099 i != plugin_window_moves_.end(); ++i) {
1087 if (i->window == window) { 1100 if (i->window == window) {
1088 plugin_window_moves_.erase(i); 1101 plugin_window_moves_.erase(i);
1089 break; 1102 break;
1090 } 1103 }
1091 } 1104 }
1092 } 1105 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698