Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: ui/app_list/search/dictionary_data_store.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698