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

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

Issue 166153002: [SyncFS] Check MetadataDatabase availability before database operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_engine.h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/drive/drive_api_service.h" 10 #include "chrome/browser/drive/drive_api_service.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 void SyncEngine::DownloadRemoteVersion( 284 void SyncEngine::DownloadRemoteVersion(
285 const fileapi::FileSystemURL& url, 285 const fileapi::FileSystemURL& url,
286 const std::string& version_id, 286 const std::string& version_id,
287 const DownloadVersionCallback& callback) { 287 const DownloadVersionCallback& callback) {
288 // TODO(tzik): Implement this before we support manual conflict resolution. 288 // TODO(tzik): Implement this before we support manual conflict resolution.
289 callback.Run(SYNC_STATUS_FAILED, webkit_blob::ScopedFile()); 289 callback.Run(SYNC_STATUS_FAILED, webkit_blob::ScopedFile());
290 } 290 }
291 291
292 void SyncEngine::PromoteDemotedChanges() { 292 void SyncEngine::PromoteDemotedChanges() {
293 metadata_database_->PromoteLowerPriorityTrackersToNormal(); 293 if (metadata_database_)
294 metadata_database_->PromoteLowerPriorityTrackersToNormal();
294 } 295 }
295 296
296 void SyncEngine::ApplyLocalChange( 297 void SyncEngine::ApplyLocalChange(
297 const FileChange& local_change, 298 const FileChange& local_change,
298 const base::FilePath& local_path, 299 const base::FilePath& local_path,
299 const SyncFileMetadata& local_metadata, 300 const SyncFileMetadata& local_metadata,
300 const fileapi::FileSystemURL& url, 301 const fileapi::FileSystemURL& url,
301 const SyncStatusCallback& callback) { 302 const SyncStatusCallback& callback) {
302 LocalToRemoteSyncer* syncer = new LocalToRemoteSyncer( 303 LocalToRemoteSyncer* syncer = new LocalToRemoteSyncer(
303 this, local_metadata, local_change, local_path, url); 304 this, local_metadata, local_change, local_path, url);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 should_check_remote_change_(true), 422 should_check_remote_change_(true),
422 listing_remote_changes_(false), 423 listing_remote_changes_(false),
423 sync_enabled_(false), 424 sync_enabled_(false),
424 conflict_resolution_policy_(CONFLICT_RESOLUTION_POLICY_LAST_WRITE_WIN), 425 conflict_resolution_policy_(CONFLICT_RESOLUTION_POLICY_LAST_WRITE_WIN),
425 network_available_(false), 426 network_available_(false),
426 weak_ptr_factory_(this) { 427 weak_ptr_factory_(this) {
427 } 428 }
428 429
429 void SyncEngine::DoDisableApp(const std::string& app_id, 430 void SyncEngine::DoDisableApp(const std::string& app_id,
430 const SyncStatusCallback& callback) { 431 const SyncStatusCallback& callback) {
431 metadata_database_->DisableApp(app_id, callback); 432 if (metadata_database_)
433 metadata_database_->DisableApp(app_id, callback);
434 else
435 callback.Run(SYNC_STATUS_OK);
432 } 436 }
433 437
434 void SyncEngine::DoEnableApp(const std::string& app_id, 438 void SyncEngine::DoEnableApp(const std::string& app_id,
435 const SyncStatusCallback& callback) { 439 const SyncStatusCallback& callback) {
436 metadata_database_->EnableApp(app_id, callback); 440 if (metadata_database_)
441 metadata_database_->EnableApp(app_id, callback);
442 else
443 callback.Run(SYNC_STATUS_OK);
437 } 444 }
438 445
439 void SyncEngine::PostInitializeTask() { 446 void SyncEngine::PostInitializeTask() {
440 DCHECK(!metadata_database_); 447 DCHECK(!metadata_database_);
441 448
442 // This initializer task may not run if metadata_database_ is already 449 // This initializer task may not run if metadata_database_ is already
443 // initialized when it runs. 450 // initialized when it runs.
444 SyncEngineInitializer* initializer = 451 SyncEngineInitializer* initializer =
445 new SyncEngineInitializer(this, 452 new SyncEngineInitializer(this,
446 task_runner_.get(), 453 task_runner_.get(),
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 706 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
700 if (is_app_enabled && !is_app_root_tracker_enabled) 707 if (is_app_enabled && !is_app_root_tracker_enabled)
701 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 708 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
702 else if (!is_app_enabled && is_app_root_tracker_enabled) 709 else if (!is_app_enabled && is_app_root_tracker_enabled)
703 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 710 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
704 } 711 }
705 } 712 }
706 713
707 } // namespace drive_backend 714 } // namespace drive_backend
708 } // namespace sync_file_system 715 } // 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