| 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 "components/domain_reliability/uploader.h" | 5 #include "components/domain_reliability/uploader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "components/data_use_measurement/core/data_use_user_data.h" | |
| 13 #include "components/domain_reliability/util.h" | 12 #include "components/domain_reliability/util.h" |
| 14 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
| 15 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 16 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 17 #include "net/http/http_util.h" | 16 #include "net/http/http_util.h" |
| 18 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 18 #include "net/url_request/url_fetcher_delegate.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 21 | 20 |
| 22 namespace domain_reliability { | 21 namespace domain_reliability { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 VLOG(1) << "Discarding report instead of uploading."; | 70 VLOG(1) << "Discarding report instead of uploading."; |
| 72 UploadResult result; | 71 UploadResult result; |
| 73 result.status = UploadResult::SUCCESS; | 72 result.status = UploadResult::SUCCESS; |
| 74 callback.Run(result); | 73 callback.Run(result); |
| 75 return; | 74 return; |
| 76 } | 75 } |
| 77 | 76 |
| 78 net::URLFetcher* fetcher = | 77 net::URLFetcher* fetcher = |
| 79 net::URLFetcher::Create(0, upload_url, net::URLFetcher::POST, this) | 78 net::URLFetcher::Create(0, upload_url, net::URLFetcher::POST, this) |
| 80 .release(); | 79 .release(); |
| 81 data_use_measurement::DataUseUserData::AttachToFetcher( | |
| 82 fetcher, data_use_measurement::DataUseUserData::DOMAIN_RELIABILITY); | |
| 83 fetcher->SetRequestContext(url_request_context_getter_.get()); | 80 fetcher->SetRequestContext(url_request_context_getter_.get()); |
| 84 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 81 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 85 net::LOAD_DO_NOT_SAVE_COOKIES); | 82 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 86 fetcher->SetUploadData(kJsonMimeType, report_json); | 83 fetcher->SetUploadData(kJsonMimeType, report_json); |
| 87 fetcher->SetAutomaticallyRetryOn5xx(false); | 84 fetcher->SetAutomaticallyRetryOn5xx(false); |
| 88 fetcher->SetURLRequestUserData( | 85 fetcher->SetURLRequestUserData( |
| 89 UploadUserData::kUserDataKey, | 86 UploadUserData::kUserDataKey, |
| 90 UploadUserData::CreateCreateDataCallback()); | 87 UploadUserData::CreateCreateDataCallback()); |
| 91 fetcher->Start(); | 88 fetcher->Start(); |
| 92 | 89 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 new DomainReliabilityUploaderImpl(time, url_request_context_getter)); | 161 new DomainReliabilityUploaderImpl(time, url_request_context_getter)); |
| 165 } | 162 } |
| 166 | 163 |
| 167 // static | 164 // static |
| 168 bool DomainReliabilityUploader::URLRequestIsUpload( | 165 bool DomainReliabilityUploader::URLRequestIsUpload( |
| 169 const net::URLRequest& request) { | 166 const net::URLRequest& request) { |
| 170 return request.GetUserData(UploadUserData::kUserDataKey) != nullptr; | 167 return request.GetUserData(UploadUserData::kUserDataKey) != nullptr; |
| 171 } | 168 } |
| 172 | 169 |
| 173 } // namespace domain_reliability | 170 } // namespace domain_reliability |
| OLD | NEW |