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

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

Issue 11411352: Clear syncing flag after a remote or local sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: also check REMOTE_SERVICE_DISABLED state 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
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/local_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/local_file_sync_service.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/sync_file_system/local_change_processor.h" 8 #include "chrome/browser/sync_file_system/local_change_processor.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 void LocalFileSyncService::HasPendingLocalChanges( 143 void LocalFileSyncService::HasPendingLocalChanges(
144 const fileapi::FileSystemURL& url, 144 const fileapi::FileSystemURL& url,
145 const HasPendingLocalChangeCallback& callback) { 145 const HasPendingLocalChangeCallback& callback) {
146 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); 146 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
147 sync_context_->HasPendingLocalChanges( 147 sync_context_->HasPendingLocalChanges(
148 origin_to_contexts_[url.origin()], url, callback); 148 origin_to_contexts_[url.origin()], url, callback);
149 } 149 }
150 150
151 void LocalFileSyncService::ClearSyncFlagForURL(
152 const fileapi::FileSystemURL& url) {
153 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
154 sync_context_->ClearSyncFlagForURL(url);
155 }
156
151 void LocalFileSyncService::GetLocalFileMetadata( 157 void LocalFileSyncService::GetLocalFileMetadata(
152 const fileapi::FileSystemURL& url, 158 const fileapi::FileSystemURL& url,
153 const SyncFileMetadataCallback& callback) { 159 const SyncFileMetadataCallback& callback) {
154 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); 160 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
155 sync_context_->GetFileMetadata(origin_to_contexts_[url.origin()], 161 sync_context_->GetFileMetadata(origin_to_contexts_[url.origin()],
156 url, callback); 162 url, callback);
157 } 163 }
158 164
159 void LocalFileSyncService::PrepareForProcessRemoteChange( 165 void LocalFileSyncService::PrepareForProcessRemoteChange(
160 const FileSystemURL& url, 166 const FileSystemURL& url,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 local_sync_callback_.Reset(); 216 local_sync_callback_.Reset();
211 callback.Run(status, url); 217 callback.Run(status, url);
212 } 218 }
213 219
214 void LocalFileSyncService::DidGetFileForLocalSync( 220 void LocalFileSyncService::DidGetFileForLocalSync(
215 LocalChangeProcessor* processor, 221 LocalChangeProcessor* processor,
216 SyncStatusCode status, 222 SyncStatusCode status,
217 const LocalFileSyncInfo& sync_file_info) { 223 const LocalFileSyncInfo& sync_file_info) {
218 DCHECK(!local_sync_callback_.is_null()); 224 DCHECK(!local_sync_callback_.is_null());
219 if (status != fileapi::SYNC_STATUS_OK) { 225 if (status != fileapi::SYNC_STATUS_OK) {
220 RunLocalSyncCallback(status, FileSystemURL()); 226 RunLocalSyncCallback(status, sync_file_info.url);
221 return; 227 return;
222 } 228 }
223 if (sync_file_info.changes.empty()) { 229 if (sync_file_info.changes.empty()) {
224 // There's a slight chance this could happen. 230 // There's a slight chance this could happen.
225 fileapi::SyncFileCallback callback = local_sync_callback_; 231 fileapi::SyncFileCallback callback = local_sync_callback_;
226 local_sync_callback_.Reset(); 232 local_sync_callback_.Reset();
227 ProcessLocalChange(processor, callback); 233 ProcessLocalChange(processor, callback);
228 return; 234 return;
229 } 235 }
230 236
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // a sync error. 271 // a sync error.
266 272
267 const FileSystemURL& url = sync_file_info.url; 273 const FileSystemURL& url = sync_file_info.url;
268 if (status != fileapi::SYNC_STATUS_OK || changes.empty()) { 274 if (status != fileapi::SYNC_STATUS_OK || changes.empty()) {
269 if (status == fileapi::SYNC_STATUS_OK || 275 if (status == fileapi::SYNC_STATUS_OK ||
270 status == fileapi::SYNC_STATUS_HAS_CONFLICT) { 276 status == fileapi::SYNC_STATUS_HAS_CONFLICT) {
271 // Clear the recorded changes for the URL if the sync was successfull 277 // Clear the recorded changes for the URL if the sync was successfull
272 // OR has failed due to conflict (so that we won't stick to the same 278 // OR has failed due to conflict (so that we won't stick to the same
273 // conflicting file again and again). 279 // conflicting file again and again).
274 DCHECK(ContainsKey(origin_to_contexts_, url.origin())); 280 DCHECK(ContainsKey(origin_to_contexts_, url.origin()));
275 sync_context_->FinalizeSyncForURL(origin_to_contexts_[url.origin()], url); 281 sync_context_->ClearChangesForURL(
282 origin_to_contexts_[url.origin()], url,
283 base::Bind(&LocalFileSyncService::RunLocalSyncCallback,
284 AsWeakPtr(), status, url));
285 return;
276 } 286 }
277 RunLocalSyncCallback(status, url); 287 RunLocalSyncCallback(status, url);
278 return; 288 return;
279 } 289 }
280 290
281 DCHECK(processor); 291 DCHECK(processor);
282 processor->ApplyLocalChange( 292 processor->ApplyLocalChange(
283 changes.front(), 293 changes.front(),
284 sync_file_info.local_file_path, 294 sync_file_info.local_file_path,
285 sync_file_info.metadata, 295 sync_file_info.metadata,
286 url, 296 url,
287 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL, 297 base::Bind(&LocalFileSyncService::ProcessNextChangeForURL,
288 AsWeakPtr(), processor, sync_file_info, 298 AsWeakPtr(), processor, sync_file_info,
289 changes.front(), changes.PopAndGetNewList())); 299 changes.front(), changes.PopAndGetNewList()));
290 } 300 }
291 301
292 } // namespace sync_file_system 302 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698