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

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

Issue 13449004: drive: Update directory changestamp after "fast fetch" for the content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix Created 7 years, 8 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/change_list_loader.cc
diff --git a/chrome/browser/chromeos/drive/change_list_loader.cc b/chrome/browser/chromeos/drive/change_list_loader.cc
index a566a882f1941914d9381cbc2d416db43bbad21b..7ad4274293dca56be9fdb2958d72bbac268ea58d 100644
--- a/chrome/browser/chromeos/drive/change_list_loader.cc
+++ b/chrome/browser/chromeos/drive/change_list_loader.cc
@@ -354,6 +354,7 @@ void ChangeListLoader::LoadDirectoryFromServerAfterGetAbout(
if (util::GDataToDriveFileError(status) == DRIVE_FILE_OK) {
DCHECK(about_resource);
remote_changestamp = about_resource->largest_change_id();
+ last_known_remote_changestamp_ = remote_changestamp;
}
const DirectoryFetchInfo directory_fetch_info(directory_resource_id,
@@ -734,7 +735,10 @@ void ChangeListLoader::ScheduleRun(
// If the directory's changestamp is up-to-date, just schedule to run the
// callback, as there is no need to fetch the directory.
- if (directory_fetch_info.changestamp() >= last_known_remote_changestamp_) {
+ // Note that |last_known_remote_changestamp_| is 0 when it is not received
+ // yet. In that case we conservatively assume that we need to fetch.
+ if (last_known_remote_changestamp_ > 0 &&
+ directory_fetch_info.changestamp() >= last_known_remote_changestamp_) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback, DRIVE_FILE_OK));
@@ -745,8 +749,21 @@ void ChangeListLoader::ScheduleRun(
// can check that the directory is being fetched.
pending_load_callback_[resource_id].push_back(
base::Bind(&util::EmptyFileOperationCallback));
+
+ // Start fetching the directory content, and mark it with the changestamp
+ // |last_known_remote_changestamp_|. To be precise, instead we need to call
+ // GetAboutResource() to get the latest changestamp. However,
+ // - It is costly to do GetAboutResource HTTP request every time.
+ // - The chance using an old value is small; it only happens when LoadIfNeeded
+ // is called during one GetAboutResource roundtrip time of a feed fetching.
+ // - Even if the value is old, it just marks the directory as older. It may
+ // trigger one future unnecessary re-fetch, but it'll never lose data, etc.
+ DirectoryFetchInfo new_directory_fetch_info(
+ directory_fetch_info.resource_id(),
+ std::max(directory_fetch_info.changestamp(),
+ last_known_remote_changestamp_));
DoLoadDirectoryFromServer(
- directory_fetch_info,
+ new_directory_fetch_info,
base::Bind(&ChangeListLoader::OnDirectoryLoadComplete,
weak_ptr_factory_.GetWeakPtr(),
directory_fetch_info,
« 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