| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "url_request_adapter.h" | 5 #include "url_request_adapter.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 void URLRequestAdapter::OnInitiateConnection() { | 137 void URLRequestAdapter::OnInitiateConnection() { |
| 138 DCHECK(OnNetworkThread()); | 138 DCHECK(OnNetworkThread()); |
| 139 if (canceled_) { | 139 if (canceled_) { |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 VLOG(1) << "Starting chromium request: " | 143 VLOG(1) << "Starting chromium request: " |
| 144 << url_.possibly_invalid_spec().c_str() | 144 << url_.possibly_invalid_spec().c_str() |
| 145 << " priority: " << RequestPriorityToString(priority_); | 145 << " priority: " << RequestPriorityToString(priority_); |
| 146 url_request_ = context_->GetURLRequestContext()->CreateRequest( | 146 url_request_ = context_->GetURLRequestContext()->CreateRequest( |
| 147 url_, net::DEFAULT_PRIORITY, this, NULL); | 147 url_, net::DEFAULT_PRIORITY, this); |
| 148 int flags = net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES; | 148 int flags = net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES; |
| 149 if (context_->load_disable_cache()) | 149 if (context_->load_disable_cache()) |
| 150 flags |= net::LOAD_DISABLE_CACHE; | 150 flags |= net::LOAD_DISABLE_CACHE; |
| 151 url_request_->SetLoadFlags(flags); | 151 url_request_->SetLoadFlags(flags); |
| 152 url_request_->set_method(method_); | 152 url_request_->set_method(method_); |
| 153 url_request_->SetExtraRequestHeaders(headers_); | 153 url_request_->SetExtraRequestHeaders(headers_); |
| 154 if (!headers_.HasHeader(net::HttpRequestHeaders::kUserAgent)) { | 154 if (!headers_.HasHeader(net::HttpRequestHeaders::kUserAgent)) { |
| 155 std::string user_agent; | 155 std::string user_agent; |
| 156 user_agent = context_->GetUserAgent(url_); | 156 user_agent = context_->GetUserAgent(url_); |
| 157 url_request_->SetExtraRequestHeaderByName( | 157 url_request_->SetExtraRequestHeaderByName( |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 unsigned char* URLRequestAdapter::Data() const { | 316 unsigned char* URLRequestAdapter::Data() const { |
| 317 DCHECK(OnNetworkThread()); | 317 DCHECK(OnNetworkThread()); |
| 318 return reinterpret_cast<unsigned char*>(read_buffer_->data()); | 318 return reinterpret_cast<unsigned char*>(read_buffer_->data()); |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool URLRequestAdapter::OnNetworkThread() const { | 321 bool URLRequestAdapter::OnNetworkThread() const { |
| 322 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 322 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace cronet | 325 } // namespace cronet |
| OLD | NEW |