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

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: Rebase 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 void SyncEngine::SetSyncEnabled(bool enabled) { 388 void SyncEngine::SetSyncEnabled(bool enabled) {
389 worker_task_runner_->PostTask( 389 worker_task_runner_->PostTask(
390 FROM_HERE, 390 FROM_HERE,
391 base::Bind(&SyncWorker::SetSyncEnabled, 391 base::Bind(&SyncWorker::SetSyncEnabled,
392 base::Unretained(sync_worker_.get()), 392 base::Unretained(sync_worker_.get()),
393 enabled)); 393 enabled));
394 } 394 }
395 395
396 void SyncEngine::PromoteDemotedChanges() { 396 void SyncEngine::PromoteDemotedChanges() {
397 MetadataDatabase* metadata_db = GetMetadataDatabase(); 397 worker_task_runner_->PostTask(
398 if (metadata_db && metadata_db->HasLowPriorityDirtyTracker()) { 398 FROM_HERE,
399 metadata_db->PromoteLowerPriorityTrackersToNormal(); 399 base::Bind(&SyncWorker::PromoteDemotedChanges,
400 FOR_EACH_OBSERVER( 400 base::Unretained(sync_worker_.get())));
401 Observer,
402 service_observers_,
403 OnRemoteChangeQueueUpdated(metadata_db->CountDirtyTracker()));
404 }
405 } 401 }
406 402
407 void SyncEngine::ApplyLocalChange( 403 void SyncEngine::ApplyLocalChange(
408 const FileChange& local_change, 404 const FileChange& local_change,
409 const base::FilePath& local_path, 405 const base::FilePath& local_path,
410 const SyncFileMetadata& local_metadata, 406 const SyncFileMetadata& local_metadata,
411 const fileapi::FileSystemURL& url, 407 const fileapi::FileSystemURL& url,
412 const SyncStatusCallback& callback) { 408 const SyncStatusCallback& callback) {
413 worker_task_runner_->PostTask( 409 worker_task_runner_->PostTask(
414 FROM_HERE, 410 FROM_HERE,
415 base::Bind(&SyncWorker::ApplyLocalChange, 411 base::Bind(&SyncWorker::ApplyLocalChange,
416 base::Unretained(sync_worker_.get()), 412 base::Unretained(sync_worker_.get()),
417 local_change, 413 local_change,
418 local_path, 414 local_path,
419 local_metadata, 415 local_metadata,
420 url, 416 url,
421 RelayCallbackToCurrentThread( 417 RelayCallbackToCurrentThread(
422 FROM_HERE, callback))); 418 FROM_HERE, callback)));
423 } 419 }
424 420
425 SyncTaskManager* SyncEngine::GetSyncTaskManagerForTesting() {
426 return sync_worker_->GetSyncTaskManager();
427 }
428
429 void SyncEngine::OnNotificationReceived() { 421 void SyncEngine::OnNotificationReceived() {
430 worker_task_runner_->PostTask( 422 worker_task_runner_->PostTask(
431 FROM_HERE, 423 FROM_HERE,
432 base::Bind(&SyncWorker::OnNotificationReceived, 424 base::Bind(&SyncWorker::OnNotificationReceived,
433 base::Unretained(sync_worker_.get()))); 425 base::Unretained(sync_worker_.get())));
434 } 426 }
435 427
436 void SyncEngine::OnPushNotificationEnabled(bool) {} 428 void SyncEngine::OnPushNotificationEnabled(bool) {}
437 429
438 void SyncEngine::OnReadyToSendRequests() { 430 void SyncEngine::OnReadyToSendRequests() {
(...skipping 24 matching lines...) Expand all
463 } 455 }
464 456
465 drive::DriveServiceInterface* SyncEngine::GetDriveService() { 457 drive::DriveServiceInterface* SyncEngine::GetDriveService() {
466 return drive_service_.get(); 458 return drive_service_.get();
467 } 459 }
468 460
469 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() { 461 drive::DriveUploaderInterface* SyncEngine::GetDriveUploader() {
470 return drive_uploader_.get(); 462 return drive_uploader_.get();
471 } 463 }
472 464
473 MetadataDatabase* SyncEngine::GetMetadataDatabase() {
474 // TODO(peria): Post task
475 return sync_worker_->GetMetadataDatabase();
476 }
477
478 SyncEngine::SyncEngine( 465 SyncEngine::SyncEngine(
479 scoped_ptr<drive::DriveServiceInterface> drive_service, 466 scoped_ptr<drive::DriveServiceInterface> drive_service,
480 scoped_ptr<drive::DriveUploaderInterface> drive_uploader, 467 scoped_ptr<drive::DriveUploaderInterface> drive_uploader,
481 base::SequencedTaskRunner* worker_task_runner, 468 base::SequencedTaskRunner* worker_task_runner,
482 drive::DriveNotificationManager* notification_manager, 469 drive::DriveNotificationManager* notification_manager,
483 ExtensionServiceInterface* extension_service, 470 ExtensionServiceInterface* extension_service,
484 SigninManagerBase* signin_manager) 471 SigninManagerBase* signin_manager)
485 : drive_service_(drive_service.Pass()), 472 : drive_service_(drive_service.Pass()),
486 drive_service_wrapper_(new DriveServiceWrapper(drive_service_.get())), 473 drive_service_wrapper_(new DriveServiceWrapper(drive_service_.get())),
487 drive_uploader_(drive_uploader.Pass()), 474 drive_uploader_(drive_uploader.Pass()),
(...skipping 24 matching lines...) Expand all
512 499
513 void SyncEngine::UpdateServiceState(RemoteServiceState state, 500 void SyncEngine::UpdateServiceState(RemoteServiceState state,
514 const std::string& description) { 501 const std::string& description) {
515 service_state_ = state; 502 service_state_ = state;
516 503
517 FOR_EACH_OBSERVER( 504 FOR_EACH_OBSERVER(
518 Observer, service_observers_, 505 Observer, service_observers_,
519 OnRemoteServiceStateUpdated(state, description)); 506 OnRemoteServiceStateUpdated(state, description));
520 } 507 }
521 508
522 void SyncEngine::UpdateRegisteredApps() { 509 void SyncEngine::UpdateRegisteredAppsForTesting() {
523 if (!extension_service_) 510 if (!extension_service_)
524 return; 511 return;
525 512
526 MetadataDatabase* metadata_db = GetMetadataDatabase(); 513 MetadataDatabase* metadata_db = sync_worker_->GetMetadataDatabase();
527 DCHECK(metadata_db); 514 DCHECK(metadata_db);
528 std::vector<std::string> app_ids; 515 std::vector<std::string> app_ids;
529 metadata_db->GetRegisteredAppIDs(&app_ids); 516 metadata_db->GetRegisteredAppIDs(&app_ids);
530 517
531 // Update the status of every origin using status from ExtensionService. 518 // Update the status of every origin using status from ExtensionService.
532 for (std::vector<std::string>::const_iterator itr = app_ids.begin(); 519 for (std::vector<std::string>::const_iterator itr = app_ids.begin();
533 itr != app_ids.end(); ++itr) { 520 itr != app_ids.end(); ++itr) {
534 const std::string& app_id = *itr; 521 const std::string& app_id = *itr;
535 GURL origin = 522 GURL origin =
536 extensions::Extension::GetBaseURLFromExtensionId(app_id); 523 extensions::Extension::GetBaseURLFromExtensionId(app_id);
(...skipping 16 matching lines...) Expand all
553 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT; 540 tracker.tracker_kind() == TRACKER_KIND_APP_ROOT;
554 if (is_app_enabled && !is_app_root_tracker_enabled) 541 if (is_app_enabled && !is_app_root_tracker_enabled)
555 EnableOrigin(origin, base::Bind(&EmptyStatusCallback)); 542 EnableOrigin(origin, base::Bind(&EmptyStatusCallback));
556 else if (!is_app_enabled && is_app_root_tracker_enabled) 543 else if (!is_app_enabled && is_app_root_tracker_enabled)
557 DisableOrigin(origin, base::Bind(&EmptyStatusCallback)); 544 DisableOrigin(origin, base::Bind(&EmptyStatusCallback));
558 } 545 }
559 } 546 }
560 547
561 } // namespace drive_backend 548 } // namespace drive_backend
562 } // namespace sync_file_system 549 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698