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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/last_download_finder.cc

Issue 783963003: Removing HistoryService::profile() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/safe_browsing/incident_reporting/last_download_finder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/safe_browsing/incident_reporting/last_download_finder.h " 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 base::Bind(&LastDownloadFinder::OnDownloadQuery, 239 base::Bind(&LastDownloadFinder::OnDownloadQuery,
240 weak_ptr_factory_.GetWeakPtr(), 240 weak_ptr_factory_.GetWeakPtr(),
241 profile)); 241 profile));
242 } else { 242 } else {
243 // else wait until history is loaded. 243 // else wait until history is loaded.
244 history_service_observer_.Add(history_service); 244 history_service_observer_.Add(history_service);
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 void LastDownloadFinder::OnProfileHistoryLoaded(
250 Profile* profile,
251 HistoryService* history_service) {
252 auto iter = profile_states_.find(profile);
253 if (iter == profile_states_.end())
254 return;
255
256 // Start the query in the history service if the finder was waiting for the
257 // service to load.
258 if (iter->second == WAITING_FOR_HISTORY) {
259 history_service->QueryDownloads(
260 base::Bind(&LastDownloadFinder::OnDownloadQuery,
261 weak_ptr_factory_.GetWeakPtr(),
262 profile));
263 }
264 }
265
266 void LastDownloadFinder::AbandonSearchInProfile(Profile* profile) { 249 void LastDownloadFinder::AbandonSearchInProfile(Profile* profile) {
267 // |profile| may not be present in the set of profiles. 250 // |profile| may not be present in the set of profiles.
268 auto iter = profile_states_.find(profile); 251 auto iter = profile_states_.find(profile);
269 if (iter != profile_states_.end()) 252 if (iter != profile_states_.end())
270 RemoveProfileAndReportIfDone(iter); 253 RemoveProfileAndReportIfDone(iter);
271 } 254 }
272 255
273 void LastDownloadFinder::OnDownloadQuery( 256 void LastDownloadFinder::OnDownloadQuery(
274 Profile* profile, 257 Profile* profile,
275 scoped_ptr<std::vector<history::DownloadRow> > downloads) { 258 scoped_ptr<std::vector<history::DownloadRow> > downloads) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 case chrome::NOTIFICATION_PROFILE_DESTROYED: 315 case chrome::NOTIFICATION_PROFILE_DESTROYED:
333 AbandonSearchInProfile(content::Source<Profile>(source).ptr()); 316 AbandonSearchInProfile(content::Source<Profile>(source).ptr());
334 break; 317 break;
335 default: 318 default:
336 break; 319 break;
337 } 320 }
338 } 321 }
339 322
340 void LastDownloadFinder::OnHistoryServiceLoaded( 323 void LastDownloadFinder::OnHistoryServiceLoaded(
341 HistoryService* history_service) { 324 HistoryService* history_service) {
342 OnProfileHistoryLoaded(history_service->profile(), history_service); 325 for (const auto& pair : profile_states_) {
326 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
sky 2014/12/11 19:23:49 IMO the old way is cleaner. Why do you need to rem
327 pair.first, Profile::EXPLICIT_ACCESS);
328 if (hs == history_service) {
329 // Start the query in the history service if the finder was waiting for
330 // the service to load.
331 if (pair.second == WAITING_FOR_HISTORY) {
332 history_service->QueryDownloads(
333 base::Bind(&LastDownloadFinder::OnDownloadQuery,
334 weak_ptr_factory_.GetWeakPtr(),
335 pair.first));
336 }
337 return;
338 }
339 }
343 } 340 }
344 341
345 void LastDownloadFinder::HistoryServiceBeingDeleted( 342 void LastDownloadFinder::HistoryServiceBeingDeleted(
346 HistoryService* history_service) { 343 HistoryService* history_service) {
347 history_service_observer_.Remove(history_service); 344 history_service_observer_.Remove(history_service);
348 } 345 }
349 346
350 } // namespace safe_browsing 347 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/incident_reporting/last_download_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698