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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years 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) 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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "chrome/browser/prefs/pref_service.h"
16 #include "sync/api/sync_data.h" 15 #include "sync/api/sync_data.h"
17 #include "sync/api/syncable_service.h" 16 #include "sync/api/syncable_service.h"
18 17
18 class PrefServiceSyncable;
19
19 namespace sync_pb { 20 namespace sync_pb {
20 class PreferenceSpecifics; 21 class PreferenceSpecifics;
21 } 22 }
22 23
23 namespace base { 24 namespace base {
24 class Value; 25 class Value;
25 } 26 }
26 27
27 // Contains all preference sync related logic. 28 // Contains all preference sync related logic.
28 // TODO(sync): Merge this into PrefService once we separate the profile 29 // TODO(sync): Merge this into PrefService once we separate the profile
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 virtual bool IsPrefRegistered(const char* name); 66 virtual bool IsPrefRegistered(const char* name);
66 67
67 // Unregisters a previously registered preference. This must be called 68 // Unregisters a previously registered preference. This must be called
68 // prior to making the first sync. 69 // prior to making the first sync.
69 virtual void UnregisterPref(const char* name); 70 virtual void UnregisterPref(const char* name);
70 71
71 // Process a local preference change. This can trigger new SyncChanges being 72 // Process a local preference change. This can trigger new SyncChanges being
72 // sent to the syncer. 73 // sent to the syncer.
73 virtual void ProcessPrefChange(const std::string& name); 74 virtual void ProcessPrefChange(const std::string& name);
74 75
75 void SetPrefService(PrefService* pref_service); 76 void SetPrefService(PrefServiceSyncable* pref_service);
76 77
77 // Merges the local_value into the supplied server_value and returns 78 // Merges the local_value into the supplied server_value and returns
78 // the result (caller takes ownership). If there is a conflict, the server 79 // the result (caller takes ownership). If there is a conflict, the server
79 // value always takes precedence. Note that only certain preferences will 80 // value always takes precedence. Note that only certain preferences will
80 // actually be merged, all others will return a copy of the server value. See 81 // actually be merged, all others will return a copy of the server value. See
81 // the method's implementation for details. 82 // the method's implementation for details.
82 static scoped_ptr<base::Value> MergePreference( 83 static scoped_ptr<base::Value> MergePreference(
83 const std::string& name, 84 const std::string& name,
84 const base::Value& local_value, 85 const base::Value& local_value,
85 const base::Value& server_value); 86 const base::Value& server_value);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // The preferences that are currently synced (excludes those preferences 137 // The preferences that are currently synced (excludes those preferences
137 // that have never had sync data and currently have default values or are 138 // that have never had sync data and currently have default values or are
138 // policy controlled). 139 // policy controlled).
139 // Note: this set never decreases, only grows to eventually match 140 // Note: this set never decreases, only grows to eventually match
140 // registered_preferences_ as more preferences are synced. It determines 141 // registered_preferences_ as more preferences are synced. It determines
141 // whether a preference change should update an existing sync node or create 142 // whether a preference change should update an existing sync node or create
142 // a new sync node. 143 // a new sync node.
143 PreferenceSet synced_preferences_; 144 PreferenceSet synced_preferences_;
144 145
145 // The PrefService we are syncing to. 146 // The PrefService we are syncing to.
146 PrefService* pref_service_; 147 PrefServiceSyncable* pref_service_;
147 148
148 // Sync's syncer::SyncChange handler. We push all our changes through this. 149 // Sync's syncer::SyncChange handler. We push all our changes through this.
149 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 150 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
150 151
151 // Sync's error handler. We use this to create sync errors. 152 // Sync's error handler. We use this to create sync errors.
152 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; 153 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
153 154
154 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 155 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
155 }; 156 };
156 157
157 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 158 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698