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

Unified Diff: chrome/views/throbber.cc

Issue 18757: Porting in chrome/views/ (Closed)
Patch Set: sync with trunk Created 11 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/views/throbber.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/views/throbber.cc
diff --git a/chrome/views/throbber.cc b/chrome/views/throbber.cc
index ba8695c4678445f1a9ac76b84dd45a96d2a84cce..2b6b21556f025c0f9464b2fe12ed325e8d152f36 100644
--- a/chrome/views/throbber.cc
+++ b/chrome/views/throbber.cc
@@ -4,24 +4,24 @@
#include "chrome/views/throbber.h"
+#include "base/time.h"
#include "chrome/app/theme/theme_resources.h"
#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/resource_bundle.h"
#include "skia/include/SkBitmap.h"
+using base::Time;
using base::TimeDelta;
namespace views {
Throbber::Throbber(int frame_time_ms,
bool paint_while_stopped)
- : paint_while_stopped_(paint_while_stopped),
- running_(false),
- last_frame_drawn_(-1),
- frame_time_ms_(frame_time_ms),
+ : running_(false),
+ paint_while_stopped_(paint_while_stopped),
frames_(NULL),
- last_time_recorded_(0) {
+ frame_time_(TimeDelta::FromMilliseconds(frame_time_ms)) {
ResourceBundle &rb = ResourceBundle::GetSharedInstance();
frames_ = rb.GetBitmapNamed(IDR_THROBBER);
DCHECK(frames_->width() > 0 && frames_->height() > 0);
@@ -37,11 +37,10 @@ void Throbber::Start() {
if (running_)
return;
- start_time_ = GetTickCount();
- last_time_recorded_ = start_time_;
+ start_time_ = Time::Now();
- timer_.Start(
- TimeDelta::FromMilliseconds(frame_time_ms_ - 10), this, &Throbber::Run);
+ timer_.Start(frame_time_ - TimeDelta::FromMilliseconds(10),
+ this, &Throbber::Run);
running_ = true;
@@ -72,20 +71,9 @@ void Throbber::Paint(ChromeCanvas* canvas) {
if (!running_ && !paint_while_stopped_)
return;
- DWORD current_time = GetTickCount();
- int current_frame = 0;
-
- // deal with timer wraparound
- if (current_time < last_time_recorded_) {
- start_time_ = current_time;
- current_frame = (last_frame_drawn_ + 1) % frame_count_;
- } else {
- current_frame =
- ((current_time - start_time_) / frame_time_ms_) % frame_count_;
- }
-
- last_time_recorded_ = current_time;
- last_frame_drawn_ = current_frame;
+ const TimeDelta elapsed_time = Time::Now() - start_time_;
+ const int current_frame =
+ static_cast<int>(elapsed_time / frame_time_) % frame_count_;
int image_size = frames_->height();
int image_offset = current_frame * image_size;
@@ -140,8 +128,8 @@ void SmoothedThrobber::StopDelayOver() {
// Checkmark throbber ---------------------------------------------------------
CheckmarkThrobber::CheckmarkThrobber()
- : checked_(false),
- Throbber(kFrameTimeMs, false) {
+ : Throbber(kFrameTimeMs, false),
+ checked_(false) {
InitClass();
}
« no previous file with comments | « chrome/views/throbber.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698