| 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 #ifndef COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ | 5 #ifndef COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ |
| 6 #define COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ | 6 #define COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/threading/non_thread_safe.h" | 19 #include "base/sequence_checker.h" |
| 20 #include "components/sync/model/sync_data.h" | 20 #include "components/sync/model/sync_data.h" |
| 21 #include "components/sync/model/syncable_service.h" | 21 #include "components/sync/model/syncable_service.h" |
| 22 #include "components/sync_preferences/synced_pref_observer.h" | 22 #include "components/sync_preferences/synced_pref_observer.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class Value; | 25 class Value; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace sync_pb { | 28 namespace sync_pb { |
| 29 class PreferenceSpecifics; | 29 class PreferenceSpecifics; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace sync_preferences { | 32 namespace sync_preferences { |
| 33 | 33 |
| 34 class PrefModelAssociatorClient; | 34 class PrefModelAssociatorClient; |
| 35 class PrefServiceSyncable; | 35 class PrefServiceSyncable; |
| 36 | 36 |
| 37 // Contains all preference sync related logic. | 37 // Contains all preference sync related logic. |
| 38 // TODO(sync): Merge this into PrefService once we separate the profile | 38 // TODO(sync): Merge this into PrefService once we separate the profile |
| 39 // PrefService from the local state PrefService. | 39 // PrefService from the local state PrefService. |
| 40 class PrefModelAssociator : public syncer::SyncableService, | 40 class PrefModelAssociator : public syncer::SyncableService { |
| 41 public base::NonThreadSafe { | |
| 42 public: | 41 public: |
| 43 // Constructs a PrefModelAssociator initializing the |client_| and |type_| | 42 // Constructs a PrefModelAssociator initializing the |client_| and |type_| |
| 44 // instance variable. The |client| is not owned by this object and the caller | 43 // instance variable. The |client| is not owned by this object and the caller |
| 45 // must ensure that it oulives the PrefModelAssociator. | 44 // must ensure that it oulives the PrefModelAssociator. |
| 46 PrefModelAssociator(const PrefModelAssociatorClient* client, | 45 PrefModelAssociator(const PrefModelAssociatorClient* client, |
| 47 syncer::ModelType type); | 46 syncer::ModelType type); |
| 48 ~PrefModelAssociator() override; | 47 ~PrefModelAssociator() override; |
| 49 | 48 |
| 50 // See description above field for details. | 49 // See description above field for details. |
| 51 bool models_associated() const { return models_associated_; } | 50 bool models_associated() const { return models_associated_; } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 using SyncedPrefObserverMap = | 193 using SyncedPrefObserverMap = |
| 195 base::hash_map<std::string, std::unique_ptr<SyncedPrefObserverList>>; | 194 base::hash_map<std::string, std::unique_ptr<SyncedPrefObserverList>>; |
| 196 | 195 |
| 197 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; | 196 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; |
| 198 | 197 |
| 199 SyncedPrefObserverMap synced_pref_observers_; | 198 SyncedPrefObserverMap synced_pref_observers_; |
| 200 const PrefModelAssociatorClient* client_; // Weak. | 199 const PrefModelAssociatorClient* client_; // Weak. |
| 201 | 200 |
| 202 std::vector<base::Closure> callback_list_; | 201 std::vector<base::Closure> callback_list_; |
| 203 | 202 |
| 203 SEQUENCE_CHECKER(sequence_checker_); |
| 204 |
| 204 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); | 205 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); |
| 205 }; | 206 }; |
| 206 | 207 |
| 207 } // namespace sync_preferences | 208 } // namespace sync_preferences |
| 208 | 209 |
| 209 #endif // COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ | 210 #endif // COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |