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 ThreatDetails class. | 5 // Implementation of the ThreatDetails class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/threat_details.h" | 7 #include "chrome/browser/safe_browsing/threat_details.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/md5.h" | 13 #include "base/md5.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
16 #include "chrome/browser/safe_browsing/threat_details_cache.h" | 16 #include "chrome/browser/safe_browsing/threat_details_cache.h" |
17 #include "chrome/common/safe_browsing/csd.pb.h" | 17 #include "chrome/common/safe_browsing/csd.pb.h" |
| 18 #include "components/data_use_measurement/core/data_use_user_data.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
22 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
23 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
25 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
26 | 27 |
27 using content::BrowserThread; | 28 using content::BrowserThread; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 76 } |
76 | 77 |
77 if (!request_context_getter_.get()) { | 78 if (!request_context_getter_.get()) { |
78 DVLOG(1) << "Missing request context getter"; | 79 DVLOG(1) << "Missing request context getter"; |
79 AllDone(false); | 80 AllDone(false); |
80 return; | 81 return; |
81 } | 82 } |
82 | 83 |
83 current_fetch_ = net::URLFetcher::Create(GURL(resources_it_->first), | 84 current_fetch_ = net::URLFetcher::Create(GURL(resources_it_->first), |
84 net::URLFetcher::GET, this); | 85 net::URLFetcher::GET, this); |
| 86 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 87 current_fetch_.get(), |
| 88 data_use_measurement::DataUseUserData::SAFE_BROWSING); |
85 current_fetch_->SetRequestContext(request_context_getter_.get()); | 89 current_fetch_->SetRequestContext(request_context_getter_.get()); |
86 // Only from cache, and don't save cookies. | 90 // Only from cache, and don't save cookies. |
87 current_fetch_->SetLoadFlags(net::LOAD_ONLY_FROM_CACHE | | 91 current_fetch_->SetLoadFlags(net::LOAD_ONLY_FROM_CACHE | |
88 net::LOAD_DO_NOT_SAVE_COOKIES); | 92 net::LOAD_DO_NOT_SAVE_COOKIES); |
89 current_fetch_->SetAutomaticallyRetryOn5xx(false); // No retries. | 93 current_fetch_->SetAutomaticallyRetryOn5xx(false); // No retries. |
90 current_fetch_->Start(); // OnURLFetchComplete will be called when done. | 94 current_fetch_->Start(); // OnURLFetchComplete will be called when done. |
91 } | 95 } |
92 | 96 |
93 ClientSafeBrowsingReportRequest::Resource* | 97 ClientSafeBrowsingReportRequest::Resource* |
94 ThreatDetailsCacheCollector::GetResource(const GURL& url) { | 98 ThreatDetailsCacheCollector::GetResource(const GURL& url) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 203 |
200 void ThreatDetailsCacheCollector::AllDone(bool success) { | 204 void ThreatDetailsCacheCollector::AllDone(bool success) { |
201 DVLOG(1) << "AllDone"; | 205 DVLOG(1) << "AllDone"; |
202 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 206 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
203 *result_ = success; | 207 *result_ = success; |
204 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); | 208 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, callback_); |
205 callback_.Reset(); | 209 callback_.Reset(); |
206 } | 210 } |
207 | 211 |
208 } // namespace safe_browsing | 212 } // namespace safe_browsing |
OLD | NEW |