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

Unified Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 12221088: Sync FileSystem: Drop is_fetching_changes_ flag and completion_callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: run StartBatchSync on REMOTE_SERVICE_TEMPORARY_UNAVAILABLE case Created 7 years, 10 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 | « chrome/browser/sync_file_system/drive_file_sync_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_file_sync_service.cc
diff --git a/chrome/browser/sync_file_system/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_file_sync_service.cc
index 171853aa703b7b7265d207e34448610e98a6c10a..84b71ea44ba7ed7c8b28cfffef213a3795bb3f9f 100644
--- a/chrome/browser/sync_file_system/drive_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/drive_file_sync_service.cc
@@ -52,7 +52,7 @@ const char kDriveInvalidationObjectId[] = "CHANGELOG";
// notifications are on or off.
const int64 kMinimumPollingDelaySeconds = 5;
const int64 kMaximumPollingDelaySeconds = 10 * 60; // 10 min
-const int64 kPollingDelaySecondsWithNotification = 4 * 60 * 60; // 4 hr
+const int64 kPollingDelaySecondsWithNotification = 10 * 60; // 10 min
const double kDelayMultiplier = 1.6;
bool CreateTemporaryFile(const FilePath& dir_path, FilePath* temp_file) {
@@ -75,10 +75,6 @@ void DeleteTemporaryFile(const FilePath& file_path) {
void EmptyStatusCallback(fileapi::SyncStatusCode code) {}
-void MarkFetchingChangesCompleted(bool* is_fetching_changes) {
- *is_fetching_changes = false;
-}
-
void DidRemoveOrigin(const GURL& origin, fileapi::SyncStatusCode status) {
// TODO(calvinlo): Disable syncing if status not ok (http://crbug.com/171611).
DCHECK_EQ(fileapi::SYNC_STATUS_OK, status);
@@ -110,9 +106,6 @@ class DriveFileSyncService::TaskToken {
location_ = location;
task_type_ = TASK_TYPE_NONE;
description_.clear();
- if (!completion_callback_.is_null())
- completion_callback_.Run();
- completion_callback_.Reset();
}
void UpdateTask(const tracked_objects::Location& location,
@@ -131,14 +124,6 @@ class DriveFileSyncService::TaskToken {
const std::string& description() const { return description_; }
std::string done_description() const { return description_ + " done"; }
- void set_completion_callback(const base::Closure& callback) {
- completion_callback_ = callback;
- }
-
- const base::Closure& completion_callback() {
- return completion_callback_;
- }
-
~TaskToken() {
// All task on DriveFileSyncService must hold TaskToken instance to ensure
// no other tasks are running. Also, as soon as a task finishes to work,
@@ -157,7 +142,6 @@ class DriveFileSyncService::TaskToken {
tracked_objects::Location location_;
TaskType task_type_;
std::string description_;
- base::Closure completion_callback_;
DISALLOW_COPY_AND_ASSIGN(TaskToken);
};
@@ -186,6 +170,7 @@ void DriveFileSyncService::OnIncomingInvalidation(
kDriveInvalidationObjectId);
DCHECK_EQ(1U, invalidation_map.count(object_id));
+ has_unfetched_remote_change_ = true;
FetchChangesForIncrementalSync();
}
@@ -287,7 +272,7 @@ DriveFileSyncService::DriveFileSyncService(Profile* profile)
push_notification_registered_(false),
push_notification_enabled_(false),
polling_delay_seconds_(kMinimumPollingDelaySeconds),
- is_fetching_changes_(false),
+ has_unfetched_remote_change_(true),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
temporary_file_dir_ =
profile->GetPath().Append(kSyncFileSystemDir).Append(kTempDirName);
@@ -707,7 +692,7 @@ DriveFileSyncService::DriveFileSyncService(
push_notification_registered_(false),
push_notification_enabled_(false),
polling_delay_seconds_(-1),
- is_fetching_changes_(false),
+ has_unfetched_remote_change_(true),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(profile);
temporary_file_dir_ = base_dir.Append(kTempDirName);
@@ -767,9 +752,6 @@ void DriveFileSyncService::NotifyTaskDone(fileapi::SyncStatusCode status,
}
}
- if (!token_->completion_callback().is_null())
- token_->completion_callback().Run();
-
token_->ResetTask(FROM_HERE);
if (!pending_tasks_.empty()) {
base::Closure closure = pending_tasks_.front();
@@ -778,10 +760,14 @@ void DriveFileSyncService::NotifyTaskDone(fileapi::SyncStatusCode status,
return;
}
+ if (has_unfetched_remote_change_ && push_notification_enabled_) {
+ FetchChangesForIncrementalSync();
+ return;
+ }
+
SchedulePolling();
- if (GetCurrentState() != REMOTE_SERVICE_OK &&
- GetCurrentState() != REMOTE_SERVICE_TEMPORARY_UNAVAILABLE)
+ if (GetCurrentState() != REMOTE_SERVICE_OK)
return;
// If the state has become OK or TEMPORARY_UNAVAILABLE and we have any
@@ -1837,42 +1823,17 @@ bool DriveFileSyncService::GetPendingChangeForFileSystemURL(
}
void DriveFileSyncService::FetchChangesForIncrementalSync() {
- scoped_ptr<TaskToken> token(GetToken(FROM_HERE, TASK_TYPE_DRIVE,
- "Fetching remote change list"));
- // If we got |token| successfully, |is_fetching_changes_| should be false.
- // |is_fetching_changes_| is true only when the FetchChanges sequence is
- // running or is in |pending_queue_|. In both case, the token is owned by
- // the FetchChanges sequence.
- DCHECK(!token || !is_fetching_changes_);
-
if (!sync_enabled_ ||
- is_fetching_changes_ ||
!pending_batch_sync_origins_.empty() ||
metadata_store_->incremental_sync_origins().empty() ||
- !pending_changes_.empty()) {
- if (token) {
- token->ResetTask(FROM_HERE);
- NotifyTaskDone(last_operation_status_, token.Pass());
- }
+ !pending_changes_.empty())
return;
- }
-
- is_fetching_changes_ = true;
-
- if (!token) {
- pending_tasks_.push_back(base::Bind(
- &DriveFileSyncService::FetchChangesForIncrementalSync, AsWeakPtr()));
- return;
- }
- token->set_completion_callback(
- base::Bind(&MarkFetchingChangesCompleted, &is_fetching_changes_));
-
- if (metadata_store_->incremental_sync_origins().empty()) {
- token->ResetTask(FROM_HERE);
- NotifyTaskDone(fileapi::SYNC_STATUS_OK, token.Pass());
+ scoped_ptr<TaskToken> token(GetToken(FROM_HERE, TASK_TYPE_DRIVE,
+ "Fetching remote change list"));
+ if (!token)
return;
- }
+ has_unfetched_remote_change_ = false;
DVLOG(1) << "FetchChangesForIncrementalSync (start_changestamp:"
<< (largest_fetched_changestamp_ + 1) << ")";
« no previous file with comments | « chrome/browser/sync_file_system/drive_file_sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698