OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/sync/glue/preference_model_associator.h" | 5 #include "chrome/browser/sync/glue/preference_model_associator.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/pref_service.h" | 12 #include "chrome/browser/pref_service.h" |
13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
14 #include "chrome/browser/sync/engine/syncapi.h" | 14 #include "chrome/browser/sync/engine/syncapi.h" |
15 #include "chrome/browser/sync/glue/synchronized_preferences.h" | 15 #include "chrome/browser/sync/glue/synchronized_preferences.h" |
16 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
17 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" | 17 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" |
18 #include "chrome/common/json_value_serializer.h" | 18 #include "chrome/common/json_value_serializer.h" |
19 | 19 |
20 namespace browser_sync { | 20 namespace browser_sync { |
21 | 21 |
22 PreferenceModelAssociator::PreferenceModelAssociator( | 22 PreferenceModelAssociator::PreferenceModelAssociator( |
23 ProfileSyncService* sync_service, | 23 ProfileSyncService* sync_service) |
24 UnrecoverableErrorHandler* error_handler) | |
25 : sync_service_(sync_service), | 24 : sync_service_(sync_service), |
26 error_handler_(error_handler), | |
27 preferences_node_id_(sync_api::kInvalidId) { | 25 preferences_node_id_(sync_api::kInvalidId) { |
28 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 26 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
29 DCHECK(sync_service_); | 27 DCHECK(sync_service_); |
30 | 28 |
31 // Add the list of kSynchronizedPreferences to our local | 29 // Add the list of kSynchronizedPreferences to our local |
32 // synced_preferences set, taking care to filter out any preferences | 30 // synced_preferences set, taking care to filter out any preferences |
33 // that are not registered. | 31 // that are not registered. |
34 PrefService* pref_service = sync_service_->profile()->GetPrefs(); | 32 PrefService* pref_service = sync_service_->profile()->GetPrefs(); |
35 for (size_t i = 0; | 33 for (size_t i = 0; |
36 i < static_cast<size_t>(arraysize(kSynchronizedPreferences)); ++i) { | 34 i < static_cast<size_t>(arraysize(kSynchronizedPreferences)); ++i) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 sync_api::ReadTransaction trans( | 186 sync_api::ReadTransaction trans( |
189 sync_service_->backend()->GetUserShareHandle()); | 187 sync_service_->backend()->GetUserShareHandle()); |
190 sync_api::ReadNode sync_node(&trans); | 188 sync_api::ReadNode sync_node(&trans); |
191 if (!sync_node.InitByTagLookup(tag.c_str())) | 189 if (!sync_node.InitByTagLookup(tag.c_str())) |
192 return false; | 190 return false; |
193 *sync_id = sync_node.GetId(); | 191 *sync_id = sync_node.GetId(); |
194 return true; | 192 return true; |
195 } | 193 } |
196 | 194 |
197 } // namespace browser_sync | 195 } // namespace browser_sync |
OLD | NEW |