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 #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_value_serializer.h" | 9 #include "base/json/json_value_serializer.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 369 |
370 void PrefModelAssociator::RegisterPref(const char* name) { | 370 void PrefModelAssociator::RegisterPref(const char* name) { |
371 DCHECK(!models_associated_ && registered_preferences_.count(name) == 0); | 371 DCHECK(!models_associated_ && registered_preferences_.count(name) == 0); |
372 registered_preferences_.insert(name); | 372 registered_preferences_.insert(name); |
373 } | 373 } |
374 | 374 |
375 bool PrefModelAssociator::IsPrefRegistered(const char* name) { | 375 bool PrefModelAssociator::IsPrefRegistered(const char* name) { |
376 return registered_preferences_.count(name) > 0; | 376 return registered_preferences_.count(name) > 0; |
377 } | 377 } |
378 | 378 |
| 379 void PrefModelAssociator::UnregisterPref(const char* name) { |
| 380 DCHECK(synced_preferences_.count(name) == 0); |
| 381 registered_preferences_.erase(name); |
| 382 } |
| 383 |
379 void PrefModelAssociator::ProcessPrefChange(const std::string& name) { | 384 void PrefModelAssociator::ProcessPrefChange(const std::string& name) { |
380 if (processing_syncer_changes_) | 385 if (processing_syncer_changes_) |
381 return; // These are changes originating from us, ignore. | 386 return; // These are changes originating from us, ignore. |
382 | 387 |
383 // We only process changes if we've already associated models. | 388 // We only process changes if we've already associated models. |
384 if (!models_associated_) | 389 if (!models_associated_) |
385 return; | 390 return; |
386 | 391 |
387 const PrefService::Preference* preference = | 392 const PrefService::Preference* preference = |
388 pref_service_->FindPreference(name.c_str()); | 393 pref_service_->FindPreference(name.c_str()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 SyncError error = | 427 SyncError error = |
423 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 428 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
424 if (error.IsSet()) | 429 if (error.IsSet()) |
425 StopSyncing(PREFERENCES); | 430 StopSyncing(PREFERENCES); |
426 } | 431 } |
427 | 432 |
428 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { | 433 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { |
429 DCHECK(pref_service_ == NULL); | 434 DCHECK(pref_service_ == NULL); |
430 pref_service_ = pref_service; | 435 pref_service_ = pref_service; |
431 } | 436 } |
OLD | NEW |