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