| 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 CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 
| 6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <set> | 9 #include <set> | 
| 10 #include <string> | 10 #include <string> | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26 class Value; | 26 class Value; | 
| 27 } | 27 } | 
| 28 | 28 | 
| 29 // Contains all preference sync related logic. | 29 // Contains all preference sync related logic. | 
| 30 // TODO(sync): Merge this into PrefService once we separate the profile | 30 // TODO(sync): Merge this into PrefService once we separate the profile | 
| 31 // PrefService from the local state PrefService. | 31 // PrefService from the local state PrefService. | 
| 32 class PrefModelAssociator | 32 class PrefModelAssociator | 
| 33     : public syncer::SyncableService, | 33     : public syncer::SyncableService, | 
| 34       public base::NonThreadSafe { | 34       public base::NonThreadSafe { | 
| 35  public: | 35  public: | 
| 36   PrefModelAssociator(); | 36   explicit PrefModelAssociator(syncer::ModelType type); | 
| 37   virtual ~PrefModelAssociator(); | 37   virtual ~PrefModelAssociator(); | 
| 38 | 38 | 
| 39   // See description above field for details. | 39   // See description above field for details. | 
| 40   bool models_associated() const { return models_associated_; } | 40   bool models_associated() const { return models_associated_; } | 
| 41 | 41 | 
| 42   // syncer::SyncableService implementation. | 42   // syncer::SyncableService implementation. | 
| 43   virtual syncer::SyncDataList GetAllSyncData( | 43   virtual syncer::SyncDataList GetAllSyncData( | 
| 44       syncer::ModelType type) const OVERRIDE; | 44       syncer::ModelType type) const OVERRIDE; | 
| 45   virtual syncer::SyncError ProcessSyncChanges( | 45   virtual syncer::SyncError ProcessSyncChanges( | 
| 46       const tracked_objects::Location& from_here, | 46       const tracked_objects::Location& from_here, | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 77   // value always takes precedence. Note that only certain preferences will | 77   // value always takes precedence. Note that only certain preferences will | 
| 78   // actually be merged, all others will return a copy of the server value. See | 78   // actually be merged, all others will return a copy of the server value. See | 
| 79   // the method's implementation for details. | 79   // the method's implementation for details. | 
| 80   static scoped_ptr<base::Value> MergePreference( | 80   static scoped_ptr<base::Value> MergePreference( | 
| 81       const std::string& name, | 81       const std::string& name, | 
| 82       const base::Value& local_value, | 82       const base::Value& local_value, | 
| 83       const base::Value& server_value); | 83       const base::Value& server_value); | 
| 84 | 84 | 
| 85   // Fills |sync_data| with a sync representation of the preference data | 85   // Fills |sync_data| with a sync representation of the preference data | 
| 86   // provided. | 86   // provided. | 
| 87   static bool CreatePrefSyncData(const std::string& name, | 87   bool CreatePrefSyncData(const std::string& name, | 
| 88                                  const base::Value& value, | 88                           const base::Value& value, | 
| 89                                  syncer::SyncData* sync_data); | 89                           syncer::SyncData* sync_data) const; | 
| 90 | 90 | 
| 91   // Extract preference value and name from sync specifics. | 91   // Extract preference value and name from sync specifics. | 
| 92   base::Value* ReadPreferenceSpecifics( | 92   base::Value* ReadPreferenceSpecifics( | 
| 93       const sync_pb::PreferenceSpecifics& specifics, | 93       const sync_pb::PreferenceSpecifics& specifics, | 
| 94       std::string* name); | 94       std::string* name); | 
| 95 | 95 | 
| 96  protected: | 96  protected: | 
| 97   friend class ProfileSyncServicePreferenceTest; | 97   friend class ProfileSyncServicePreferenceTest; | 
| 98 | 98 | 
| 99   typedef std::map<std::string, syncer::SyncData> SyncDataMap; | 99   typedef std::map<std::string, syncer::SyncData> SyncDataMap; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 142 | 142 | 
| 143   // The PrefService we are syncing to. | 143   // The PrefService we are syncing to. | 
| 144   PrefServiceSyncable* pref_service_; | 144   PrefServiceSyncable* pref_service_; | 
| 145 | 145 | 
| 146   // Sync's syncer::SyncChange handler. We push all our changes through this. | 146   // Sync's syncer::SyncChange handler. We push all our changes through this. | 
| 147   scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 147   scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 
| 148 | 148 | 
| 149   // Sync's error handler. We use this to create sync errors. | 149   // Sync's error handler. We use this to create sync errors. | 
| 150   scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; | 150   scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; | 
| 151 | 151 | 
|  | 152   // The datatype that this associator is responible for, either PREFERENCES or | 
|  | 153   // PRIORITY_PREFERENCES. | 
|  | 154   syncer::ModelType type_; | 
|  | 155 | 
| 152   DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); | 156   DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); | 
| 153 }; | 157 }; | 
| 154 | 158 | 
| 155 #endif  // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 159 #endif  // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 
| OLD | NEW | 
|---|