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

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

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 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 | « rlz/chromeos/lib/rlz_value_store_chromeos.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = JSONFileValueDeserializer::JSON_NO_ERROR; 67 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR;
68 std::string error_message; 68 std::string error_message;
69 JSONFileValueDeserializer deserializer(data_file_); 69 JSONFileValueDeserializer deserializer(data_file_);
70 base::Value* value = deserializer.Deserialize(&error_code, &error_message); 70 scoped_ptr<base::DictionaryValue> dict_value = base::DictionaryValue::From(
71 base::DictionaryValue* dict_value = NULL; 71 deserializer.Deserialize(&error_code, &error_message));
72 if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !value || 72 if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !dict_value) {
73 !value->GetAsDictionary(&dict_value) || !dict_value) {
74 return nullptr; 73 return nullptr;
75 } 74 }
76 75
77 base::DictionaryValue* return_dict = dict_value->DeepCopy(); 76 scoped_ptr<base::DictionaryValue> return_dict =
78 cached_dict_.reset(dict_value); 77 make_scoped_ptr(dict_value.get()->DeepCopy());
79 return make_scoped_ptr(return_dict); 78 cached_dict_ = dict_value.Pass();
79 return 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 | « rlz/chromeos/lib/rlz_value_store_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698