OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/sync/driver/sync_service_base.h" | 5 #include "components/sync/driver/sync_service_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void SyncServiceBase::AddObserver(SyncServiceObserver* observer) { | 71 void SyncServiceBase::AddObserver(SyncServiceObserver* observer) { |
72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
73 observers_.AddObserver(observer); | 73 observers_.AddObserver(observer); |
74 } | 74 } |
75 | 75 |
76 void SyncServiceBase::RemoveObserver(SyncServiceObserver* observer) { | 76 void SyncServiceBase::RemoveObserver(SyncServiceObserver* observer) { |
77 DCHECK(thread_checker_.CalledOnValidThread()); | 77 DCHECK(thread_checker_.CalledOnValidThread()); |
78 observers_.RemoveObserver(observer); | 78 observers_.RemoveObserver(observer); |
79 } | 79 } |
80 | 80 |
| 81 bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const { |
| 82 DCHECK(thread_checker_.CalledOnValidThread()); |
| 83 return observers_.HasObserver(observer); |
| 84 } |
| 85 |
| 86 SigninManagerBase* SyncServiceBase::signin() const { |
| 87 DCHECK(thread_checker_.CalledOnValidThread()); |
| 88 return signin_ ? signin_->GetOriginal() : nullptr; |
| 89 } |
| 90 |
81 // static | 91 // static |
82 base::FilePath SyncServiceBase::FormatSyncDataPath( | 92 base::FilePath SyncServiceBase::FormatSyncDataPath( |
83 const base::FilePath& base_directory) { | 93 const base::FilePath& base_directory) { |
84 return base_directory.Append(base::FilePath(kSyncDataFolderName)); | 94 return base_directory.Append(base::FilePath(kSyncDataFolderName)); |
85 } | 95 } |
86 | 96 |
87 // static | 97 // static |
88 base::FilePath SyncServiceBase::FormatSharedModelTypeStorePath( | 98 base::FilePath SyncServiceBase::FormatSharedModelTypeStorePath( |
89 const base::FilePath& base_directory) { | 99 const base::FilePath& base_directory) { |
90 return FormatSyncDataPath(base_directory) | 100 return FormatSyncDataPath(base_directory) |
91 .Append(base::FilePath(kLevelDBFolderName)); | 101 .Append(base::FilePath(kLevelDBFolderName)); |
92 } | 102 } |
93 | 103 |
94 bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const { | |
95 DCHECK(thread_checker_.CalledOnValidThread()); | |
96 return observers_.HasObserver(observer); | |
97 } | |
98 | |
99 void SyncServiceBase::NotifyObservers() { | 104 void SyncServiceBase::NotifyObservers() { |
100 for (auto& observer : observers_) { | 105 for (auto& observer : observers_) { |
101 observer.OnStateChanged(this); | 106 observer.OnStateChanged(this); |
102 } | 107 } |
103 } | 108 } |
104 | 109 |
105 void SyncServiceBase::InitializeEngine() { | 110 void SyncServiceBase::InitializeEngine() { |
106 DCHECK(engine_); | 111 DCHECK(engine_); |
107 | 112 |
108 if (!sync_thread_) { | 113 if (!sync_thread_) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 void SyncServiceBase::ResetCryptoState() { | 159 void SyncServiceBase::ResetCryptoState() { |
155 crypto_ = base::MakeUnique<SyncServiceCrypto>( | 160 crypto_ = base::MakeUnique<SyncServiceCrypto>( |
156 base::BindRepeating(&SyncServiceBase::NotifyObservers, | 161 base::BindRepeating(&SyncServiceBase::NotifyObservers, |
157 base::Unretained(this)), | 162 base::Unretained(this)), |
158 base::BindRepeating(&SyncService::GetPreferredDataTypes, | 163 base::BindRepeating(&SyncService::GetPreferredDataTypes, |
159 base::Unretained(this)), | 164 base::Unretained(this)), |
160 &sync_prefs_); | 165 &sync_prefs_); |
161 } | 166 } |
162 | 167 |
163 } // namespace syncer | 168 } // namespace syncer |
OLD | NEW |