OLD | NEW |
---|---|
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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/sync/api/syncable_service.h" | 17 #include "chrome/browser/sync/api/syncable_service.h" |
18 #include "chrome/browser/sync/api/sync_data.h" | 18 #include "chrome/browser/sync/api/sync_data.h" |
19 #include "chrome/browser/sync/api/sync_error.h" | |
akalin
2011/07/21 23:03:53
forward declare instead? Or just not #include, si
Nicolas Zea
2011/07/21 23:43:27
Done.
| |
19 | 20 |
20 namespace sync_pb { | 21 namespace sync_pb { |
21 class PreferenceSpecifics; | 22 class PreferenceSpecifics; |
22 } | 23 } |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class Value; | 26 class Value; |
26 } | 27 } |
27 | 28 |
28 // Contains all preference sync related logic. | 29 // Contains all preference sync related logic. |
29 // TODO(sync): Merge this into PrefService once we separate the profile | 30 // TODO(sync): Merge this into PrefService once we separate the profile |
30 // PrefService from the local state PrefService. | 31 // PrefService from the local state PrefService. |
31 class PrefModelAssociator | 32 class PrefModelAssociator |
32 : public SyncableService, | 33 : public SyncableService, |
33 public base::NonThreadSafe { | 34 public base::NonThreadSafe { |
34 public: | 35 public: |
35 explicit PrefModelAssociator(PrefService* pref_service); | 36 explicit PrefModelAssociator(PrefService* pref_service); |
36 virtual ~PrefModelAssociator(); | 37 virtual ~PrefModelAssociator(); |
37 | 38 |
38 // SyncableService implementation. | 39 // SyncableService implementation. |
39 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; | 40 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; |
40 virtual void ProcessSyncChanges(const tracked_objects::Location& from_here, | 41 virtual bool ProcessSyncChanges(const tracked_objects::Location& from_here, |
41 const SyncChangeList& change_list) OVERRIDE; | 42 const SyncChangeList& change_list, |
43 SyncError* error) OVERRIDE; | |
42 virtual bool MergeDataAndStartSyncing( | 44 virtual bool MergeDataAndStartSyncing( |
43 syncable::ModelType type, | 45 syncable::ModelType type, |
44 const SyncDataList& initial_sync_data, | 46 const SyncDataList& initial_sync_data, |
45 SyncChangeProcessor* sync_processor) OVERRIDE; | 47 SyncChangeProcessor* sync_processor, |
48 SyncError* error) OVERRIDE; | |
46 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; | 49 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; |
47 | 50 |
48 // Returns the list of preference names that are registered as syncable, and | 51 // Returns the list of preference names that are registered as syncable, and |
49 // hence should be monitored for changes. | 52 // hence should be monitored for changes. |
50 std::set<std::string> registered_preferences() const; | 53 std::set<std::string> registered_preferences() const; |
51 | 54 |
52 // Register a preference with the specified name for syncing. We do not care | 55 // Register a preference with the specified name for syncing. We do not care |
53 // about the type at registration time, but when changes arrive from the | 56 // about the type at registration time, but when changes arrive from the |
54 // syncer, we check if they can be applied and if not drop them. | 57 // syncer, we check if they can be applied and if not drop them. |
55 // Note: This should only be called at profile startup time (before sync | 58 // Note: This should only be called at profile startup time (before sync |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 // The PrefService we are syncing to. | 143 // The PrefService we are syncing to. |
141 PrefService* pref_service_; | 144 PrefService* pref_service_; |
142 | 145 |
143 // Sync's SyncChange handler. We push all our changes through this. | 146 // Sync's SyncChange handler. We push all our changes through this. |
144 SyncChangeProcessor* sync_processor_; | 147 SyncChangeProcessor* sync_processor_; |
145 | 148 |
146 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); | 149 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); |
147 }; | 150 }; |
148 | 151 |
149 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 152 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
OLD | NEW |