| Index: chrome/browser/chromeos/drive/change_list_loader.cc
|
| ===================================================================
|
| --- chrome/browser/chromeos/drive/change_list_loader.cc (revision 193805)
|
| +++ chrome/browser/chromeos/drive/change_list_loader.cc (working copy)
|
| @@ -357,6 +357,7 @@
|
| 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,
|
| @@ -740,7 +741,10 @@
|
|
|
| // 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));
|
| @@ -751,8 +755,21 @@
|
| // 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,
|
|
|