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

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: polish 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..6166c7596cf4e3af2cd8c053193dab6717706007 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,20 @@ 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, or very small. This rarely happens but should be handled.
+ const int kMinIntervalMs = 10;
+ if (interval.InMilliseconds() < kMinIntervalMs)
+ interval = base::TimeDelta::FromMilliseconds(kMinIntervalMs);
+
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