| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/url_request.h" | 5 #include "net/url_request/url_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "net/base/auth.h" | 23 #include "net/base/auth.h" |
| 24 #include "net/base/chunked_upload_data_stream.h" | |
| 25 #include "net/base/host_port_pair.h" | 24 #include "net/base/host_port_pair.h" |
| 26 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 27 #include "net/base/load_timing_info.h" | 26 #include "net/base/load_timing_info.h" |
| 28 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 29 #include "net/base/network_change_notifier.h" | 28 #include "net/base/network_change_notifier.h" |
| 30 #include "net/base/network_delegate.h" | 29 #include "net/base/network_delegate.h" |
| 31 #include "net/base/upload_data_stream.h" | 30 #include "net/base/upload_data_stream.h" |
| 32 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
| 33 #include "net/http/http_util.h" | 32 #include "net/http/http_util.h" |
| 34 #include "net/log/net_log.h" | 33 #include "net/log/net_log.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 CHECK_EQ(1, deleted); | 183 CHECK_EQ(1, deleted); |
| 185 | 184 |
| 186 int net_error = OK; | 185 int net_error = OK; |
| 187 // Log error only on failure, not cancellation, as even successful requests | 186 // Log error only on failure, not cancellation, as even successful requests |
| 188 // are "cancelled" on destruction. | 187 // are "cancelled" on destruction. |
| 189 if (status_.status() == URLRequestStatus::FAILED) | 188 if (status_.status() == URLRequestStatus::FAILED) |
| 190 net_error = status_.error(); | 189 net_error = status_.error(); |
| 191 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error); | 190 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error); |
| 192 } | 191 } |
| 193 | 192 |
| 194 void URLRequest::EnableChunkedUpload() { | |
| 195 DCHECK(!upload_data_stream_ || upload_data_stream_->is_chunked()); | |
| 196 if (!upload_data_stream_) { | |
| 197 upload_chunked_data_stream_ = new ChunkedUploadDataStream(0); | |
| 198 upload_data_stream_.reset(upload_chunked_data_stream_); | |
| 199 } | |
| 200 } | |
| 201 | |
| 202 void URLRequest::AppendChunkToUpload(const char* bytes, | |
| 203 int bytes_len, | |
| 204 bool is_last_chunk) { | |
| 205 DCHECK(upload_data_stream_); | |
| 206 DCHECK(upload_data_stream_->is_chunked()); | |
| 207 upload_chunked_data_stream_->AppendData(bytes, bytes_len, is_last_chunk); | |
| 208 } | |
| 209 | |
| 210 void URLRequest::set_upload(scoped_ptr<UploadDataStream> upload) { | 193 void URLRequest::set_upload(scoped_ptr<UploadDataStream> upload) { |
| 211 upload_data_stream_ = std::move(upload); | 194 upload_data_stream_ = std::move(upload); |
| 212 } | 195 } |
| 213 | 196 |
| 214 const UploadDataStream* URLRequest::get_upload() const { | 197 const UploadDataStream* URLRequest::get_upload() const { |
| 215 return upload_data_stream_.get(); | 198 return upload_data_stream_.get(); |
| 216 } | 199 } |
| 217 | 200 |
| 218 bool URLRequest::has_upload() const { | 201 bool URLRequest::has_upload() const { |
| 219 return upload_data_stream_.get() != NULL; | 202 return upload_data_stream_.get() != NULL; |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1200 } |
| 1218 | 1201 |
| 1219 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { | 1202 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 1220 if (job_) | 1203 if (job_) |
| 1221 job_->GetConnectionAttempts(out); | 1204 job_->GetConnectionAttempts(out); |
| 1222 else | 1205 else |
| 1223 out->clear(); | 1206 out->clear(); |
| 1224 } | 1207 } |
| 1225 | 1208 |
| 1226 } // namespace net | 1209 } // namespace net |
| OLD | NEW |