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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
11 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
12 #include "base/debug/dump_without_crashing.h" | 14 #include "base/debug/dump_without_crashing.h" |
13 #include "base/debug/stack_trace.h" | 15 #include "base/debug/stack_trace.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
15 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
16 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 203 |
202 void URLRequest::AppendChunkToUpload(const char* bytes, | 204 void URLRequest::AppendChunkToUpload(const char* bytes, |
203 int bytes_len, | 205 int bytes_len, |
204 bool is_last_chunk) { | 206 bool is_last_chunk) { |
205 DCHECK(upload_data_stream_); | 207 DCHECK(upload_data_stream_); |
206 DCHECK(upload_data_stream_->is_chunked()); | 208 DCHECK(upload_data_stream_->is_chunked()); |
207 upload_chunked_data_stream_->AppendData(bytes, bytes_len, is_last_chunk); | 209 upload_chunked_data_stream_->AppendData(bytes, bytes_len, is_last_chunk); |
208 } | 210 } |
209 | 211 |
210 void URLRequest::set_upload(scoped_ptr<UploadDataStream> upload) { | 212 void URLRequest::set_upload(scoped_ptr<UploadDataStream> upload) { |
211 upload_data_stream_ = upload.Pass(); | 213 upload_data_stream_ = std::move(upload); |
212 } | 214 } |
213 | 215 |
214 const UploadDataStream* URLRequest::get_upload() const { | 216 const UploadDataStream* URLRequest::get_upload() const { |
215 return upload_data_stream_.get(); | 217 return upload_data_stream_.get(); |
216 } | 218 } |
217 | 219 |
218 bool URLRequest::has_upload() const { | 220 bool URLRequest::has_upload() const { |
219 return upload_data_stream_.get() != NULL; | 221 return upload_data_stream_.get() != NULL; |
220 } | 222 } |
221 | 223 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 282 |
281 scoped_ptr<base::Value> URLRequest::GetStateAsValue() const { | 283 scoped_ptr<base::Value> URLRequest::GetStateAsValue() const { |
282 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 284 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
283 dict->SetString("url", original_url().possibly_invalid_spec()); | 285 dict->SetString("url", original_url().possibly_invalid_spec()); |
284 | 286 |
285 if (url_chain_.size() > 1) { | 287 if (url_chain_.size() > 1) { |
286 scoped_ptr<base::ListValue> list(new base::ListValue()); | 288 scoped_ptr<base::ListValue> list(new base::ListValue()); |
287 for (const GURL& url : url_chain_) { | 289 for (const GURL& url : url_chain_) { |
288 list->AppendString(url.possibly_invalid_spec()); | 290 list->AppendString(url.possibly_invalid_spec()); |
289 } | 291 } |
290 dict->Set("url_chain", list.Pass()); | 292 dict->Set("url_chain", std::move(list)); |
291 } | 293 } |
292 | 294 |
293 dict->SetInteger("load_flags", load_flags_); | 295 dict->SetInteger("load_flags", load_flags_); |
294 | 296 |
295 LoadStateWithParam load_state = GetLoadState(); | 297 LoadStateWithParam load_state = GetLoadState(); |
296 dict->SetInteger("load_state", load_state.state); | 298 dict->SetInteger("load_state", load_state.state); |
297 if (!load_state.param.empty()) | 299 if (!load_state.param.empty()) |
298 dict->SetString("load_state_param", load_state.param); | 300 dict->SetString("load_state_param", load_state.param); |
299 if (!blocked_by_.empty()) | 301 if (!blocked_by_.empty()) |
300 dict->SetString("delegate_info", blocked_by_); | 302 dict->SetString("delegate_info", blocked_by_); |
(...skipping 14 matching lines...) Expand all Loading... |
315 break; | 317 break; |
316 case URLRequestStatus::CANCELED: | 318 case URLRequestStatus::CANCELED: |
317 dict->SetString("status", "CANCELED"); | 319 dict->SetString("status", "CANCELED"); |
318 break; | 320 break; |
319 case URLRequestStatus::FAILED: | 321 case URLRequestStatus::FAILED: |
320 dict->SetString("status", "FAILED"); | 322 dict->SetString("status", "FAILED"); |
321 break; | 323 break; |
322 } | 324 } |
323 if (status_.error() != OK) | 325 if (status_.error() != OK) |
324 dict->SetInteger("net_error", status_.error()); | 326 dict->SetInteger("net_error", status_.error()); |
325 return dict.Pass(); | 327 return std::move(dict); |
326 } | 328 } |
327 | 329 |
328 void URLRequest::LogBlockedBy(const char* blocked_by) { | 330 void URLRequest::LogBlockedBy(const char* blocked_by) { |
329 DCHECK(blocked_by); | 331 DCHECK(blocked_by); |
330 DCHECK_GT(strlen(blocked_by), 0u); | 332 DCHECK_GT(strlen(blocked_by), 0u); |
331 | 333 |
332 // Only log information to NetLog during startup and certain deferring calls | 334 // Only log information to NetLog during startup and certain deferring calls |
333 // to delegates. For all reads but the first, do nothing. | 335 // to delegates. For all reads but the first, do nothing. |
334 if (!calling_delegate_ && !response_info_.request_time.is_null()) | 336 if (!calling_delegate_ && !response_info_.request_time.is_null()) |
335 return; | 337 return; |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 } | 1221 } |
1220 | 1222 |
1221 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { | 1223 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { |
1222 if (job_) | 1224 if (job_) |
1223 job_->GetConnectionAttempts(out); | 1225 job_->GetConnectionAttempts(out); |
1224 else | 1226 else |
1225 out->clear(); | 1227 out->clear(); |
1226 } | 1228 } |
1227 | 1229 |
1228 } // namespace net | 1230 } // namespace net |
OLD | NEW |