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

Side by Side Diff: chrome/browser/prefs/pref_model_associator.h

Issue 8568019: Introduce per-tab preferences service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 14 matching lines...) Expand all
25 class Value; 25 class Value;
26 } 26 }
27 27
28 // Contains all preference sync related logic. 28 // Contains all preference sync related logic.
29 // TODO(sync): Merge this into PrefService once we separate the profile 29 // TODO(sync): Merge this into PrefService once we separate the profile
30 // PrefService from the local state PrefService. 30 // PrefService from the local state PrefService.
31 class PrefModelAssociator 31 class PrefModelAssociator
32 : public SyncableService, 32 : public SyncableService,
33 public base::NonThreadSafe { 33 public base::NonThreadSafe {
34 public: 34 public:
35 explicit PrefModelAssociator(PrefService* pref_service); 35 PrefModelAssociator();
36 virtual ~PrefModelAssociator(); 36 virtual ~PrefModelAssociator();
37 37
38 // SyncableService implementation. 38 // SyncableService implementation.
39 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; 39 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE;
40 virtual SyncError ProcessSyncChanges( 40 virtual SyncError ProcessSyncChanges(
41 const tracked_objects::Location& from_here, 41 const tracked_objects::Location& from_here,
42 const SyncChangeList& change_list) OVERRIDE; 42 const SyncChangeList& change_list) OVERRIDE;
43 virtual SyncError MergeDataAndStartSyncing( 43 virtual SyncError MergeDataAndStartSyncing(
44 syncable::ModelType type, 44 syncable::ModelType type,
45 const SyncDataList& initial_sync_data, 45 const SyncDataList& initial_sync_data,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 static bool CreatePrefSyncData(const std::string& name, 78 static bool CreatePrefSyncData(const std::string& name,
79 const base::Value& value, 79 const base::Value& value,
80 SyncData* sync_data); 80 SyncData* sync_data);
81 81
82 // Extract preference value and name from sync specifics. 82 // Extract preference value and name from sync specifics.
83 base::Value* ReadPreferenceSpecifics( 83 base::Value* ReadPreferenceSpecifics(
84 const sync_pb::PreferenceSpecifics& specifics, 84 const sync_pb::PreferenceSpecifics& specifics,
85 std::string* name); 85 std::string* name);
86 86
87 protected: 87 protected:
88 friend class PrefService;
88 friend class ProfileSyncServicePreferenceTest; 89 friend class ProfileSyncServicePreferenceTest;
89 90
90 typedef std::map<std::string, SyncData> SyncDataMap; 91 typedef std::map<std::string, SyncData> SyncDataMap;
91 92
92 // For testing.
93 PrefModelAssociator();
94
95 // Create an association for a given preference. If |sync_pref| is valid, 93 // Create an association for a given preference. If |sync_pref| is valid,
96 // signifying that sync has data for this preference, we reconcile their data 94 // signifying that sync has data for this preference, we reconcile their data
97 // with ours and append a new UPDATE SyncChange to |sync_changes|. If 95 // with ours and append a new UPDATE SyncChange to |sync_changes|. If
98 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with 96 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with
99 // the current preference data. 97 // the current preference data.
100 // Note: We do not modify the sync data for preferences that are either 98 // Note: We do not modify the sync data for preferences that are either
101 // controlled by policy (are not user modifiable) or have their default value 99 // controlled by policy (are not user modifiable) or have their default value
102 // (are not user controlled). 100 // (are not user controlled).
103 void InitPrefAndAssociate(const SyncData& sync_pref, 101 void InitPrefAndAssociate(const SyncData& sync_pref,
104 const std::string& pref_name, 102 const std::string& pref_name,
105 SyncChangeList* sync_changes); 103 SyncChangeList* sync_changes);
106 104
105 void SetPrefService(PrefService* pref_service);
106
107 static base::Value* MergeListValues( 107 static base::Value* MergeListValues(
108 const base::Value& from_value, const base::Value& to_value); 108 const base::Value& from_value, const base::Value& to_value);
109 static base::Value* MergeDictionaryValues(const base::Value& from_value, 109 static base::Value* MergeDictionaryValues(const base::Value& from_value,
110 const base::Value& to_value); 110 const base::Value& to_value);
111 111
112 // Do we have an active association between the preferences and sync models? 112 // Do we have an active association between the preferences and sync models?
113 // Set when start syncing, reset in StopSyncing. While this is not set, we 113 // Set when start syncing, reset in StopSyncing. While this is not set, we
114 // ignore any local preference changes (when we start syncing we will look 114 // ignore any local preference changes (when we start syncing we will look
115 // up the most recent values anyways). 115 // up the most recent values anyways).
116 bool models_associated_; 116 bool models_associated_;
(...skipping 20 matching lines...) Expand all
137 // The PrefService we are syncing to. 137 // The PrefService we are syncing to.
138 PrefService* pref_service_; 138 PrefService* pref_service_;
139 139
140 // Sync's SyncChange handler. We push all our changes through this. 140 // Sync's SyncChange handler. We push all our changes through this.
141 SyncChangeProcessor* sync_processor_; 141 SyncChangeProcessor* sync_processor_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 143 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
144 }; 144 };
145 145
146 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 146 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698