| 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) { | 62 void ReportSender::OnResponseStarted(URLRequest* request, int net_error) { |
| 63 if (!request->status().is_success()) { | 63 DCHECK_NE(ERR_IO_PENDING, net_error); |
| 64 |
| 65 if (net_error != OK) { |
| 64 DVLOG(1) << "Failed to send report for " << request->url().host(); | 66 DVLOG(1) << "Failed to send report for " << request->url().host(); |
| 65 if (!error_callback_.is_null()) | 67 if (!error_callback_.is_null()) |
| 66 error_callback_.Run(request->url(), request->status().error()); | 68 error_callback_.Run(request->url(), net_error); |
| 67 } | 69 } |
| 68 | 70 |
| 69 CHECK_GT(inflight_requests_.erase(request), 0u); | 71 CHECK_GT(inflight_requests_.erase(request), 0u); |
| 70 // Clean up the request, which cancels it. | 72 // Clean up the request, which cancels it. |
| 71 delete request; | 73 delete request; |
| 72 } | 74 } |
| 73 | 75 |
| 74 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { | 76 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { |
| 75 NOTREACHED(); | 77 NOTREACHED(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 } // namespace net | 80 } // namespace net |
| OLD | NEW |