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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_worker.cc

Issue 558603002: [SyncFS] Make MetadataDatabase operations synchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_create
Patch Set: +TODO Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_backend/sync_worker.h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_worker.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/browser/drive/drive_service_interface.h" 10 #include "chrome/browser/drive/drive_service_interface.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 333
334 void SyncWorker::AddObserver(Observer* observer) { 334 void SyncWorker::AddObserver(Observer* observer) {
335 observers_.AddObserver(observer); 335 observers_.AddObserver(observer);
336 } 336 }
337 337
338 void SyncWorker::DoDisableApp(const std::string& app_id, 338 void SyncWorker::DoDisableApp(const std::string& app_id,
339 const SyncStatusCallback& callback) { 339 const SyncStatusCallback& callback) {
340 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 340 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
341 341
342 if (GetMetadataDatabase()) { 342 if (!GetMetadataDatabase()) {
343 GetMetadataDatabase()->DisableApp(app_id, callback);
344 } else {
345 callback.Run(SYNC_STATUS_OK); 343 callback.Run(SYNC_STATUS_OK);
344 return;
346 } 345 }
346
347 SyncStatusCode status = GetMetadataDatabase()->DisableApp(app_id);
348 callback.Run(status);
347 } 349 }
348 350
349 void SyncWorker::DoEnableApp(const std::string& app_id, 351 void SyncWorker::DoEnableApp(const std::string& app_id,
350 const SyncStatusCallback& callback) { 352 const SyncStatusCallback& callback) {
351 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 353 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
352 354
353 if (GetMetadataDatabase()) { 355 if (!GetMetadataDatabase()) {
354 GetMetadataDatabase()->EnableApp(app_id, callback);
355 } else {
356 callback.Run(SYNC_STATUS_OK); 356 callback.Run(SYNC_STATUS_OK);
357 return;
357 } 358 }
359
360 SyncStatusCode status = GetMetadataDatabase()->EnableApp(app_id);
361 callback.Run(status);
358 } 362 }
359 363
360 void SyncWorker::PostInitializeTask() { 364 void SyncWorker::PostInitializeTask() {
361 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 365 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
362 DCHECK(!GetMetadataDatabase()); 366 DCHECK(!GetMetadataDatabase());
363 367
364 // This initializer task may not run if MetadataDatabase in context_ is 368 // This initializer task may not run if MetadataDatabase in context_ is
365 // already initialized when it runs. 369 // already initialized when it runs.
366 SyncEngineInitializer* initializer = 370 SyncEngineInitializer* initializer =
367 new SyncEngineInitializer(context_.get(), 371 new SyncEngineInitializer(context_.get(),
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 return context_->GetDriveUploader(); 715 return context_->GetDriveUploader();
712 } 716 }
713 717
714 MetadataDatabase* SyncWorker::GetMetadataDatabase() { 718 MetadataDatabase* SyncWorker::GetMetadataDatabase() {
715 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 719 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
716 return context_->GetMetadataDatabase(); 720 return context_->GetMetadataDatabase();
717 } 721 }
718 722
719 } // namespace drive_backend 723 } // namespace drive_backend
720 } // namespace sync_file_system 724 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698