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

Side by Side Diff: chrome/browser/search/suggestions/suggestions_ui.cc

Issue 2568133005: [SuggestionsService] Split SuggestionsService interface from impl (Closed)
Patch Set: Moved impl to dedicated file. Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/search/suggestions/suggestions_ui.h" 5 #include "chrome/browser/search/suggestions/suggestions_ui.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (!suggestions_service) { 193 if (!suggestions_service) {
194 std::string output = RenderOutputHtmlNoSuggestions(is_refresh); 194 std::string output = RenderOutputHtmlNoSuggestions(is_refresh);
195 callback.Run(base::RefCountedString::TakeString(&output)); 195 callback.Run(base::RefCountedString::TakeString(&output));
196 return; 196 return;
197 } 197 }
198 198
199 if (is_refresh) 199 if (is_refresh)
200 suggestions_service->FetchSuggestionsData(); 200 suggestions_service->FetchSuggestionsData();
201 201
202 SuggestionsProfile suggestions_profile = 202 SuggestionsProfile suggestions_profile =
203 suggestions_service->GetSuggestionsDataFromCache(); 203 suggestions_service->GetSuggestionsDataFromCache().value_or(
204 SuggestionsProfile());
204 size_t size = suggestions_profile.suggestions_size(); 205 size_t size = suggestions_profile.suggestions_size();
205 if (!size) { 206 if (!size) {
206 std::string output = RenderOutputHtmlNoSuggestions(is_refresh); 207 std::string output = RenderOutputHtmlNoSuggestions(is_refresh);
207 callback.Run(base::RefCountedString::TakeString(&output)); 208 callback.Run(base::RefCountedString::TakeString(&output));
208 } else { 209 } else {
209 RequestContext* context = 210 RequestContext* context =
210 new RequestContext(is_refresh, suggestions_profile, callback); 211 new RequestContext(is_refresh, suggestions_profile, callback);
211 base::Closure barrier = BarrierClosure( 212 base::Closure barrier = BarrierClosure(
212 size, base::Bind(&SuggestionsSource::OnThumbnailsFetched, 213 size, base::Bind(&SuggestionsSource::OnThumbnailsFetched,
213 weak_ptr_factory_.GetWeakPtr(), context)); 214 weak_ptr_factory_.GetWeakPtr(), context));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 263
263 SuggestionsUI::SuggestionsUI(content::WebUI* web_ui) 264 SuggestionsUI::SuggestionsUI(content::WebUI* web_ui)
264 : content::WebUIController(web_ui) { 265 : content::WebUIController(web_ui) {
265 Profile* profile = Profile::FromWebUI(web_ui); 266 Profile* profile = Profile::FromWebUI(web_ui);
266 content::URLDataSource::Add(profile, new SuggestionsSource(profile)); 267 content::URLDataSource::Add(profile, new SuggestionsSource(profile));
267 } 268 }
268 269
269 SuggestionsUI::~SuggestionsUI() {} 270 SuggestionsUI::~SuggestionsUI() {}
270 271
271 } // namespace suggestions 272 } // namespace suggestions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698