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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/history_data.h ('k') | ui/app_list/search/history_data_store.h » ('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.h" 5 #include "ui/app_list/search/history_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 std::find(secondary.begin(), secondary.end(), result_id); 90 std::find(secondary.begin(), secondary.end(), result_id);
91 if (secondary_it != secondary.end()) 91 if (secondary_it != secondary.end())
92 secondary.erase(secondary_it); 92 secondary.erase(secondary_it);
93 93
94 secondary.push_back(result_id); 94 secondary.push_back(result_id);
95 if (secondary.size() > max_secondary_) 95 if (secondary.size() > max_secondary_)
96 secondary.pop_front(); 96 secondary.pop_front();
97 store_->SetSecondary(query, secondary); 97 store_->SetSecondary(query, secondary);
98 } 98 }
99 99
100 scoped_ptr<KnownResults> HistoryData::GetKnownResults( 100 std::unique_ptr<KnownResults> HistoryData::GetKnownResults(
101 const std::string& query) const { 101 const std::string& query) const {
102 scoped_ptr<KnownResults> results(new KnownResults); 102 std::unique_ptr<KnownResults> results(new KnownResults);
103 for (Associations::const_iterator assoc_it = associations_.lower_bound(query); 103 for (Associations::const_iterator assoc_it = associations_.lower_bound(query);
104 assoc_it != associations_.end(); 104 assoc_it != associations_.end();
105 ++assoc_it) { 105 ++assoc_it) {
106 // Break out of the loop if |query| is no longer a prefix. 106 // Break out of the loop if |query| is no longer a prefix.
107 if (assoc_it->first.size() < query.size() || 107 if (assoc_it->first.size() < query.size() ||
108 strncmp(assoc_it->first.c_str(), query.c_str(), query.length()) != 0) { 108 strncmp(assoc_it->first.c_str(), query.c_str(), query.length()) != 0) {
109 break; 109 break;
110 } 110 }
111 111
112 const bool perfect = assoc_it->first == query; 112 const bool perfect = assoc_it->first == query;
(...skipping 21 matching lines...) Expand all
134 } 134 }
135 135
136 void HistoryData::AddObserver(HistoryDataObserver* observer) { 136 void HistoryData::AddObserver(HistoryDataObserver* observer) {
137 observers_.AddObserver(observer); 137 observers_.AddObserver(observer);
138 } 138 }
139 139
140 void HistoryData::RemoveObserver(HistoryDataObserver* observer) { 140 void HistoryData::RemoveObserver(HistoryDataObserver* observer) {
141 observers_.RemoveObserver(observer); 141 observers_.RemoveObserver(observer);
142 } 142 }
143 143
144 void HistoryData::OnStoreLoaded(scoped_ptr<Associations> loaded_data) { 144 void HistoryData::OnStoreLoaded(std::unique_ptr<Associations> loaded_data) {
145 if (loaded_data) 145 if (loaded_data)
146 loaded_data->swap(associations_); 146 loaded_data->swap(associations_);
147 147
148 FOR_EACH_OBSERVER( 148 FOR_EACH_OBSERVER(
149 HistoryDataObserver, observers_, OnHistoryDataLoadedFromStore()); 149 HistoryDataObserver, observers_, OnHistoryDataLoadedFromStore());
150 } 150 }
151 151
152 void HistoryData::TrimEntries() { 152 void HistoryData::TrimEntries() {
153 if (associations_.size() <= max_primary_) 153 if (associations_.size() <= max_primary_)
154 return; 154 return;
(...skipping 12 matching lines...) Expand all
167 &EntrySortByTimeAscending); 167 &EntrySortByTimeAscending);
168 168
169 for (size_t i = 0; i < entries_to_remove; ++i) { 169 for (size_t i = 0; i < entries_to_remove; ++i) {
170 const std::string& query = *entries[i].query; 170 const std::string& query = *entries[i].query;
171 store_->Delete(query); 171 store_->Delete(query);
172 associations_.erase(query); 172 associations_.erase(query);
173 } 173 }
174 } 174 }
175 175
176 } // namespace app_list 176 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/search/history_data.h ('k') | ui/app_list/search/history_data_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698