| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implementation of the MalwareDetailsRedirectsCollector class. | 5 // Implementation of the MalwareDetailsRedirectsCollector class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/malware_details_history.h" | 7 #include "chrome/browser/safe_browsing/malware_details_history.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 HistoryService* history = HistoryServiceFactory::GetForProfile( | 91 HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 92 profile_, Profile::EXPLICIT_ACCESS); | 92 profile_, Profile::EXPLICIT_ACCESS); |
| 93 if (!history) { | 93 if (!history) { |
| 94 AllDone(); | 94 AllDone(); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 history->QueryRedirectsTo( | 98 history->QueryRedirectsTo( |
| 99 url, | 99 url, |
| 100 &request_consumer_, | |
| 101 base::Bind(&MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo, | 100 base::Bind(&MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo, |
| 102 base::Unretained(this))); | 101 base::Unretained(this), |
| 102 url), |
| 103 &request_tracker_); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo( | 106 void MalwareDetailsRedirectsCollector::OnGotQueryRedirectsTo( |
| 106 HistoryService::Handle handle, | 107 const GURL& url, |
| 107 GURL url, | 108 const history::RedirectList* redirect_list) { |
| 108 bool success, | 109 if (!redirect_list->empty()) { |
| 109 history::RedirectList* redirect_list) { | |
| 110 | |
| 111 if (success && redirect_list->size() > 0) { | |
| 112 std::vector<GURL> urllist; | 110 std::vector<GURL> urllist; |
| 113 urllist.push_back(url); | 111 urllist.push_back(url); |
| 114 for (size_t i = 0; i < redirect_list->size(); i++) { | 112 urllist.insert(urllist.end(), redirect_list->begin(), redirect_list->end()); |
| 115 urllist.push_back(redirect_list->at(i)); | |
| 116 } | |
| 117 redirects_urls_.push_back(urllist); | 113 redirects_urls_.push_back(urllist); |
| 118 } | 114 } |
| 119 | 115 |
| 120 // Proceed to next url | 116 // Proceed to next url |
| 121 ++urls_it_; | 117 ++urls_it_; |
| 122 | 118 |
| 123 if (urls_it_ == urls_.end()) { | 119 if (urls_it_ == urls_.end()) { |
| 124 AllDone(); | 120 AllDone(); |
| 125 return; | 121 return; |
| 126 } | 122 } |
| 127 | 123 |
| 128 GetRedirects(*urls_it_); | 124 GetRedirects(*urls_it_); |
| 129 } | 125 } |
| 130 | 126 |
| 131 void MalwareDetailsRedirectsCollector::AllDone() { | 127 void MalwareDetailsRedirectsCollector::AllDone() { |
| 132 DVLOG(1) << "AllDone"; | 128 DVLOG(1) << "AllDone"; |
| 133 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); | 129 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); |
| 134 callback_.Reset(); | 130 callback_.Reset(); |
| 135 } | 131 } |
| OLD | NEW |