| 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 "components/prefs/pref_service.h" | 5 #include "components/prefs/pref_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 read_error_callback_(read_error_callback) { | 70 read_error_callback_(read_error_callback) { |
| 71 pref_notifier_->SetPrefService(this); | 71 pref_notifier_->SetPrefService(this); |
| 72 | 72 |
| 73 // TODO(battre): This is a check for crbug.com/435208 to make sure that | 73 // TODO(battre): This is a check for crbug.com/435208 to make sure that |
| 74 // access violations are caused by a use-after-free bug and not by an | 74 // access violations are caused by a use-after-free bug and not by an |
| 75 // initialization bug. | 75 // initialization bug. |
| 76 CHECK(pref_registry_); | 76 CHECK(pref_registry_); |
| 77 CHECK(pref_value_store_); | 77 CHECK(pref_value_store_); |
| 78 | 78 |
| 79 InitFromStorage(async); | 79 InitFromStorage(async); |
| 80 LOG(ERROR) << "PrefService::PrefService init"; |
| 80 } | 81 } |
| 81 | 82 |
| 82 PrefService::~PrefService() { | 83 PrefService::~PrefService() { |
| 83 DCHECK(CalledOnValidThread()); | 84 DCHECK(CalledOnValidThread()); |
| 84 | 85 |
| 85 // Reset pointers so accesses after destruction reliably crash. | 86 // Reset pointers so accesses after destruction reliably crash. |
| 86 pref_value_store_.reset(); | 87 pref_value_store_.reset(); |
| 87 pref_registry_ = NULL; | 88 pref_registry_ = NULL; |
| 88 user_pref_store_ = NULL; | 89 user_pref_store_ = NULL; |
| 89 pref_notifier_.reset(); | 90 pref_notifier_.reset(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return out; | 229 return out; |
| 229 } | 230 } |
| 230 | 231 |
| 231 const PrefService::Preference* PrefService::FindPreference( | 232 const PrefService::Preference* PrefService::FindPreference( |
| 232 const std::string& pref_name) const { | 233 const std::string& pref_name) const { |
| 233 DCHECK(CalledOnValidThread()); | 234 DCHECK(CalledOnValidThread()); |
| 234 PreferenceMap::iterator it = prefs_map_.find(pref_name); | 235 PreferenceMap::iterator it = prefs_map_.find(pref_name); |
| 235 if (it != prefs_map_.end()) | 236 if (it != prefs_map_.end()) |
| 236 return &(it->second); | 237 return &(it->second); |
| 237 const base::Value* default_value = NULL; | 238 const base::Value* default_value = NULL; |
| 239 if (!pref_name.compare("settings.display.properties")) |
| 240 LOG(ERROR) << "PrefService::FindPreference - 1"; |
| 238 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value)) | 241 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value)) |
| 239 return NULL; | 242 return NULL; |
| 243 if (!pref_name.compare("settings.display.properties")) |
| 244 LOG(ERROR) << "PrefService::FindPreference - 2"; |
| 245 |
| 240 it = prefs_map_.insert( | 246 it = prefs_map_.insert( |
| 241 std::make_pair(pref_name, Preference( | 247 std::make_pair(pref_name, Preference( |
| 242 this, pref_name, default_value->GetType()))).first; | 248 this, pref_name, default_value->GetType()))).first; |
| 243 return &(it->second); | 249 return &(it->second); |
| 244 } | 250 } |
| 245 | 251 |
| 246 bool PrefService::ReadOnly() const { | 252 bool PrefService::ReadOnly() const { |
| 247 return user_pref_store_->ReadOnly(); | 253 return user_pref_store_->ReadOnly(); |
| 248 } | 254 } |
| 249 | 255 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 DCHECK(found_value->IsType(default_type)); | 620 DCHECK(found_value->IsType(default_type)); |
| 615 return found_value; | 621 return found_value; |
| 616 } else { | 622 } else { |
| 617 // Every registered preference has at least a default value. | 623 // Every registered preference has at least a default value. |
| 618 NOTREACHED() << "no valid value found for registered pref " << path; | 624 NOTREACHED() << "no valid value found for registered pref " << path; |
| 619 } | 625 } |
| 620 } | 626 } |
| 621 | 627 |
| 622 return NULL; | 628 return NULL; |
| 623 } | 629 } |
| OLD | NEW |