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

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

Issue 855023003: Add presubmit check for scoped_ptr usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 5 years, 11 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 | « ui/app_list/search/dictionary_data_store.cc ('k') | ui/app_list/test/test_search_result.cc » ('j') | 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/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
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
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
OLDNEW
« no previous file with comments | « ui/app_list/search/dictionary_data_store.cc ('k') | ui/app_list/test/test_search_result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698