| OLD | NEW |
| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 if (details) { | 220 if (details) { |
| 221 if (IsMostInteresting(*details, details_.get(), most_recent_row_)) { | 221 if (IsMostInteresting(*details, details_.get(), most_recent_row_)) { |
| 222 details_ = details.Pass(); | 222 details_ = details.Pass(); |
| 223 most_recent_row_.end_time = base::Time(); | 223 most_recent_row_.end_time = base::Time(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 RemoveProfileAndReportIfDone(iter); | 226 RemoveProfileAndReportIfDone(iter); |
| 227 } else { | 227 } else { |
| 228 // Search history since no metadata was found. | 228 // Search history since no metadata was found. |
| 229 iter->second = WAITING_FOR_HISTORY; | 229 iter->second = WAITING_FOR_HISTORY; |
| 230 HistoryService* history_service = | 230 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 231 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 231 profile, ServiceAccessType::IMPLICIT_ACCESS); |
| 232 // No history service is returned for profiles that do not save history. | 232 // No history service is returned for profiles that do not save history. |
| 233 if (!history_service) { | 233 if (!history_service) { |
| 234 RemoveProfileAndReportIfDone(iter); | 234 RemoveProfileAndReportIfDone(iter); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 if (history_service->BackendLoaded()) { | 237 if (history_service->BackendLoaded()) { |
| 238 history_service->QueryDownloads( | 238 history_service->QueryDownloads( |
| 239 base::Bind(&LastDownloadFinder::OnDownloadQuery, | 239 base::Bind(&LastDownloadFinder::OnDownloadQuery, |
| 240 weak_ptr_factory_.GetWeakPtr(), | 240 weak_ptr_factory_.GetWeakPtr(), |
| 241 profile)); | 241 profile)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 break; | 317 break; |
| 318 default: | 318 default: |
| 319 break; | 319 break; |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 void LastDownloadFinder::OnHistoryServiceLoaded( | 323 void LastDownloadFinder::OnHistoryServiceLoaded( |
| 324 HistoryService* history_service) { | 324 HistoryService* history_service) { |
| 325 for (const auto& pair : profile_states_) { | 325 for (const auto& pair : profile_states_) { |
| 326 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( | 326 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 327 pair.first, Profile::EXPLICIT_ACCESS); | 327 pair.first, ServiceAccessType::EXPLICIT_ACCESS); |
| 328 if (hs == history_service) { | 328 if (hs == history_service) { |
| 329 // Start the query in the history service if the finder was waiting for | 329 // Start the query in the history service if the finder was waiting for |
| 330 // the service to load. | 330 // the service to load. |
| 331 if (pair.second == WAITING_FOR_HISTORY) { | 331 if (pair.second == WAITING_FOR_HISTORY) { |
| 332 history_service->QueryDownloads( | 332 history_service->QueryDownloads( |
| 333 base::Bind(&LastDownloadFinder::OnDownloadQuery, | 333 base::Bind(&LastDownloadFinder::OnDownloadQuery, |
| 334 weak_ptr_factory_.GetWeakPtr(), | 334 weak_ptr_factory_.GetWeakPtr(), |
| 335 pair.first)); | 335 pair.first)); |
| 336 } | 336 } |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 void LastDownloadFinder::HistoryServiceBeingDeleted( | 342 void LastDownloadFinder::HistoryServiceBeingDeleted( |
| 343 HistoryService* history_service) { | 343 HistoryService* history_service) { |
| 344 history_service_observer_.Remove(history_service); | 344 history_service_observer_.Remove(history_service); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace safe_browsing | 347 } // namespace safe_browsing |
| OLD | NEW |