| OLD | NEW |
| 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 "chrome/browser/prefs/pref_model_associator.h" | 5 #include "chrome/browser/prefs/pref_model_associator.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 void PrefModelAssociator::RegisterPref(const char* name) { | 393 void PrefModelAssociator::RegisterPref(const char* name) { |
| 394 DCHECK(!models_associated_ && registered_preferences_.count(name) == 0); | 394 DCHECK(!models_associated_ && registered_preferences_.count(name) == 0); |
| 395 registered_preferences_.insert(name); | 395 registered_preferences_.insert(name); |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool PrefModelAssociator::IsPrefRegistered(const char* name) { | 398 bool PrefModelAssociator::IsPrefRegistered(const char* name) { |
| 399 return registered_preferences_.count(name) > 0; | 399 return registered_preferences_.count(name) > 0; |
| 400 } | 400 } |
| 401 | 401 |
| 402 void PrefModelAssociator::UnregisterPref(const char* name) { | |
| 403 DCHECK(synced_preferences_.count(name) == 0); | |
| 404 registered_preferences_.erase(name); | |
| 405 } | |
| 406 | |
| 407 void PrefModelAssociator::ProcessPrefChange(const std::string& name) { | 402 void PrefModelAssociator::ProcessPrefChange(const std::string& name) { |
| 408 if (processing_syncer_changes_) | 403 if (processing_syncer_changes_) |
| 409 return; // These are changes originating from us, ignore. | 404 return; // These are changes originating from us, ignore. |
| 410 | 405 |
| 411 // We only process changes if we've already associated models. | 406 // We only process changes if we've already associated models. |
| 412 if (!models_associated_) | 407 if (!models_associated_) |
| 413 return; | 408 return; |
| 414 | 409 |
| 415 const PrefService::Preference* preference = | 410 const PrefService::Preference* preference = |
| 416 pref_service_->FindPreference(name.c_str()); | 411 pref_service_->FindPreference(name.c_str()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 446 } |
| 452 | 447 |
| 453 syncer::SyncError error = | 448 syncer::SyncError error = |
| 454 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 449 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
| 455 } | 450 } |
| 456 | 451 |
| 457 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) { | 452 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) { |
| 458 DCHECK(pref_service_ == NULL); | 453 DCHECK(pref_service_ == NULL); |
| 459 pref_service_ = pref_service; | 454 pref_service_ = pref_service; |
| 460 } | 455 } |
| OLD | NEW |