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

Unified Diff: chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc

Issue 11192027: drive: Fix computation for showing the number of fetched files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc
diff --git a/chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc b/chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc
index 2e0d2d46fb9162c6b7b3fba563845aaa56f9bd81..bf3a366775803fc61fa945c99cc4a44bdcf41efd 100644
--- a/chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc
+++ b/chrome/browser/chromeos/drive/gdata_wapi_feed_loader.cc
@@ -743,7 +743,7 @@ void GDataWapiFeedLoader::OnNotifyDocumentFeedFetched(
return;
}
- base::TimeDelta elapsed_time =
+ base::TimeDelta ui_elapsed_time =
base::TimeTicks::Now() - ui_state->start_time;
if (ui_state->num_showing_documents + kFetchUiUpdateStep <=
@@ -759,13 +759,19 @@ void GDataWapiFeedLoader::OnNotifyDocumentFeedFetched(
// Heuristically, we use fetched time duration to calculate the next
// UI update timing.
base::TimeDelta remaining_duration =
- ui_state->feed_fetching_elapsed_time - elapsed_time;
+ ui_state->feed_fetching_elapsed_time - ui_elapsed_time;
+ base::TimeDelta interval = remaining_duration / num_remaining_ui_updates;
+ // If UI update is slow for some reason, the interval can be
+ // negative. This rarely happens but should be handled.
+ if (interval.InMilliseconds() < 0)
hidehiko 2012/10/17 08:39:49 10 instead of 0 may be better to keep the consiste
satorux1 2012/10/17 08:44:03 I guess "< 0" is clearer that we are dealing with
+ interval = base::TimeDelta::FromMilliseconds(10);
+
base::MessageLoopProxy::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&GDataWapiFeedLoader::OnNotifyDocumentFeedFetched,
weak_ptr_factory_.GetWeakPtr(),
ui_state->weak_ptr_factory.GetWeakPtr()),
- remaining_duration / num_remaining_ui_updates);
+ interval);
}
}
}
« 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