| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 chunked_upload_ = true; | 79 chunked_upload_ = true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void URLRequestAdapter::AppendChunk(const char* bytes, int bytes_len, | 82 void URLRequestAdapter::AppendChunk(const char* bytes, int bytes_len, |
| 83 bool is_last_chunk) { | 83 bool is_last_chunk) { |
| 84 VLOG(1) << "AppendChunk, len: " << bytes_len << ", last: " << is_last_chunk; | 84 VLOG(1) << "AppendChunk, len: " << bytes_len << ", last: " << is_last_chunk; |
| 85 scoped_ptr<char[]> buf(new char[bytes_len]); | 85 scoped_ptr<char[]> buf(new char[bytes_len]); |
| 86 memcpy(buf.get(), bytes, bytes_len); | 86 memcpy(buf.get(), bytes, bytes_len); |
| 87 context_->PostTaskToNetworkThread( | 87 context_->PostTaskToNetworkThread( |
| 88 FROM_HERE, | 88 FROM_HERE, |
| 89 base::Bind(&URLRequestAdapter::OnAppendChunk, | 89 base::Bind(&URLRequestAdapter::OnAppendChunk, base::Unretained(this), |
| 90 base::Unretained(this), | 90 base::Passed(&buf), bytes_len, is_last_chunk)); |
| 91 Passed(buf.Pass()), | |
| 92 bytes_len, | |
| 93 is_last_chunk)); | |
| 94 } | 91 } |
| 95 | 92 |
| 96 std::string URLRequestAdapter::GetHeader(const std::string& name) const { | 93 std::string URLRequestAdapter::GetHeader(const std::string& name) const { |
| 97 std::string value; | 94 std::string value; |
| 98 if (url_request_ != NULL) { | 95 if (url_request_ != NULL) { |
| 99 url_request_->GetResponseHeaderByName(name, &value); | 96 url_request_->GetResponseHeaderByName(name, &value); |
| 100 } | 97 } |
| 101 return value; | 98 return value; |
| 102 } | 99 } |
| 103 | 100 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 unsigned char* URLRequestAdapter::Data() const { | 319 unsigned char* URLRequestAdapter::Data() const { |
| 323 DCHECK(OnNetworkThread()); | 320 DCHECK(OnNetworkThread()); |
| 324 return reinterpret_cast<unsigned char*>(read_buffer_->data()); | 321 return reinterpret_cast<unsigned char*>(read_buffer_->data()); |
| 325 } | 322 } |
| 326 | 323 |
| 327 bool URLRequestAdapter::OnNetworkThread() const { | 324 bool URLRequestAdapter::OnNetworkThread() const { |
| 328 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 325 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); |
| 329 } | 326 } |
| 330 | 327 |
| 331 } // namespace cronet | 328 } // namespace cronet |
| OLD | NEW |