Commit 01eb8fa8 authored by tzik@chromium.org's avatar tzik@chromium.org

Sync FileSystem: Update polling delay when remote change-list did not update change_queue.


BUG=156041


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170961 0039d316-1c4b-4281-b951-d872f2087c98
parent 45628434
...@@ -1320,7 +1320,7 @@ void DriveFileSyncService::FinalizeRemoteSync( ...@@ -1320,7 +1320,7 @@ void DriveFileSyncService::FinalizeRemoteSync(
} }
} }
void DriveFileSyncService::AppendNewRemoteChange( bool DriveFileSyncService::AppendNewRemoteChange(
const GURL& origin, const GURL& origin,
const google_apis::DocumentEntry& entry, const google_apis::DocumentEntry& entry,
int64 changestamp, int64 changestamp,
...@@ -1332,7 +1332,7 @@ void DriveFileSyncService::AppendNewRemoteChange( ...@@ -1332,7 +1332,7 @@ void DriveFileSyncService::AppendNewRemoteChange(
PathToChange::iterator found = path_to_change->find(path); PathToChange::iterator found = path_to_change->find(path);
if (found != path_to_change->end()) { if (found != path_to_change->end()) {
if (found->second.changestamp >= changestamp) if (found->second.changestamp >= changestamp)
return; return false;
pending_changes_.erase(found->second.position_in_queue); pending_changes_.erase(found->second.position_in_queue);
} }
...@@ -1361,6 +1361,7 @@ void DriveFileSyncService::AppendNewRemoteChange( ...@@ -1361,6 +1361,7 @@ void DriveFileSyncService::AppendNewRemoteChange(
(*path_to_change)[path] = RemoteChange( (*path_to_change)[path] = RemoteChange(
changestamp, entry.resource_id(), url, file_change, changestamp, entry.resource_id(), url, file_change,
inserted_to_queue.first); inserted_to_queue.first);
return true;
} }
void DriveFileSyncService::RemoveRemoteChange( void DriveFileSyncService::RemoveRemoteChange(
...@@ -1420,11 +1421,12 @@ void DriveFileSyncService::FetchChangesForIncrementalSync() { ...@@ -1420,11 +1421,12 @@ void DriveFileSyncService::FetchChangesForIncrementalSync() {
sync_client_->ListChanges( sync_client_->ListChanges(
largest_fetched_changestamp_ + 1, largest_fetched_changestamp_ + 1,
base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync, base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync,
AsWeakPtr(), base::Passed(&token))); AsWeakPtr(), base::Passed(&token), false));
} }
void DriveFileSyncService::DidFetchChangesForIncrementalSync( void DriveFileSyncService::DidFetchChangesForIncrementalSync(
scoped_ptr<TaskToken> token, scoped_ptr<TaskToken> token,
bool has_new_changes,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::DocumentFeed> changes) { scoped_ptr<google_apis::DocumentFeed> changes) {
if (error != google_apis::HTTP_SUCCESS) { if (error != google_apis::HTTP_SUCCESS) {
...@@ -1440,8 +1442,9 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync( ...@@ -1440,8 +1442,9 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync(
if (!GetOriginForEntry(entry, &origin)) if (!GetOriginForEntry(entry, &origin))
continue; continue;
AppendNewRemoteChange(origin, entry, entry.changestamp(), has_new_changes = has_new_changes ||
REMOTE_SYNC_TYPE_INCREMENTAL); AppendNewRemoteChange(origin, entry, entry.changestamp(),
REMOTE_SYNC_TYPE_INCREMENTAL);
} }
GURL next_feed; GURL next_feed;
...@@ -1449,20 +1452,20 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync( ...@@ -1449,20 +1452,20 @@ void DriveFileSyncService::DidFetchChangesForIncrementalSync(
sync_client_->ContinueListing( sync_client_->ContinueListing(
next_feed, next_feed,
base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync, base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync,
AsWeakPtr(), base::Passed(&token))); AsWeakPtr(), base::Passed(&token), has_new_changes));
return; return;
} }
largest_fetched_changestamp_ = changes->largest_changestamp(); largest_fetched_changestamp_ = changes->largest_changestamp();
if (changes->start_index() == 0 && changes->entries().empty()) { if (has_new_changes) {
// If this set of changes is the first feed and it's empty, update polling_delay_seconds_ = kMinimumPollingDelaySeconds;
// the polling delay to wait longer. } else {
// If the change_queue_ was not updated, update the polling delay to wait
// longer.
polling_delay_seconds_ = std::min( polling_delay_seconds_ = std::min(
static_cast<int64>(kDelayMultiplier * polling_delay_seconds_), static_cast<int64>(kDelayMultiplier * polling_delay_seconds_),
kMaximumPollingDelaySeconds); kMaximumPollingDelaySeconds);
} else {
polling_delay_seconds_ = kMinimumPollingDelaySeconds;
} }
NotifyTaskDone(fileapi::SYNC_STATUS_OK, token.Pass()); NotifyTaskDone(fileapi::SYNC_STATUS_OK, token.Pass());
......
...@@ -280,7 +280,8 @@ class DriveFileSyncService ...@@ -280,7 +280,8 @@ class DriveFileSyncService
scoped_ptr<ProcessRemoteChangeParam> param, scoped_ptr<ProcessRemoteChangeParam> param,
fileapi::SyncStatusCode status); fileapi::SyncStatusCode status);
void AppendNewRemoteChange(const GURL& origin, // Returns true if |pending_changes_| was updated.
bool AppendNewRemoteChange(const GURL& origin,
const google_apis::DocumentEntry& entry, const google_apis::DocumentEntry& entry,
int64 changestamp, int64 changestamp,
RemoteSyncType sync_type); RemoteSyncType sync_type);
...@@ -301,6 +302,7 @@ class DriveFileSyncService ...@@ -301,6 +302,7 @@ class DriveFileSyncService
void FetchChangesForIncrementalSync(); void FetchChangesForIncrementalSync();
void DidFetchChangesForIncrementalSync( void DidFetchChangesForIncrementalSync(
scoped_ptr<TaskToken> token, scoped_ptr<TaskToken> token,
bool has_new_changes,
google_apis::GDataErrorCode error, google_apis::GDataErrorCode error,
scoped_ptr<google_apis::DocumentFeed> changes); scoped_ptr<google_apis::DocumentFeed> changes);
bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin); bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin);
......
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