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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 11418305: Fix incremental sync behavior of DriveFileSyncService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: drop unreached case Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 DISALLOW_COPY_AND_ASSIGN(TaskToken); 132 DISALLOW_COPY_AND_ASSIGN(TaskToken);
133 }; 133 };
134 134
135 struct DriveFileSyncService::ProcessRemoteChangeParam { 135 struct DriveFileSyncService::ProcessRemoteChangeParam {
136 scoped_ptr<TaskToken> token; 136 scoped_ptr<TaskToken> token;
137 RemoteChangeProcessor* processor; 137 RemoteChangeProcessor* processor;
138 RemoteChange remote_change; 138 RemoteChange remote_change;
139 fileapi::SyncOperationCallback callback; 139 fileapi::SyncOperationCallback callback;
140 140
141 DriveMetadata drive_metadata; 141 DriveMetadata drive_metadata;
142 bool missing_db_entry;
143 bool metadata_updated; 142 bool metadata_updated;
144 FilePath temporary_file_path; 143 FilePath temporary_file_path;
145 std::string md5_checksum; 144 std::string md5_checksum;
146 fileapi::SyncOperationType operation_type; 145 fileapi::SyncOperationType operation_type;
147 146
148 ProcessRemoteChangeParam(scoped_ptr<TaskToken> token, 147 ProcessRemoteChangeParam(scoped_ptr<TaskToken> token,
149 RemoteChangeProcessor* processor, 148 RemoteChangeProcessor* processor,
150 const RemoteChange& remote_change, 149 const RemoteChange& remote_change,
151 const fileapi::SyncOperationCallback& callback) 150 const fileapi::SyncOperationCallback& callback)
152 : token(token.Pass()), 151 : token(token.Pass()),
153 processor(processor), 152 processor(processor),
154 remote_change(remote_change), 153 remote_change(remote_change),
155 callback(callback), 154 callback(callback),
156 missing_db_entry(false),
157 metadata_updated(false), 155 metadata_updated(false),
158 operation_type(fileapi::SYNC_OPERATION_NONE) { 156 operation_type(fileapi::SYNC_OPERATION_NONE) {
159 } 157 }
160 }; 158 };
161 159
162 DriveFileSyncService::ChangeQueueItem::ChangeQueueItem() 160 DriveFileSyncService::ChangeQueueItem::ChangeQueueItem()
163 : changestamp(0), 161 : changestamp(0),
164 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL) { 162 sync_type(REMOTE_SYNC_TYPE_INCREMENTAL) {
165 } 163 }
166 164
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 DCHECK(local_changes.list().back().IsDelete()); 1133 DCHECK(local_changes.list().back().IsDelete());
1136 param->operation_type = fileapi::SYNC_OPERATION_ADD; 1134 param->operation_type = fileapi::SYNC_OPERATION_ADD;
1137 DownloadForRemoteSync(param.Pass()); 1135 DownloadForRemoteSync(param.Pass());
1138 return; 1136 return;
1139 } 1137 }
1140 1138
1141 DCHECK(param->remote_change.change.IsDelete()); 1139 DCHECK(param->remote_change.change.IsDelete());
1142 if (local_changes.empty()) { 1140 if (local_changes.empty()) {
1143 if (missing_local_file) { 1141 if (missing_local_file) {
1144 param->operation_type = fileapi::SYNC_OPERATION_NONE; 1142 param->operation_type = fileapi::SYNC_OPERATION_NONE;
1145 DeleteMetadataForRemoteSync(param.Pass()); 1143 if (missing_db_entry)
1144 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK);
1145 else
1146 DeleteMetadataForRemoteSync(param.Pass());
1146 return; 1147 return;
1147 } 1148 }
1148 DCHECK(!missing_local_file); 1149 DCHECK(!missing_local_file);
1149 param->operation_type = fileapi::SYNC_OPERATION_DELETE; 1150 param->operation_type = fileapi::SYNC_OPERATION_DELETE;
1150 1151
1151 const fileapi::FileChange& file_change = param->remote_change.change; 1152 const fileapi::FileChange& file_change = param->remote_change.change;
1152 param->processor->ApplyRemoteChange( 1153 param->processor->ApplyRemoteChange(
1153 file_change, FilePath(), url, 1154 file_change, FilePath(), url,
1154 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(), 1155 base::Bind(&DriveFileSyncService::DidApplyRemoteChange, AsWeakPtr(),
1155 base::Passed(&param))); 1156 base::Passed(&param)));
1156 return; 1157 return;
1157 } 1158 }
1158 1159
1159 DCHECK(!local_changes.empty()); 1160 DCHECK(!local_changes.empty());
1160 if (local_changes.list().back().IsAddOrUpdate()) { 1161 if (local_changes.list().back().IsAddOrUpdate()) {
1161 param->operation_type = fileapi::SYNC_OPERATION_NONE; 1162 param->operation_type = fileapi::SYNC_OPERATION_NONE;
1162 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK); 1163 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK);
1163 return; 1164 return;
1164 } 1165 }
1165 1166
1166 DCHECK(local_changes.list().back().IsDelete()); 1167 DCHECK(local_changes.list().back().IsDelete());
1167 param->operation_type = fileapi::SYNC_OPERATION_NONE; 1168 param->operation_type = fileapi::SYNC_OPERATION_NONE;
1168 DeleteMetadataForRemoteSync(param.Pass()); 1169 if (missing_db_entry)
1170 CompleteRemoteSync(param.Pass(), fileapi::SYNC_STATUS_OK);
1171 else
1172 DeleteMetadataForRemoteSync(param.Pass());
1169 } 1173 }
1170 1174
1171 void DriveFileSyncService::DownloadForRemoteSync( 1175 void DriveFileSyncService::DownloadForRemoteSync(
1172 scoped_ptr<ProcessRemoteChangeParam> param) { 1176 scoped_ptr<ProcessRemoteChangeParam> param) {
1173 // TODO(tzik): Use ShareableFileReference here after we get thread-safe 1177 // TODO(tzik): Use ShareableFileReference here after we get thread-safe
1174 // version of it. crbug.com/162598 1178 // version of it. crbug.com/162598
1175 FilePath* temporary_file_path = &param->temporary_file_path; 1179 FilePath* temporary_file_path = &param->temporary_file_path;
1176 content::BrowserThread::PostTaskAndReplyWithResult( 1180 content::BrowserThread::PostTaskAndReplyWithResult(
1177 content::BrowserThread::FILE, FROM_HERE, 1181 content::BrowserThread::FILE, FROM_HERE,
1178 base::Bind(&CreateTemporaryFile, 1182 base::Bind(&CreateTemporaryFile,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 1400
1397 polling_enabled_ = false; 1401 polling_enabled_ = false;
1398 token->set_completion_callback(base::Bind(&EnablePolling, &polling_enabled_)); 1402 token->set_completion_callback(base::Bind(&EnablePolling, &polling_enabled_));
1399 1403
1400 if (metadata_store_->incremental_sync_origins().empty()) { 1404 if (metadata_store_->incremental_sync_origins().empty()) {
1401 NotifyTaskDone(fileapi::SYNC_STATUS_OK, token.Pass()); 1405 NotifyTaskDone(fileapi::SYNC_STATUS_OK, token.Pass());
1402 return; 1406 return;
1403 } 1407 }
1404 1408
1405 sync_client_->ListChanges( 1409 sync_client_->ListChanges(
1406 largest_fetched_changestamp_, 1410 largest_fetched_changestamp_ + 1,
1407 base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync, 1411 base::Bind(&DriveFileSyncService::DidFetchChangesForIncrementalSync,
1408 AsWeakPtr(), base::Passed(&token))); 1412 AsWeakPtr(), base::Passed(&token)));
1409 } 1413 }
1410 1414
1411 void DriveFileSyncService::DidFetchChangesForIncrementalSync( 1415 void DriveFileSyncService::DidFetchChangesForIncrementalSync(
1412 scoped_ptr<TaskToken> token, 1416 scoped_ptr<TaskToken> token,
1413 google_apis::GDataErrorCode error, 1417 google_apis::GDataErrorCode error,
1414 scoped_ptr<google_apis::DocumentFeed> changes) { 1418 scoped_ptr<google_apis::DocumentFeed> changes) {
1415 if (error != google_apis::HTTP_SUCCESS) { 1419 if (error != google_apis::HTTP_SUCCESS) {
1416 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass()); 1420 NotifyTaskDone(GDataErrorCodeToSyncStatusCodeWrapper(error), token.Pass());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 fileapi::SyncStatusCode 1511 fileapi::SyncStatusCode
1508 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper( 1512 DriveFileSyncService::GDataErrorCodeToSyncStatusCodeWrapper(
1509 google_apis::GDataErrorCode error) const { 1513 google_apis::GDataErrorCode error) const {
1510 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); 1514 fileapi::SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
1511 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated()) 1515 if (status != fileapi::SYNC_STATUS_OK && !sync_client_->IsAuthenticated())
1512 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED; 1516 return fileapi::SYNC_STATUS_AUTHENTICATION_FAILED;
1513 return status; 1517 return status;
1514 } 1518 }
1515 1519
1516 } // namespace sync_file_system 1520 } // namespace sync_file_system
OLDNEW
« 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