| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/url_request/report_sender.h" | 5 #include "net/url_request/report_sender.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/elements_upload_data_stream.h" | 10 #include "net/base/elements_upload_data_stream.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 URLRequest* raw_url_request = url_request.get(); | 53 URLRequest* raw_url_request = url_request.get(); |
| 54 inflight_requests_.insert(url_request.release()); | 54 inflight_requests_.insert(url_request.release()); |
| 55 raw_url_request->Start(); | 55 raw_url_request->Start(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ReportSender::SetErrorCallback(const ErrorCallback& error_callback) { | 58 void ReportSender::SetErrorCallback(const ErrorCallback& error_callback) { |
| 59 error_callback_ = error_callback; | 59 error_callback_ = error_callback; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ReportSender::OnResponseStarted(URLRequest* request, int net_error) { | 62 void ReportSender::OnResponseStarted(URLRequest* request) { |
| 63 DCHECK_NE(ERR_IO_PENDING, net_error); | 63 if (!request->status().is_success()) { |
| 64 | |
| 65 if (net_error != OK) { | |
| 66 DVLOG(1) << "Failed to send report for " << request->url().host(); | 64 DVLOG(1) << "Failed to send report for " << request->url().host(); |
| 67 if (!error_callback_.is_null()) | 65 if (!error_callback_.is_null()) |
| 68 error_callback_.Run(request->url(), net_error); | 66 error_callback_.Run(request->url(), request->status().error()); |
| 69 } | 67 } |
| 70 | 68 |
| 71 CHECK_GT(inflight_requests_.erase(request), 0u); | 69 CHECK_GT(inflight_requests_.erase(request), 0u); |
| 72 // Clean up the request, which cancels it. | 70 // Clean up the request, which cancels it. |
| 73 delete request; | 71 delete request; |
| 74 } | 72 } |
| 75 | 73 |
| 76 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { | 74 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { |
| 77 NOTREACHED(); | 75 NOTREACHED(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 } // namespace net | 78 } // namespace net |
| OLD | NEW |