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/history_data_store.h" | 5 #include "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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // "t" : "last_update_timestamp" | 52 // "t" : "last_update_timestamp" |
53 // }, | 53 // }, |
54 // ... | 54 // ... |
55 // } | 55 // } |
56 // } | 56 // } |
57 scoped_ptr<HistoryData::Associations> Parse( | 57 scoped_ptr<HistoryData::Associations> Parse( |
58 scoped_ptr<base::DictionaryValue> dict) { | 58 scoped_ptr<base::DictionaryValue> dict) { |
59 std::string version; | 59 std::string version; |
60 if (!dict->GetStringWithoutPathExpansion(kKeyVersion, &version) || | 60 if (!dict->GetStringWithoutPathExpansion(kKeyVersion, &version) || |
61 version != kCurrentVersion) { | 61 version != kCurrentVersion) { |
62 return scoped_ptr<HistoryData::Associations>(); | 62 return nullptr; |
63 } | 63 } |
64 | 64 |
65 const base::DictionaryValue* assoc_dict = NULL; | 65 const base::DictionaryValue* assoc_dict = NULL; |
66 if (!dict->GetDictionaryWithoutPathExpansion(kKeyAssociations, &assoc_dict) || | 66 if (!dict->GetDictionaryWithoutPathExpansion(kKeyAssociations, &assoc_dict) || |
67 !assoc_dict) { | 67 !assoc_dict) { |
68 return scoped_ptr<HistoryData::Associations>(); | 68 return nullptr; |
69 } | 69 } |
70 | 70 |
71 scoped_ptr<HistoryData::Associations> data(new HistoryData::Associations); | 71 scoped_ptr<HistoryData::Associations> data(new HistoryData::Associations); |
72 for (base::DictionaryValue::Iterator it(*assoc_dict); !it.IsAtEnd(); | 72 for (base::DictionaryValue::Iterator it(*assoc_dict); !it.IsAtEnd(); |
73 it.Advance()) { | 73 it.Advance()) { |
74 const base::DictionaryValue* entry_dict = NULL; | 74 const base::DictionaryValue* entry_dict = NULL; |
75 if (!it.value().GetAsDictionary(&entry_dict)) | 75 if (!it.value().GetAsDictionary(&entry_dict)) |
76 continue; | 76 continue; |
77 | 77 |
78 std::string primary; | 78 std::string primary; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 assoc_dict->SetWithoutPathExpansion(query, entry_dict); | 205 assoc_dict->SetWithoutPathExpansion(query, entry_dict); |
206 } | 206 } |
207 | 207 |
208 return entry_dict; | 208 return entry_dict; |
209 } | 209 } |
210 | 210 |
211 void HistoryDataStore::OnDictionaryLoadedCallback( | 211 void HistoryDataStore::OnDictionaryLoadedCallback( |
212 OnLoadedCallback callback, | 212 OnLoadedCallback callback, |
213 scoped_ptr<base::DictionaryValue> dict) { | 213 scoped_ptr<base::DictionaryValue> dict) { |
214 if (!dict) { | 214 if (!dict) { |
215 callback.Run(scoped_ptr<HistoryData::Associations>()); | 215 callback.Run(nullptr); |
216 } else { | 216 } else { |
217 callback.Run(Parse(dict.Pass()).Pass()); | 217 callback.Run(Parse(dict.Pass()).Pass()); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 } // namespace app_list | 221 } // namespace app_list |
OLD | NEW |