| 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/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 VLOG(2) << "Report JSON: " << report_json; | 61 VLOG(2) << "Report JSON: " << report_json; |
| 62 | 62 |
| 63 if (discard_uploads_) { | 63 if (discard_uploads_) { |
| 64 VLOG(1) << "Discarding report instead of uploading."; | 64 VLOG(1) << "Discarding report instead of uploading."; |
| 65 callback.Run(true); | 65 callback.Run(true); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 | 68 |
| 69 net::URLFetcher* fetcher = | 69 net::URLFetcher* fetcher = |
| 70 net::URLFetcher::Create(0, upload_url, net::URLFetcher::POST, this); | 70 net::URLFetcher::Create(0, upload_url, net::URLFetcher::POST, this); |
| 71 fetcher->SetRequestContext(url_request_context_getter_); | 71 fetcher->SetRequestContext(url_request_context_getter_.get()); |
| 72 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 72 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 73 net::LOAD_DO_NOT_SAVE_COOKIES); | 73 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 74 fetcher->SetUploadData(kJsonMimeType, report_json); | 74 fetcher->SetUploadData(kJsonMimeType, report_json); |
| 75 fetcher->SetAutomaticallyRetryOn5xx(false); | 75 fetcher->SetAutomaticallyRetryOn5xx(false); |
| 76 fetcher->SetURLRequestUserData( | 76 fetcher->SetURLRequestUserData( |
| 77 UploadUserData::kUserDataKey, | 77 UploadUserData::kUserDataKey, |
| 78 UploadUserData::CreateCreateDataCallback()); | 78 UploadUserData::CreateCreateDataCallback()); |
| 79 fetcher->Start(); | 79 fetcher->Start(); |
| 80 | 80 |
| 81 upload_callbacks_[fetcher] = callback; | 81 upload_callbacks_[fetcher] = callback; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 new DomainReliabilityUploaderImpl(url_request_context_getter)); | 128 new DomainReliabilityUploaderImpl(url_request_context_getter)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 bool DomainReliabilityUploader::URLRequestIsUpload( | 132 bool DomainReliabilityUploader::URLRequestIsUpload( |
| 133 const net::URLRequest& request) { | 133 const net::URLRequest& request) { |
| 134 return request.GetUserData(UploadUserData::kUserDataKey) != NULL; | 134 return request.GetUserData(UploadUserData::kUserDataKey) != NULL; |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace domain_reliability | 137 } // namespace domain_reliability |
| OLD | NEW |