Chromium Code Reviews| 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/common/json_pref_store.h" | 5 #include "chrome/common/json_pref_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 void JsonPrefStore::ReportValueChanged(const std::string& key) { | 257 void JsonPrefStore::ReportValueChanged(const std::string& key) { |
| 258 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 258 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
| 259 if (!read_only_) | 259 if (!read_only_) |
| 260 writer_.ScheduleWrite(this); | 260 writer_.ScheduleWrite(this); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void JsonPrefStore::OnFileRead(Value* value_owned, | 263 void JsonPrefStore::OnFileRead(Value* value_owned, |
| 264 PersistentPrefStore::PrefReadError error, | 264 PersistentPrefStore::PrefReadError error, |
| 265 bool no_dir) { | 265 bool no_dir) { |
| 266 scoped_ptr<Value> value(value_owned); | 266 scoped_ptr<Value> value(value_owned); |
| 267 initialized_ = true; | |
| 268 read_error_ = error; | 267 read_error_ = error; |
| 269 | 268 |
| 270 if (no_dir) { | 269 if (no_dir) { |
| 271 FOR_EACH_OBSERVER(PrefStore::Observer, | 270 FOR_EACH_OBSERVER(PrefStore::Observer, |
| 272 observers_, | 271 observers_, |
| 273 OnInitializationCompleted(false)); | 272 OnInitializationCompleted(false)); |
| 274 return; | 273 return; |
| 275 } | 274 } |
| 276 | 275 |
| 276 initialized_ = true; | |
|
Mattias Nissler (ping if slow)
2012/05/10 15:44:04
Good catch.
| |
| 277 | |
| 277 switch (error) { | 278 switch (error) { |
| 278 case PREF_READ_ERROR_ACCESS_DENIED: | 279 case PREF_READ_ERROR_ACCESS_DENIED: |
| 279 case PREF_READ_ERROR_FILE_OTHER: | 280 case PREF_READ_ERROR_FILE_OTHER: |
| 280 case PREF_READ_ERROR_FILE_LOCKED: | 281 case PREF_READ_ERROR_FILE_LOCKED: |
| 281 case PREF_READ_ERROR_JSON_TYPE: | 282 case PREF_READ_ERROR_JSON_TYPE: |
| 282 case PREF_READ_ERROR_FILE_NOT_SPECIFIED: | 283 case PREF_READ_ERROR_FILE_NOT_SPECIFIED: |
| 283 read_only_ = true; | 284 read_only_ = true; |
| 284 break; | 285 break; |
| 285 case PREF_READ_ERROR_NONE: | 286 case PREF_READ_ERROR_NONE: |
| 286 DCHECK(value.get()); | 287 DCHECK(value.get()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 copy->Set(key, new base::ListValue); | 335 copy->Set(key, new base::ListValue); |
| 335 } else if (value->IsType(base::Value::TYPE_DICTIONARY)) { | 336 } else if (value->IsType(base::Value::TYPE_DICTIONARY)) { |
| 336 const base::DictionaryValue* dict = NULL; | 337 const base::DictionaryValue* dict = NULL; |
| 337 if (value->GetAsDictionary(&dict) && dict->empty()) | 338 if (value->GetAsDictionary(&dict) && dict->empty()) |
| 338 copy->Set(key, new base::DictionaryValue); | 339 copy->Set(key, new base::DictionaryValue); |
| 339 } | 340 } |
| 340 } | 341 } |
| 341 | 342 |
| 342 return serializer.Serialize(*(copy.get())); | 343 return serializer.Serialize(*(copy.get())); |
| 343 } | 344 } |
| OLD | NEW |