| OLD | NEW |
| 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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 SYNC_FILE_STATUS_HAS_PENDING_CHANGES : SYNC_FILE_STATUS_SYNCED); | 639 SYNC_FILE_STATUS_HAS_PENDING_CHANGES : SYNC_FILE_STATUS_SYNCED); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void SyncFileSystemService::OnRemoteServiceStateUpdated( | 642 void SyncFileSystemService::OnRemoteServiceStateUpdated( |
| 643 RemoteServiceState state, | 643 RemoteServiceState state, |
| 644 const std::string& description) { | 644 const std::string& description) { |
| 645 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 645 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 646 util::Log(logging::LOG_VERBOSE, FROM_HERE, | 646 util::Log(logging::LOG_VERBOSE, FROM_HERE, |
| 647 "OnRemoteServiceStateChanged: %d %s", state, description.c_str()); | 647 "OnRemoteServiceStateChanged: %d %s", state, description.c_str()); |
| 648 | 648 |
| 649 FOR_EACH_OBSERVER( | 649 for (auto& observer : observers_) { |
| 650 SyncEventObserver, observers_, | 650 observer.OnSyncStateUpdated(GURL(), RemoteStateToSyncServiceState(state), |
| 651 OnSyncStateUpdated(GURL(), | 651 description); |
| 652 RemoteStateToSyncServiceState(state), | 652 } |
| 653 description)); | |
| 654 | 653 |
| 655 RunForEachSyncRunners(&SyncProcessRunner::Schedule); | 654 RunForEachSyncRunners(&SyncProcessRunner::Schedule); |
| 656 } | 655 } |
| 657 | 656 |
| 658 void SyncFileSystemService::OnExtensionInstalled( | 657 void SyncFileSystemService::OnExtensionInstalled( |
| 659 content::BrowserContext* browser_context, | 658 content::BrowserContext* browser_context, |
| 660 const Extension* extension, | 659 const Extension* extension, |
| 661 bool is_update) { | 660 bool is_update) { |
| 662 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id()); | 661 GURL app_origin = Extension::GetBaseURLFromExtensionId(extension->id()); |
| 663 DVLOG(1) << "Handle extension notification for INSTALLED: " << app_origin; | 662 DVLOG(1) << "Handle extension notification for INSTALLED: " << app_origin; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 if (profile_sync_service) | 734 if (profile_sync_service) |
| 736 UpdateSyncEnabledStatus(profile_sync_service); | 735 UpdateSyncEnabledStatus(profile_sync_service); |
| 737 } | 736 } |
| 738 | 737 |
| 739 void SyncFileSystemService::OnFileStatusChanged( | 738 void SyncFileSystemService::OnFileStatusChanged( |
| 740 const FileSystemURL& url, | 739 const FileSystemURL& url, |
| 741 SyncFileType file_type, | 740 SyncFileType file_type, |
| 742 SyncFileStatus sync_status, | 741 SyncFileStatus sync_status, |
| 743 SyncAction action_taken, | 742 SyncAction action_taken, |
| 744 SyncDirection direction) { | 743 SyncDirection direction) { |
| 745 FOR_EACH_OBSERVER( | 744 for (auto& observer : observers_) |
| 746 SyncEventObserver, observers_, | 745 observer.OnFileSynced(url, file_type, sync_status, action_taken, direction); |
| 747 OnFileSynced(url, file_type, sync_status, action_taken, direction)); | |
| 748 } | 746 } |
| 749 | 747 |
| 750 void SyncFileSystemService::UpdateSyncEnabledStatus( | 748 void SyncFileSystemService::UpdateSyncEnabledStatus( |
| 751 syncer::SyncService* profile_sync_service) { | 749 syncer::SyncService* profile_sync_service) { |
| 752 if (!profile_sync_service->IsFirstSetupComplete()) | 750 if (!profile_sync_service->IsFirstSetupComplete()) |
| 753 return; | 751 return; |
| 754 bool old_sync_enabled = sync_enabled_; | 752 bool old_sync_enabled = sync_enabled_; |
| 755 sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has( | 753 sync_enabled_ = profile_sync_service->GetActiveDataTypes().Has( |
| 756 syncer::APPS); | 754 syncer::APPS); |
| 757 remote_service_->SetSyncEnabled(sync_enabled_); | 755 remote_service_->SetSyncEnabled(sync_enabled_); |
| 758 if (!old_sync_enabled && sync_enabled_) | 756 if (!old_sync_enabled && sync_enabled_) |
| 759 RunForEachSyncRunners(&SyncProcessRunner::Schedule); | 757 RunForEachSyncRunners(&SyncProcessRunner::Schedule); |
| 760 } | 758 } |
| 761 | 759 |
| 762 void SyncFileSystemService::RunForEachSyncRunners( | 760 void SyncFileSystemService::RunForEachSyncRunners( |
| 763 void(SyncProcessRunner::*method)()) { | 761 void(SyncProcessRunner::*method)()) { |
| 764 for (ScopedVector<SyncProcessRunner>::iterator iter = | 762 for (ScopedVector<SyncProcessRunner>::iterator iter = |
| 765 local_sync_runners_.begin(); | 763 local_sync_runners_.begin(); |
| 766 iter != local_sync_runners_.end(); ++iter) | 764 iter != local_sync_runners_.end(); ++iter) |
| 767 ((*iter)->*method)(); | 765 ((*iter)->*method)(); |
| 768 for (ScopedVector<SyncProcessRunner>::iterator iter = | 766 for (ScopedVector<SyncProcessRunner>::iterator iter = |
| 769 remote_sync_runners_.begin(); | 767 remote_sync_runners_.begin(); |
| 770 iter != remote_sync_runners_.end(); ++iter) | 768 iter != remote_sync_runners_.end(); ++iter) |
| 771 ((*iter)->*method)(); | 769 ((*iter)->*method)(); |
| 772 } | 770 } |
| 773 | 771 |
| 774 } // namespace sync_file_system | 772 } // namespace sync_file_system |
| OLD | NEW |