| 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_peer.h" | 5 #include "url_request_peer.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "components/cronet/android/url_request_context_peer.h" | 8 #include "components/cronet/android/url_request_context_peer.h" |
| 9 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" | 9 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" |
| 10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string URLRequestPeer::GetHeader(const std::string &name) const { | 62 std::string URLRequestPeer::GetHeader(const std::string &name) const { |
| 63 std::string value; | 63 std::string value; |
| 64 if (url_request_ != NULL) { | 64 if (url_request_ != NULL) { |
| 65 url_request_->GetResponseHeaderByName(name, &value); | 65 url_request_->GetResponseHeaderByName(name, &value); |
| 66 } | 66 } |
| 67 return value; | 67 return value; |
| 68 } | 68 } |
| 69 | 69 |
| 70 net::HttpResponseHeaders* URLRequestPeer::response_headers() const { |
| 71 if (url_request_ == NULL) { |
| 72 return NULL; |
| 73 } |
| 74 return url_request_->response_headers(); |
| 75 } |
| 76 |
| 70 void URLRequestPeer::Start() { | 77 void URLRequestPeer::Start() { |
| 71 context_->GetNetworkTaskRunner()->PostTask( | 78 context_->GetNetworkTaskRunner()->PostTask( |
| 72 FROM_HERE, | 79 FROM_HERE, |
| 73 base::Bind(&URLRequestPeer::OnInitiateConnection, | 80 base::Bind(&URLRequestPeer::OnInitiateConnection, |
| 74 base::Unretained(this))); | 81 base::Unretained(this))); |
| 75 } | 82 } |
| 76 | 83 |
| 77 void URLRequestPeer::OnInitiateConnection() { | 84 void URLRequestPeer::OnInitiateConnection() { |
| 78 if (canceled_) { | 85 if (canceled_) { |
| 79 return; | 86 return; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 258 |
| 252 delegate_->OnBytesRead(this); | 259 delegate_->OnBytesRead(this); |
| 253 delegate_->OnRequestFinished(this); | 260 delegate_->OnRequestFinished(this); |
| 254 } | 261 } |
| 255 | 262 |
| 256 unsigned char* URLRequestPeer::Data() const { | 263 unsigned char* URLRequestPeer::Data() const { |
| 257 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); | 264 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); |
| 258 } | 265 } |
| 259 | 266 |
| 260 } // namespace cronet | 267 } // namespace cronet |
| OLD | NEW |