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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync_file_system_service.h" 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 DCHECK_CURRENTLY_ON(BrowserThread::UI); 260 DCHECK_CURRENTLY_ON(BrowserThread::UI);
261 261
262 local_sync_runners_.clear(); 262 local_sync_runners_.clear();
263 remote_sync_runners_.clear(); 263 remote_sync_runners_.clear();
264 264
265 local_service_->Shutdown(); 265 local_service_->Shutdown();
266 local_service_.reset(); 266 local_service_.reset();
267 267
268 remote_service_.reset(); 268 remote_service_.reset();
269 269
270 sync_driver::SyncService* profile_sync_service = 270 syncer::SyncService* profile_sync_service =
271 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); 271 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
272 if (profile_sync_service) 272 if (profile_sync_service)
273 profile_sync_service->RemoveObserver(this); 273 profile_sync_service->RemoveObserver(this);
274 274
275 ExtensionRegistry::Get(profile_)->RemoveObserver(this); 275 ExtensionRegistry::Get(profile_)->RemoveObserver(this);
276 276
277 profile_ = nullptr; 277 profile_ = nullptr;
278 } 278 }
279 279
280 SyncFileSystemService::~SyncFileSystemService() { 280 SyncFileSystemService::~SyncFileSystemService() {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 local_service_->SetLocalChangeProcessorCallback( 469 local_service_->SetLocalChangeProcessorCallback(
470 base::Bind(&GetLocalChangeProcessorAdapter, AsWeakPtr())); 470 base::Bind(&GetLocalChangeProcessorAdapter, AsWeakPtr()));
471 471
472 remote_service_->AddServiceObserver(remote_syncer.get()); 472 remote_service_->AddServiceObserver(remote_syncer.get());
473 remote_service_->AddFileStatusObserver(this); 473 remote_service_->AddFileStatusObserver(this);
474 remote_service_->SetRemoteChangeProcessor(local_service_.get()); 474 remote_service_->SetRemoteChangeProcessor(local_service_.get());
475 475
476 local_sync_runners_.push_back(local_syncer.release()); 476 local_sync_runners_.push_back(local_syncer.release());
477 remote_sync_runners_.push_back(remote_syncer.release()); 477 remote_sync_runners_.push_back(remote_syncer.release());
478 478
479 sync_driver::SyncService* profile_sync_service = 479 syncer::SyncService* profile_sync_service =
480 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); 480 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
481 if (profile_sync_service) { 481 if (profile_sync_service) {
482 UpdateSyncEnabledStatus(profile_sync_service); 482 UpdateSyncEnabledStatus(profile_sync_service);
483 profile_sync_service->AddObserver(this); 483 profile_sync_service->AddObserver(this);
484 } 484 }
485 485
486 ExtensionRegistry::Get(profile_)->AddObserver(this); 486 ExtensionRegistry::Get(profile_)->AddObserver(this);
487 } 487 }
488 488
489 void SyncFileSystemService::DidInitializeFileSystem( 489 void SyncFileSystemService::DidInitializeFileSystem(
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 const Extension* extension) { 723 const Extension* extension) {
724 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id()); 724 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id());
725 DVLOG(1) << "Handle extension notification for LOADED: " << app_origin; 725 DVLOG(1) << "Handle extension notification for LOADED: " << app_origin;
726 remote_service_->EnableOrigin( 726 remote_service_->EnableOrigin(
727 app_origin, 727 app_origin,
728 base::Bind(&DidHandleLoadEvent, app_origin)); 728 base::Bind(&DidHandleLoadEvent, app_origin));
729 local_service_->SetOriginEnabled(app_origin, true); 729 local_service_->SetOriginEnabled(app_origin, true);
730 } 730 }
731 731
732 void SyncFileSystemService::OnStateChanged() { 732 void SyncFileSystemService::OnStateChanged() {
733 sync_driver::SyncService* profile_sync_service = 733 syncer::SyncService* profile_sync_service =
734 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); 734 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
735 if (profile_sync_service) 735 if (profile_sync_service)
736 UpdateSyncEnabledStatus(profile_sync_service); 736 UpdateSyncEnabledStatus(profile_sync_service);
737 } 737 }
738 738
739 void SyncFileSystemService::OnFileStatusChanged( 739 void SyncFileSystemService::OnFileStatusChanged(
740 const FileSystemURL& url, 740 const FileSystemURL& url,
741 SyncFileType file_type, 741 SyncFileType file_type,
742 SyncFileStatus sync_status, 742 SyncFileStatus sync_status,
743 SyncAction action_taken, 743 SyncAction action_taken,
744 SyncDirection direction) { 744 SyncDirection direction) {
745 FOR_EACH_OBSERVER( 745 FOR_EACH_OBSERVER(
746 SyncEventObserver, observers_, 746 SyncEventObserver, observers_,
747 OnFileSynced(url, file_type, sync_status, action_taken, direction)); 747 OnFileSynced(url, file_type, sync_status, action_taken, direction));
748 } 748 }
749 749
750 void SyncFileSystemService::UpdateSyncEnabledStatus( 750 void SyncFileSystemService::UpdateSyncEnabledStatus(
751 sync_driver::SyncService* profile_sync_service) { 751 syncer::SyncService* profile_sync_service) {
752 if (!profile_sync_service->IsFirstSetupComplete()) 752 if (!profile_sync_service->IsFirstSetupComplete())
753 return; 753 return;
754 bool old_sync_enabled = sync_enabled_; 754 bool old_sync_enabled = sync_enabled_;
755 sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has( 755 sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has(
756 syncer::APPS); 756 syncer::APPS);
757 remote_service_->SetSyncEnabled(sync_enabled_); 757 remote_service_->SetSyncEnabled(sync_enabled_);
758 if (!old_sync_enabled && sync_enabled_) 758 if (!old_sync_enabled && sync_enabled_)
759 RunForEachSyncRunners(&SyncProcessRunner::Schedule); 759 RunForEachSyncRunners(&SyncProcessRunner::Schedule);
760 } 760 }
761 761
762 void SyncFileSystemService::RunForEachSyncRunners( 762 void SyncFileSystemService::RunForEachSyncRunners(
763 void(SyncProcessRunner::*method)()) { 763 void(SyncProcessRunner::*method)()) {
764 for (ScopedVector<SyncProcessRunner>::iterator iter = 764 for (ScopedVector<SyncProcessRunner>::iterator iter =
765 local_sync_runners_.begin(); 765 local_sync_runners_.begin();
766 iter != local_sync_runners_.end(); ++iter) 766 iter != local_sync_runners_.end(); ++iter)
767 ((*iter)->*method)(); 767 ((*iter)->*method)();
768 for (ScopedVector<SyncProcessRunner>::iterator iter = 768 for (ScopedVector<SyncProcessRunner>::iterator iter =
769 remote_sync_runners_.begin(); 769 remote_sync_runners_.begin();
770 iter != remote_sync_runners_.end(); ++iter) 770 iter != remote_sync_runners_.end(); ++iter)
771 ((*iter)->*method)(); 771 ((*iter)->*method)();
772 } 772 }
773 773
774 } // namespace sync_file_system 774 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698