| 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 "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
| 9 #include "net/http/http_status_code.h" | 9 #include "net/http/http_status_code.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 context_->GetNetworkTaskRunner()->PostTask( | 64 context_->GetNetworkTaskRunner()->PostTask( |
| 65 FROM_HERE, | 65 FROM_HERE, |
| 66 base::Bind(&URLRequestPeer::OnAppendChunk, | 66 base::Bind(&URLRequestPeer::OnAppendChunk, |
| 67 base::Unretained(this), | 67 base::Unretained(this), |
| 68 bytes, | 68 bytes, |
| 69 bytes_len, | 69 bytes_len, |
| 70 is_last_chunk)); | 70 is_last_chunk)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 |
| 74 std::string URLRequestPeer::GetHeader(const std::string &name) const { |
| 75 std::string value; |
| 76 if (url_request_ != NULL) { |
| 77 url_request_->GetResponseHeaderByName(name, &value); |
| 78 } |
| 79 return value; |
| 80 } |
| 81 |
| 73 void URLRequestPeer::Start() { | 82 void URLRequestPeer::Start() { |
| 74 context_->GetNetworkTaskRunner()->PostTask( | 83 context_->GetNetworkTaskRunner()->PostTask( |
| 75 FROM_HERE, | 84 FROM_HERE, |
| 76 base::Bind(&URLRequestPeer::OnInitiateConnection, | 85 base::Bind(&URLRequestPeer::OnInitiateConnection, |
| 77 base::Unretained(this))); | 86 base::Unretained(this))); |
| 78 } | 87 } |
| 79 | 88 |
| 80 void URLRequestPeer::OnAppendChunk(const char* bytes, | 89 void URLRequestPeer::OnAppendChunk(const char* bytes, |
| 81 int bytes_len, | 90 int bytes_len, |
| 82 bool is_last_chunk) { | 91 bool is_last_chunk) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 284 |
| 276 delegate_->OnBytesRead(this); | 285 delegate_->OnBytesRead(this); |
| 277 delegate_->OnRequestFinished(this); | 286 delegate_->OnRequestFinished(this); |
| 278 } | 287 } |
| 279 | 288 |
| 280 unsigned char* URLRequestPeer::Data() const { | 289 unsigned char* URLRequestPeer::Data() const { |
| 281 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); | 290 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); |
| 282 } | 291 } |
| 283 | 292 |
| 284 } // namespace cronet | 293 } // namespace cronet |
| OLD | NEW |