OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 static const char kPreferencesTag[] = "google_chrome_preferences"; | 24 static const char kPreferencesTag[] = "google_chrome_preferences"; |
25 | 25 |
26 // Contains all model association related logic: | 26 // Contains all model association related logic: |
27 // * Algorithm to associate preferences model and sync model. | 27 // * Algorithm to associate preferences model and sync model. |
28 class PreferenceModelAssociator | 28 class PreferenceModelAssociator |
29 : public PerDataTypeAssociatorInterface<PrefService::Preference, | 29 : public PerDataTypeAssociatorInterface<PrefService::Preference, |
30 std::wstring> { | 30 std::wstring> { |
31 public: | 31 public: |
32 static syncable::ModelType model_type() { return syncable::PREFERENCES; } | 32 static syncable::ModelType model_type() { return syncable::PREFERENCES; } |
33 PreferenceModelAssociator(ProfileSyncService* sync_service, | 33 PreferenceModelAssociator(ProfileSyncService* sync_service); |
34 UnrecoverableErrorHandler* error_handler); | |
35 virtual ~PreferenceModelAssociator(); | 34 virtual ~PreferenceModelAssociator(); |
36 | 35 |
37 // Returns the list of preference names that should be monitored for | 36 // Returns the list of preference names that should be monitored for |
38 // changes. Only preferences that are registered will be in this | 37 // changes. Only preferences that are registered will be in this |
39 // list. | 38 // list. |
40 const std::set<std::wstring>& synced_preferences() { | 39 const std::set<std::wstring>& synced_preferences() { |
41 return synced_preferences_; | 40 return synced_preferences_; |
42 } | 41 } |
43 | 42 |
44 // PerDataTypeAssociatorInterface implementation. | 43 // PerDataTypeAssociatorInterface implementation. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Associates the given preference name with the given sync id. | 79 // Associates the given preference name with the given sync id. |
81 virtual void Associate(const PrefService::Preference* node, int64 sync_id); | 80 virtual void Associate(const PrefService::Preference* node, int64 sync_id); |
82 | 81 |
83 // Remove the association that corresponds to the given sync id. | 82 // Remove the association that corresponds to the given sync id. |
84 virtual void Disassociate(int64 sync_id); | 83 virtual void Disassociate(int64 sync_id); |
85 | 84 |
86 // Returns whether a node with the given permanent tag was found and update | 85 // Returns whether a node with the given permanent tag was found and update |
87 // |sync_id| with that node's id. | 86 // |sync_id| with that node's id. |
88 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); | 87 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); |
89 | 88 |
90 protected: | |
91 // Returns sync service instance. | 89 // Returns sync service instance. |
92 ProfileSyncService* sync_service() { return sync_service_; } | 90 ProfileSyncService* sync_service() { return sync_service_; } |
93 | 91 |
94 private: | 92 private: |
95 typedef std::map<std::wstring, int64> PreferenceNameToSyncIdMap; | 93 typedef std::map<std::wstring, int64> PreferenceNameToSyncIdMap; |
96 typedef std::map<int64, std::wstring> SyncIdToPreferenceNameMap; | 94 typedef std::map<int64, std::wstring> SyncIdToPreferenceNameMap; |
97 | 95 |
98 ProfileSyncService* sync_service_; | 96 ProfileSyncService* sync_service_; |
99 UnrecoverableErrorHandler* error_handler_; | |
100 std::set<std::wstring> synced_preferences_; | 97 std::set<std::wstring> synced_preferences_; |
101 int64 preferences_node_id_; | 98 int64 preferences_node_id_; |
102 | 99 |
103 PreferenceNameToSyncIdMap id_map_; | 100 PreferenceNameToSyncIdMap id_map_; |
104 SyncIdToPreferenceNameMap id_map_inverse_; | 101 SyncIdToPreferenceNameMap id_map_inverse_; |
105 | 102 |
106 DISALLOW_COPY_AND_ASSIGN(PreferenceModelAssociator); | 103 DISALLOW_COPY_AND_ASSIGN(PreferenceModelAssociator); |
107 }; | 104 }; |
108 | 105 |
109 } // namespace browser_sync | 106 } // namespace browser_sync |
110 | 107 |
111 #endif // CHROME_BROWSER_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ | 108 #endif // CHROME_BROWSER_SYNC_GLUE_PREFERENCE_MODEL_ASSOCIATOR_H_ |
OLD | NEW |