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

Side by Side Diff: chrome/browser/ui/app_list/search/history_data_store.cc

Issue 543893002: Random fixes through Chrome for scoped_reftpr T* removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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 "chrome/browser/ui/app_list/search/history_data_store.h" 5 #include "chrome/browser/ui/app_list/search/history_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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 void HistoryDataStore::Init(base::DictionaryValue* cached_dict) { 122 void HistoryDataStore::Init(base::DictionaryValue* cached_dict) {
123 DCHECK(cached_dict); 123 DCHECK(cached_dict);
124 cached_dict->SetString(kKeyVersion, kCurrentVersion); 124 cached_dict->SetString(kKeyVersion, kCurrentVersion);
125 cached_dict->Set(kKeyAssociations, new base::DictionaryValue); 125 cached_dict->Set(kKeyAssociations, new base::DictionaryValue);
126 } 126 }
127 127
128 void HistoryDataStore::Flush( 128 void HistoryDataStore::Flush(
129 const DictionaryDataStore::OnFlushedCallback& on_flushed) { 129 const DictionaryDataStore::OnFlushedCallback& on_flushed) {
130 if (data_store_) 130 if (data_store_.get())
131 data_store_->Flush(on_flushed); 131 data_store_->Flush(on_flushed);
132 else 132 else
133 on_flushed.Run(); 133 on_flushed.Run();
134 } 134 }
135 135
136 void HistoryDataStore::Load( 136 void HistoryDataStore::Load(
137 const HistoryDataStore::OnLoadedCallback& on_loaded) { 137 const HistoryDataStore::OnLoadedCallback& on_loaded) {
138 if (data_store_) { 138 if (data_store_.get()) {
139 data_store_->Load(base::Bind(&HistoryDataStore::OnDictionaryLoadedCallback, 139 data_store_->Load(base::Bind(&HistoryDataStore::OnDictionaryLoadedCallback,
140 this, 140 this,
141 on_loaded)); 141 on_loaded));
142 } else { 142 } else {
143 OnDictionaryLoadedCallback( 143 OnDictionaryLoadedCallback(
144 on_loaded, make_scoped_ptr(cached_dict_->DeepCopy())); 144 on_loaded, make_scoped_ptr(cached_dict_->DeepCopy()));
145 } 145 }
146 } 146 }
147 147
148 void HistoryDataStore::SetPrimary(const std::string& query, 148 void HistoryDataStore::SetPrimary(const std::string& query,
149 const std::string& result) { 149 const std::string& result) {
150 base::DictionaryValue* entry_dict = GetEntryDict(query); 150 base::DictionaryValue* entry_dict = GetEntryDict(query);
151 entry_dict->SetWithoutPathExpansion(kKeyPrimary, 151 entry_dict->SetWithoutPathExpansion(kKeyPrimary,
152 new base::StringValue(result)); 152 new base::StringValue(result));
153 if (data_store_) 153 if (data_store_.get())
154 data_store_->ScheduleWrite(); 154 data_store_->ScheduleWrite();
155 } 155 }
156 156
157 void HistoryDataStore::SetSecondary( 157 void HistoryDataStore::SetSecondary(
158 const std::string& query, 158 const std::string& query,
159 const HistoryData::SecondaryDeque& results) { 159 const HistoryData::SecondaryDeque& results) {
160 scoped_ptr<base::ListValue> results_list(new base::ListValue); 160 scoped_ptr<base::ListValue> results_list(new base::ListValue);
161 for (size_t i = 0; i< results.size(); ++i) 161 for (size_t i = 0; i< results.size(); ++i)
162 results_list->AppendString(results[i]); 162 results_list->AppendString(results[i]);
163 163
164 base::DictionaryValue* entry_dict = GetEntryDict(query); 164 base::DictionaryValue* entry_dict = GetEntryDict(query);
165 entry_dict->SetWithoutPathExpansion(kKeySecondary, results_list.release()); 165 entry_dict->SetWithoutPathExpansion(kKeySecondary, results_list.release());
166 if (data_store_) 166 if (data_store_.get())
167 data_store_->ScheduleWrite(); 167 data_store_->ScheduleWrite();
168 } 168 }
169 169
170 void HistoryDataStore::SetUpdateTime(const std::string& query, 170 void HistoryDataStore::SetUpdateTime(const std::string& query,
171 const base::Time& update_time) { 171 const base::Time& update_time) {
172 base::DictionaryValue* entry_dict = GetEntryDict(query); 172 base::DictionaryValue* entry_dict = GetEntryDict(query);
173 entry_dict->SetWithoutPathExpansion(kKeyUpdateTime, 173 entry_dict->SetWithoutPathExpansion(kKeyUpdateTime,
174 new base::StringValue(base::Int64ToString( 174 new base::StringValue(base::Int64ToString(
175 update_time.ToInternalValue()))); 175 update_time.ToInternalValue())));
176 if (data_store_) 176 if (data_store_.get())
177 data_store_->ScheduleWrite(); 177 data_store_->ScheduleWrite();
178 } 178 }
179 179
180 void HistoryDataStore::Delete(const std::string& query) { 180 void HistoryDataStore::Delete(const std::string& query) {
181 base::DictionaryValue* assoc_dict = GetAssociationDict(); 181 base::DictionaryValue* assoc_dict = GetAssociationDict();
182 assoc_dict->RemoveWithoutPathExpansion(query, NULL); 182 assoc_dict->RemoveWithoutPathExpansion(query, NULL);
183 if (data_store_) 183 if (data_store_.get())
184 data_store_->ScheduleWrite(); 184 data_store_->ScheduleWrite();
185 } 185 }
186 186
187 base::DictionaryValue* HistoryDataStore::GetAssociationDict() { 187 base::DictionaryValue* HistoryDataStore::GetAssociationDict() {
188 base::DictionaryValue* cached_dict = 188 base::DictionaryValue* cached_dict =
189 cached_dict_ ? cached_dict_.get() : data_store_->cached_dict(); 189 cached_dict_ ? cached_dict_.get() : data_store_->cached_dict();
190 DCHECK(cached_dict); 190 DCHECK(cached_dict);
191 191
192 base::DictionaryValue* assoc_dict = NULL; 192 base::DictionaryValue* assoc_dict = NULL;
193 CHECK(cached_dict->GetDictionary(kKeyAssociations, &assoc_dict) && 193 CHECK(cached_dict->GetDictionary(kKeyAssociations, &assoc_dict) &&
(...skipping 19 matching lines...) Expand all
213 void HistoryDataStore::OnDictionaryLoadedCallback( 213 void HistoryDataStore::OnDictionaryLoadedCallback(
214 OnLoadedCallback callback, scoped_ptr<base::DictionaryValue> dict) { 214 OnLoadedCallback callback, scoped_ptr<base::DictionaryValue> dict) {
215 if (!dict) { 215 if (!dict) {
216 callback.Run(scoped_ptr<HistoryData::Associations>()); 216 callback.Run(scoped_ptr<HistoryData::Associations>());
217 } else { 217 } else {
218 callback.Run(Parse(dict.Pass()).Pass()); 218 callback.Run(Parse(dict.Pass()).Pass());
219 } 219 }
220 } 220 }
221 221
222 } // namespace app_list 222 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/net/quota_policy_channel_id_store.cc ('k') | components/variations/variations_seed_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698