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

Side by Side Diff: components/syncable_prefs/pref_model_associator.cc

Issue 1895993003: Add migration code to change existing domain scoped content settings to be origin scoped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove logs and format Created 4 years, 6 months 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
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 #include "components/syncable_prefs/pref_model_associator.h" 5 #include "components/syncable_prefs/pref_model_associator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h"
11 #include "base/callback.h"
10 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
11 #include "base/json/json_string_value_serializer.h" 13 #include "base/json/json_string_value_serializer.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
15 #include "base/stl_util.h" 17 #include "base/stl_util.h"
16 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 19 #include "base/values.h"
18 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
19 #include "components/syncable_prefs/pref_model_associator_client.h" 21 #include "components/syncable_prefs/pref_model_associator_client.h"
(...skipping 27 matching lines...) Expand all
47 DCHECK(!specifics->has_preference()); 49 DCHECK(!specifics->has_preference());
48 return specifics->mutable_priority_preference()->mutable_preference(); 50 return specifics->mutable_priority_preference()->mutable_preference();
49 } else { 51 } else {
50 DCHECK(!specifics->has_priority_preference()); 52 DCHECK(!specifics->has_priority_preference());
51 return specifics->mutable_preference(); 53 return specifics->mutable_preference();
52 } 54 }
53 } 55 }
54 56
55 } // namespace 57 } // namespace
56 58
59 base::Closure syncable_prefs::PrefModelAssociator::migrate_call_back_;
60
57 PrefModelAssociator::PrefModelAssociator( 61 PrefModelAssociator::PrefModelAssociator(
58 const PrefModelAssociatorClient* client, 62 const PrefModelAssociatorClient* client,
59 syncer::ModelType type) 63 syncer::ModelType type)
60 : models_associated_(false), 64 : models_associated_(false),
61 processing_syncer_changes_(false), 65 processing_syncer_changes_(false),
62 pref_service_(NULL), 66 pref_service_(NULL),
63 type_(type), 67 type_(type),
64 client_(client) { 68 client_(client) {
65 DCHECK(CalledOnValidThread()); 69 DCHECK(CalledOnValidThread());
66 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES); 70 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 sync_data)); 154 sync_data));
151 synced_preferences_.insert(pref_name); 155 synced_preferences_.insert(pref_name);
152 } 156 }
153 157
154 // Else this pref does not have a sync value but also does not have a user 158 // Else this pref does not have a sync value but also does not have a user
155 // controlled value (either it's a default value or it's policy controlled, 159 // controlled value (either it's a default value or it's policy controlled,
156 // either way it's not interesting). We can ignore it. Once it gets changed, 160 // either way it's not interesting). We can ignore it. Once it gets changed,
157 // we'll send the new user controlled value to the syncer. 161 // we'll send the new user controlled value to the syncer.
158 } 162 }
159 163
164 // static
165 void PrefModelAssociator::SetMergeDataFinishedCallback(
166 const base::Closure& callback) {
167 migrate_call_back_ = callback;
168 }
169
170 // static
171 void PrefModelAssociator::ResetMergeDataFinishedCallback() {
172 migrate_call_back_.Reset();
173 }
174
160 syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing( 175 syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing(
161 syncer::ModelType type, 176 syncer::ModelType type,
162 const syncer::SyncDataList& initial_sync_data, 177 const syncer::SyncDataList& initial_sync_data,
163 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, 178 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
164 std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) { 179 std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) {
165 DCHECK_EQ(type_, type); 180 DCHECK_EQ(type_, type);
166 DCHECK(CalledOnValidThread()); 181 DCHECK(CalledOnValidThread());
167 DCHECK(pref_service_); 182 DCHECK(pref_service_);
168 DCHECK(!sync_processor_.get()); 183 DCHECK(!sync_processor_.get());
169 DCHECK(sync_processor.get()); 184 DCHECK(sync_processor.get());
(...skipping 29 matching lines...) Expand all
199 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes); 214 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes);
200 } 215 }
201 216
202 // Go through and build sync data for any remaining preferences. 217 // Go through and build sync data for any remaining preferences.
203 for (std::set<std::string>::iterator pref_name_iter = 218 for (std::set<std::string>::iterator pref_name_iter =
204 remaining_preferences.begin(); 219 remaining_preferences.begin();
205 pref_name_iter != remaining_preferences.end(); 220 pref_name_iter != remaining_preferences.end();
206 ++pref_name_iter) { 221 ++pref_name_iter) {
207 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes); 222 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes);
208 } 223 }
209 224 if (!migrate_call_back_.is_null()) {
225 migrate_call_back_.Run();
226 }
210 // Push updates to sync. 227 // Push updates to sync.
211 merge_result.set_error( 228 merge_result.set_error(
212 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes)); 229 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
213 if (merge_result.error().IsSet()) 230 if (merge_result.error().IsSet())
214 return merge_result; 231 return merge_result;
215 232
216 models_associated_ = true; 233 models_associated_ = true;
217 pref_service_->OnIsSyncingChanged(); 234 pref_service_->OnIsSyncingChanged();
218 return merge_result; 235 return merge_result;
219 } 236 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 SyncedPrefObserverMap::const_iterator observer_iter = 548 SyncedPrefObserverMap::const_iterator observer_iter =
532 synced_pref_observers_.find(path); 549 synced_pref_observers_.find(path);
533 if (observer_iter == synced_pref_observers_.end()) 550 if (observer_iter == synced_pref_observers_.end())
534 return; 551 return;
535 SyncedPrefObserverList* observers = observer_iter->second; 552 SyncedPrefObserverList* observers = observer_iter->second;
536 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers, 553 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers,
537 OnSyncedPrefChanged(path, from_sync)); 554 OnSyncedPrefChanged(path, from_sync));
538 } 555 }
539 556
540 } // namespace syncable_prefs 557 } // namespace syncable_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698