| 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/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 12 matching lines...) Expand all Loading... |
| 23 // (aka file) thread. | 23 // (aka file) thread. |
| 24 class FileThreadDeserializer | 24 class FileThreadDeserializer |
| 25 : public base::RefCountedThreadSafe<FileThreadDeserializer> { | 25 : public base::RefCountedThreadSafe<FileThreadDeserializer> { |
| 26 public: | 26 public: |
| 27 FileThreadDeserializer(JsonPrefStore* delegate, | 27 FileThreadDeserializer(JsonPrefStore* delegate, |
| 28 base::MessageLoopProxy* file_loop_proxy) | 28 base::MessageLoopProxy* file_loop_proxy) |
| 29 : no_dir_(false), | 29 : no_dir_(false), |
| 30 error_(PersistentPrefStore::PREF_READ_ERROR_NONE), | 30 error_(PersistentPrefStore::PREF_READ_ERROR_NONE), |
| 31 delegate_(delegate), | 31 delegate_(delegate), |
| 32 file_loop_proxy_(file_loop_proxy), | 32 file_loop_proxy_(file_loop_proxy), |
| 33 origin_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()) { | 33 origin_loop_proxy_(base::MessageLoopProxy::current()) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 void Start(const FilePath& path) { | 36 void Start(const FilePath& path) { |
| 37 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); | 37 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); |
| 38 file_loop_proxy_->PostTask( | 38 file_loop_proxy_->PostTask( |
| 39 FROM_HERE, | 39 FROM_HERE, |
| 40 NewRunnableMethod(this, | 40 NewRunnableMethod(this, |
| 41 &FileThreadDeserializer::ReadFileAndReport, | 41 &FileThreadDeserializer::ReadFileAndReport, |
| 42 path)); | 42 path)); |
| 43 } | 43 } |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool JsonPrefStore::SerializeData(std::string* output) { | 313 bool JsonPrefStore::SerializeData(std::string* output) { |
| 314 // TODO(tc): Do we want to prune webkit preferences that match the default | 314 // TODO(tc): Do we want to prune webkit preferences that match the default |
| 315 // value? | 315 // value? |
| 316 JSONStringValueSerializer serializer(output); | 316 JSONStringValueSerializer serializer(output); |
| 317 serializer.set_pretty_print(true); | 317 serializer.set_pretty_print(true); |
| 318 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); | 318 scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren()); |
| 319 return serializer.Serialize(*(copy.get())); | 319 return serializer.Serialize(*(copy.get())); |
| 320 } | 320 } |
| OLD | NEW |