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

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

Issue 306813002: [SyncFS] Make routines using metadata database async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove needless method Created 6 years, 6 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
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 void SyncEngine::SetSyncEnabled(bool enabled) { 385 void SyncEngine::SetSyncEnabled(bool enabled) {
386 worker_task_runner_->PostTask( 386 worker_task_runner_->PostTask(
387 FROM_HERE, 387 FROM_HERE,
388 base::Bind(&SyncWorker::SetSyncEnabled, 388 base::Bind(&SyncWorker::SetSyncEnabled,
389 base::Unretained(sync_worker_.get()), 389 base::Unretained(sync_worker_.get()),
390 enabled)); 390 enabled));
391 } 391 }
392 392
393 void SyncEngine::PromoteDemotedChanges() { 393 void SyncEngine::PromoteDemotedChanges() {
394 MetadataDatabase* metadata_db = GetMetadataDatabase(); 394 worker_task_runner_->PostTask(
395 if (metadata_db && metadata_db->HasLowPriorityDirtyTracker()) { 395 FROM_HERE,
396 metadata_db->PromoteLowerPriorityTrackersToNormal(); 396 base::Bind(&SyncWorker::PromoteDemotedChanges,
397 FOR_EACH_OBSERVER( 397 base::Unretained(sync_worker_.get())));
398 Observer,
399 service_observers_,
400 OnRemoteChangeQueueUpdated(metadata_db->CountDirtyTracker()));
401 }
402 } 398 }
403 399
404 void SyncEngine::ApplyLocalChange( 400 void SyncEngine::ApplyLocalChange(
405 const FileChange& local_change, 401 const FileChange& local_change,
406 const base::FilePath& local_path, 402 const base::FilePath& local_path,
407 const SyncFileMetadata& local_metadata, 403 const SyncFileMetadata& local_metadata,
408 const fileapi::FileSystemURL& url, 404 const fileapi::FileSystemURL& url,
409 const SyncStatusCallback& callback) { 405 const SyncStatusCallback& callback) {
410 worker_task_runner_->PostTask( 406 worker_task_runner_->PostTask(
411 FROM_HERE, 407 FROM_HERE,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 456 }
461 457
462 drive::DriveServiceInterface* SyncEngine::GetDriveService() { 458 drive::DriveServiceInterface* SyncEngine::GetDriveService() {
463 return drive_service_.get(); 459 return drive_service_.get();
464 } 460 }
465 461
466 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() { 462 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() {
467 return drive_uploader_.get(); 463 return drive_uploader_.get();
468 } 464 }
469 465
470 MetadataDatabase* SyncEngine::GetMetadataDatabase() { 466 MetadataDatabase* SyncEngine::GetMetadataDatabaseForTesting() {
471 // TODO(peria): Post task
472 return sync_worker_->GetMetadataDatabase(); 467 return sync_worker_->GetMetadataDatabase();
473 } 468 }
474 469
475 SyncEngine::SyncEngine( 470 SyncEngine::SyncEngine(
476 scoped_ptr<drive::DriveServiceInterface> drive_service, 471 scoped_ptr<drive::DriveServiceInterface> drive_service,
477 scoped_ptr<drive::DriveUploaderInterface> drive_uploader, 472 scoped_ptr<drive::DriveUploaderInterface> drive_uploader,
478 base::SequencedTaskRunner* worker_task_runner, 473 base::SequencedTaskRunner* worker_task_runner,
479 drive::DriveNotificationManager* notification_manager, 474 drive::DriveNotificationManager* notification_manager,
480 ExtensionServiceInterface* extension_service, 475 ExtensionServiceInterface* extension_service,
481 SigninManagerBase* signin_manager) 476 SigninManagerBase* signin_manager)
(...skipping 27 matching lines...) Expand all
509 504
510 void SyncEngine::UpdateServiceState(RemoteServiceState state, 505 void SyncEngine::UpdateServiceState(RemoteServiceState state,
511 const std::string& description) { 506 const std::string& description) {
512 service_state_ = state; 507 service_state_ = state;
513 508
514 FOR_EACH_OBSERVER( 509 FOR_EACH_OBSERVER(
515 Observer, service_observers_, 510 Observer, service_observers_,
516 OnRemoteServiceStateUpdated(state, description)); 511 OnRemoteServiceStateUpdated(state, description));
517 } 512 }
518 513
519 void SyncEngine::UpdateRegisteredApps() { 514 void SyncEngine::UpdateRegisteredAppsForTesting() {
tzik 2014/05/30 05:23:47 Could you consolidate this to SyncWorker's one?
peria 2014/06/02 04:30:28 Done.
520 if (!extension_service_) 515 if (!extension_service_)
521 return; 516 return;
522 517
523 MetadataDatabase* metadata_db = GetMetadataDatabase(); 518 MetadataDatabase* metadata_db = GetMetadataDatabaseForTesting();
524 DCHECK(metadata_db); 519 DCHECK(metadata_db);
525 std::vector<std::string> app_ids; 520 std::vector<std::string> app_ids;
526 metadata_db->GetRegisteredAppIDs(&app_ids); 521 metadata_db->GetRegisteredAppIDs(&app_ids);
527 522
528 // Update the status of every origin using status from ExtensionService. 523 // Update the status of every origin using status from ExtensionService.
529 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); 524 for (std::vector<std::string>::const_iterator itr = app_ids.begin();
530 itr != app_ids.end(); ++itr) { 525 itr != app_ids.end(); ++itr) {
531 const std::string& app_id = *itr; 526 const std::string& app_id = *itr;
532 GURL origin = 527 GURL origin =
533 extensions::Extension::GetBaseURLFromExtensionId(app_id); 528 extensions::Extension::GetBaseURLFromExtensionId(app_id);
(...skipping 16 matching lines...) Expand all
550 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 545 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
551 if (is_app_enabled && !is_app_root_tracker_enabled) 546 if (is_app_enabled && !is_app_root_tracker_enabled)
552 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 547 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
553 else if (!is_app_enabled && is_app_root_tracker_enabled) 548 else if (!is_app_enabled && is_app_root_tracker_enabled)
554 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 549 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
555 } 550 }
556 } 551 }
557 552
558 } // namespace drive_backend 553 } // namespace drive_backend
559 } // namespace sync_file_system 554 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698