Commit 2295fd49 authored by satorux@chromium.org's avatar satorux@chromium.org

drive: Fix computation for showing the number of fetched files

Previously, computation of the interval resulted in a negative value
in under certain circumstances, which resulted in a DCHECK failure.
This patch fixes the problem.

BUG=154363
TEST=Log in using a large Drive account; open Files.app and go to Drive; The number of fetched files was updated smoothly

Review URL: https://chromiumcodereview.appspot.com/11192027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162361 0039d316-1c4b-4281-b951-d872f2087c98
parent 9564b9e2
......@@ -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);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment