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

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: Add a note comment 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,
412 base::Bind(&SyncWorker::ApplyLocalChange, 408 base::Bind(&SyncWorker::ApplyLocalChange,
413 base::Unretained(sync_worker_.get()), 409 base::Unretained(sync_worker_.get()),
414 local_change, 410 local_change,
415 local_path, 411 local_path,
416 local_metadata, 412 local_metadata,
417 url, 413 url,
418 RelayCallbackToCurrentThread( 414 RelayCallbackToCurrentThread(
419 FROM_HERE, callback))); 415 FROM_HERE, callback)));
420 } 416 }
421 417
422 SyncTaskManager* SyncEngine::GetSyncTaskManagerForTesting() {
423 return sync_worker_->GetSyncTaskManager();
424 }
425
426 void SyncEngine::OnNotificationReceived() { 418 void SyncEngine::OnNotificationReceived() {
427 worker_task_runner_->PostTask( 419 worker_task_runner_->PostTask(
428 FROM_HERE, 420 FROM_HERE,
429 base::Bind(&SyncWorker::OnNotificationReceived, 421 base::Bind(&SyncWorker::OnNotificationReceived,
430 base::Unretained(sync_worker_.get()))); 422 base::Unretained(sync_worker_.get())));
431 } 423 }
432 424
433 void SyncEngine::OnPushNotificationEnabled(bool) {} 425 void SyncEngine::OnPushNotificationEnabled(bool) {}
434 426
435 void SyncEngine::OnReadyToSendRequests() { 427 void SyncEngine::OnReadyToSendRequests() {
(...skipping 24 matching lines...) Expand all
460 } 452 }
461 453
462 drive::DriveServiceInterface* SyncEngine::GetDriveService() { 454 drive::DriveServiceInterface* SyncEngine::GetDriveService() {
463 return drive_service_.get(); 455 return drive_service_.get();
464 } 456 }
465 457
466 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() { 458 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() {
467 return drive_uploader_.get(); 459 return drive_uploader_.get();
468 } 460 }
469 461
470 MetadataDatabase* SyncEngine::GetMetadataDatabase() {
471 // TODO(peria): Post task
472 return sync_worker_->GetMetadataDatabase();
473 }
474
475 SyncEngine::SyncEngine( 462 SyncEngine::SyncEngine(
476 scoped_ptr<drive::DriveServiceInterface> drive_service, 463 scoped_ptr<drive::DriveServiceInterface> drive_service,
477 scoped_ptr<drive::DriveUploaderInterface> drive_uploader, 464 scoped_ptr<drive::DriveUploaderInterface> drive_uploader,
478 base::SequencedTaskRunner* worker_task_runner, 465 base::SequencedTaskRunner* worker_task_runner,
479 drive::DriveNotificationManager* notification_manager, 466 drive::DriveNotificationManager* notification_manager,
480 ExtensionServiceInterface* extension_service, 467 ExtensionServiceInterface* extension_service,
481 SigninManagerBase* signin_manager) 468 SigninManagerBase* signin_manager)
482 : drive_service_(drive_service.Pass()), 469 : drive_service_(drive_service.Pass()),
483 drive_service_wrapper_(new DriveServiceWrapper(drive_service_.get())), 470 drive_service_wrapper_(new DriveServiceWrapper(drive_service_.get())),
484 drive_uploader_(drive_uploader.Pass()), 471 drive_uploader_(drive_uploader.Pass()),
(...skipping 24 matching lines...) Expand all
509 496
510 void SyncEngine::UpdateServiceState(RemoteServiceState state, 497 void SyncEngine::UpdateServiceState(RemoteServiceState state,
511 const std::string& description) { 498 const std::string& description) {
512 service_state_ = state; 499 service_state_ = state;
513 500
514 FOR_EACH_OBSERVER( 501 FOR_EACH_OBSERVER(
515 Observer, service_observers_, 502 Observer, service_observers_,
516 OnRemoteServiceStateUpdated(state, description)); 503 OnRemoteServiceStateUpdated(state, description));
517 } 504 }
518 505
519 void SyncEngine::UpdateRegisteredApps() { 506 void SyncEngine::UpdateRegisteredAppsForTesting() {
520 if (!extension_service_) 507 if (!extension_service_)
521 return; 508 return;
522 509
523 MetadataDatabase* metadata_db = GetMetadataDatabase(); 510 MetadataDatabase* metadata_db = sync_worker_->GetMetadataDatabase();
524 DCHECK(metadata_db); 511 DCHECK(metadata_db);
525 std::vector<std::string> app_ids; 512 std::vector<std::string> app_ids;
526 metadata_db->GetRegisteredAppIDs(&app_ids); 513 metadata_db->GetRegisteredAppIDs(&app_ids);
527 514
528 // Update the status of every origin using status from ExtensionService. 515 // Update the status of every origin using status from ExtensionService.
529 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); 516 for (std::vector<std::string>::const_iterator itr = app_ids.begin();
530 itr != app_ids.end(); ++itr) { 517 itr != app_ids.end(); ++itr) {
531 const std::string& app_id = *itr; 518 const std::string& app_id = *itr;
532 GURL origin = 519 GURL origin =
533 extensions::Extension::GetBaseURLFromExtensionId(app_id); 520 extensions::Extension::GetBaseURLFromExtensionId(app_id);
(...skipping 16 matching lines...) Expand all
550 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 537 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
551 if (is_app_enabled && !is_app_root_tracker_enabled) 538 if (is_app_enabled && !is_app_root_tracker_enabled)
552 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 539 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
553 else if (!is_app_enabled && is_app_root_tracker_enabled) 540 else if (!is_app_enabled && is_app_root_tracker_enabled)
554 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 541 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
555 } 542 }
556 } 543 }
557 544
558 } // namespace drive_backend 545 } // namespace drive_backend
559 } // namespace sync_file_system 546 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698