| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/search/dictionary_data_store.h" | 5 #include "ui/app_list/search/dictionary_data_store.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 on_loaded); | 57 on_loaded); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void DictionaryDataStore::ScheduleWrite() { | 60 void DictionaryDataStore::ScheduleWrite() { |
| 61 writer_->ScheduleWrite(this); | 61 writer_->ScheduleWrite(this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() { | 64 scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() { |
| 65 DCHECK(worker_pool_->RunsTasksOnCurrentThread()); | 65 DCHECK(worker_pool_->RunsTasksOnCurrentThread()); |
| 66 | 66 |
| 67 int error_code = JSONFileValueSerializer::JSON_NO_ERROR; | 67 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; |
| 68 std::string error_message; | 68 std::string error_message; |
| 69 JSONFileValueSerializer serializer(data_file_); | 69 JSONFileValueDeserializer deserializer(data_file_); |
| 70 base::Value* value = serializer.Deserialize(&error_code, &error_message); | 70 base::Value* value = deserializer.Deserialize(&error_code, &error_message); |
| 71 base::DictionaryValue* dict_value = NULL; | 71 base::DictionaryValue* dict_value = NULL; |
| 72 if (error_code != JSONFileValueSerializer::JSON_NO_ERROR || !value || | 72 if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value || |
| 73 !value->GetAsDictionary(&dict_value) || !dict_value) { | 73 !value->GetAsDictionary(&dict_value) || !dict_value) { |
| 74 return nullptr; | 74 return nullptr; |
| 75 } | 75 } |
| 76 | 76 |
| 77 base::DictionaryValue* return_dict = dict_value->DeepCopy(); | 77 base::DictionaryValue* return_dict = dict_value->DeepCopy(); |
| 78 cached_dict_.reset(dict_value); | 78 cached_dict_.reset(dict_value); |
| 79 return make_scoped_ptr(return_dict); | 79 return make_scoped_ptr(return_dict); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool DictionaryDataStore::SerializeData(std::string* data) { | 82 bool DictionaryDataStore::SerializeData(std::string* data) { |
| 83 JSONStringValueSerializer serializer(data); | 83 JSONStringValueSerializer serializer(data); |
| 84 serializer.set_pretty_print(true); | 84 serializer.set_pretty_print(true); |
| 85 return serializer.Serialize(*cached_dict_.get()); | 85 return serializer.Serialize(*cached_dict_.get()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace app_list | 88 } // namespace app_list |
| OLD | NEW |