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" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 void URLRequest::SetExtraRequestHeaders( | 216 void URLRequest::SetExtraRequestHeaders( |
217 const HttpRequestHeaders& headers) { | 217 const HttpRequestHeaders& headers) { |
218 DCHECK(!is_pending_); | 218 DCHECK(!is_pending_); |
219 extra_request_headers_ = headers; | 219 extra_request_headers_ = headers; |
220 | 220 |
221 // NOTE: This method will likely become non-trivial once the other setters | 221 // NOTE: This method will likely become non-trivial once the other setters |
222 // for request headers are implemented. | 222 // for request headers are implemented. |
223 } | 223 } |
224 | 224 |
| 225 void URLRequest::set_default_user_agent(const std::string& default_user_agent) { |
| 226 has_default_user_agent_ = true; |
| 227 default_user_agent_ = default_user_agent; |
| 228 } |
| 229 |
| 230 bool URLRequest::has_default_user_agent() const { |
| 231 return has_default_user_agent_; |
| 232 } |
| 233 |
225 bool URLRequest::GetFullRequestHeaders(HttpRequestHeaders* headers) const { | 234 bool URLRequest::GetFullRequestHeaders(HttpRequestHeaders* headers) const { |
226 if (!job_.get()) | 235 if (!job_.get()) |
227 return false; | 236 return false; |
228 | 237 |
229 return job_->GetFullRequestHeaders(headers); | 238 return job_->GetFullRequestHeaders(headers); |
230 } | 239 } |
231 | 240 |
232 int64_t URLRequest::GetTotalReceivedBytes() const { | 241 int64_t URLRequest::GetTotalReceivedBytes() const { |
233 if (!job_.get()) | 242 if (!job_.get()) |
234 return 0; | 243 return 0; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 NetworkDelegate* network_delegate) | 555 NetworkDelegate* network_delegate) |
547 : context_(context), | 556 : context_(context), |
548 network_delegate_(network_delegate ? network_delegate | 557 network_delegate_(network_delegate ? network_delegate |
549 : context->network_delegate()), | 558 : context->network_delegate()), |
550 net_log_( | 559 net_log_( |
551 BoundNetLog::Make(context->net_log(), NetLog::SOURCE_URL_REQUEST)), | 560 BoundNetLog::Make(context->net_log(), NetLog::SOURCE_URL_REQUEST)), |
552 url_chain_(1, url), | 561 url_chain_(1, url), |
553 method_("GET"), | 562 method_("GET"), |
554 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | 563 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), |
555 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), | 564 first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL), |
| 565 has_default_user_agent_(false), |
556 load_flags_(LOAD_NORMAL), | 566 load_flags_(LOAD_NORMAL), |
557 delegate_(delegate), | 567 delegate_(delegate), |
558 is_pending_(false), | 568 is_pending_(false), |
559 is_redirecting_(false), | 569 is_redirecting_(false), |
560 redirect_limit_(kMaxRedirects), | 570 redirect_limit_(kMaxRedirects), |
561 priority_(priority), | 571 priority_(priority), |
562 identifier_(GenerateURLRequestIdentifier()), | 572 identifier_(GenerateURLRequestIdentifier()), |
563 calling_delegate_(false), | 573 calling_delegate_(false), |
564 use_blocked_by_as_load_param_(false), | 574 use_blocked_by_as_load_param_(false), |
565 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, | 575 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 out->clear(); | 1220 out->clear(); |
1211 } | 1221 } |
1212 | 1222 |
1213 void URLRequest::set_status(URLRequestStatus status) { | 1223 void URLRequest::set_status(URLRequestStatus status) { |
1214 DCHECK(status_.is_io_pending() || status_.is_success() || | 1224 DCHECK(status_.is_io_pending() || status_.is_success() || |
1215 (!status.is_success() && !status.is_io_pending())); | 1225 (!status.is_success() && !status.is_io_pending())); |
1216 status_ = status; | 1226 status_ = status; |
1217 } | 1227 } |
1218 | 1228 |
1219 } // namespace net | 1229 } // namespace net |
OLD | NEW |