| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 return url_request_->response_headers(); | 108 return url_request_->response_headers(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::string URLRequestAdapter::GetNegotiatedProtocol() const { | 111 std::string URLRequestAdapter::GetNegotiatedProtocol() const { |
| 112 if (url_request_ == NULL) | 112 if (url_request_ == NULL) |
| 113 return std::string(); | 113 return std::string(); |
| 114 return url_request_->response_info().npn_negotiated_protocol; | 114 return url_request_->response_info().npn_negotiated_protocol; |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool URLRequestAdapter::GetWasCached() const { |
| 118 if (url_request_ == NULL) |
| 119 return false; |
| 120 return url_request_->response_info().was_cached; |
| 121 } |
| 122 |
| 117 void URLRequestAdapter::Start() { | 123 void URLRequestAdapter::Start() { |
| 118 context_->PostTaskToNetworkThread( | 124 context_->PostTaskToNetworkThread( |
| 119 FROM_HERE, | 125 FROM_HERE, |
| 120 base::Bind(&URLRequestAdapter::OnInitiateConnection, | 126 base::Bind(&URLRequestAdapter::OnInitiateConnection, |
| 121 base::Unretained(this))); | 127 base::Unretained(this))); |
| 122 } | 128 } |
| 123 | 129 |
| 124 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, | 130 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, |
| 125 int bytes_len, bool is_last_chunk) { | 131 int bytes_len, bool is_last_chunk) { |
| 126 DCHECK(OnNetworkThread()); | 132 DCHECK(OnNetworkThread()); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 unsigned char* URLRequestAdapter::Data() const { | 322 unsigned char* URLRequestAdapter::Data() const { |
| 317 DCHECK(OnNetworkThread()); | 323 DCHECK(OnNetworkThread()); |
| 318 return reinterpret_cast<unsigned char*>(read_buffer_->data()); | 324 return reinterpret_cast<unsigned char*>(read_buffer_->data()); |
| 319 } | 325 } |
| 320 | 326 |
| 321 bool URLRequestAdapter::OnNetworkThread() const { | 327 bool URLRequestAdapter::OnNetworkThread() const { |
| 322 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 328 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); |
| 323 } | 329 } |
| 324 | 330 |
| 325 } // namespace cronet | 331 } // namespace cronet |
| OLD | NEW |