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

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

Issue 11316270: SyncFileSystem: Register origin only after the local-side initialization finishes successfully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | 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/sync_file_system_service.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 DVLOG(1) << "InitializeForApp: " << app_origin.spec(); 152 DVLOG(1) << "InitializeForApp: " << app_origin.spec();
153 153
154 if (initialized_app_origins_.find(app_origin) != 154 if (initialized_app_origins_.find(app_origin) !=
155 initialized_app_origins_.end()) { 155 initialized_app_origins_.end()) {
156 DVLOG(1) << "The app is already initialized: " << app_origin.spec(); 156 DVLOG(1) << "The app is already initialized: " << app_origin.spec();
157 callback.Run(fileapi::SYNC_STATUS_OK); 157 callback.Run(fileapi::SYNC_STATUS_OK);
158 return; 158 return;
159 } 159 }
160 160
161 scoped_refptr<SharedCallbackRunner> callback_runner(
162 new SharedCallbackRunner(callback));
163
164 local_file_service_->MaybeInitializeFileSystemContext( 161 local_file_service_->MaybeInitializeFileSystemContext(
165 app_origin, service_name, file_system_context, 162 app_origin, service_name, file_system_context,
166 callback_runner->CreateCallback()); 163 base::Bind(&SyncFileSystemService::DidInitializeFileSystem,
167 remote_file_service_->RegisterOriginForTrackingChanges( 164 AsWeakPtr(), app_origin, callback));
168 app_origin,
169 base::Bind(&SyncFileSystemService::DidRegisterOrigin,
170 AsWeakPtr(), app_origin,
171 callback_runner->CreateCallback()));
172 } 165 }
173 166
174 void SyncFileSystemService::GetConflictFiles( 167 void SyncFileSystemService::GetConflictFiles(
175 const GURL& app_origin, 168 const GURL& app_origin,
176 const std::string& service_name, 169 const std::string& service_name,
177 const fileapi::SyncFileSetCallback& callback) { 170 const fileapi::SyncFileSetCallback& callback) {
178 DCHECK(remote_file_service_); 171 DCHECK(remote_file_service_);
179 DCHECK(app_origin == app_origin.GetOrigin()); 172 DCHECK(app_origin == app_origin.GetOrigin());
180 173
181 if (!ContainsKey(initialized_app_origins_, app_origin)) { 174 if (!ContainsKey(initialized_app_origins_, app_origin)) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 SyncStatusCode status) { 256 SyncStatusCode status) {
264 DCHECK(local_metadata); 257 DCHECK(local_metadata);
265 DCHECK(remote_metadata); 258 DCHECK(remote_metadata);
266 fileapi::ConflictFileInfo info; 259 fileapi::ConflictFileInfo info;
267 info.url = url; 260 info.url = url;
268 info.local_metadata = *local_metadata; 261 info.local_metadata = *local_metadata;
269 info.remote_metadata = *remote_metadata; 262 info.remote_metadata = *remote_metadata;
270 callback.Run(status, info); 263 callback.Run(status, info);
271 } 264 }
272 265
266 void SyncFileSystemService::DidInitializeFileSystem(
267 const GURL& app_origin,
268 const fileapi::SyncStatusCallback& callback,
269 fileapi::SyncStatusCode status) {
270 DVLOG(1) << "DidInitializeFileSystem: " << app_origin.spec() << " " << status;
271
272 if (status != fileapi::SYNC_STATUS_OK) {
273 callback.Run(status);
274 return;
275 }
276
277 // Local side of initialization for the app is done.
278 // Continue on initializing the remote side.
279 remote_file_service_->RegisterOriginForTrackingChanges(
280 app_origin,
281 base::Bind(&SyncFileSystemService::DidRegisterOrigin,
282 AsWeakPtr(), app_origin, callback));
283 }
284
273 void SyncFileSystemService::DidRegisterOrigin( 285 void SyncFileSystemService::DidRegisterOrigin(
274 const GURL& app_origin, 286 const GURL& app_origin,
275 const fileapi::SyncStatusCallback& callback, 287 const fileapi::SyncStatusCallback& callback,
276 fileapi::SyncStatusCode status) { 288 fileapi::SyncStatusCode status) {
277 DVLOG(1) << "DidRegisterOrigin: " << app_origin.spec() << " " << status; 289 DVLOG(1) << "DidRegisterOrigin: " << app_origin.spec() << " " << status;
278 290
279 if (status == fileapi::SYNC_STATUS_OK) 291 if (status == fileapi::SYNC_STATUS_OK)
280 initialized_app_origins_.insert(app_origin); 292 initialized_app_origins_.insert(app_origin);
281 293
282 callback.Run(status); 294 callback.Run(status);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 remote_file_service = mock_remote_file_service_.Pass(); 484 remote_file_service = mock_remote_file_service_.Pass();
473 else 485 else
474 remote_file_service.reset(new DriveFileSyncService(profile)); 486 remote_file_service.reset(new DriveFileSyncService(profile));
475 487
476 service->Initialize(local_file_service.Pass(), 488 service->Initialize(local_file_service.Pass(),
477 remote_file_service.Pass()); 489 remote_file_service.Pass());
478 return service; 490 return service;
479 } 491 }
480 492
481 } // namespace sync_file_system 493 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698