Chromium Code Reviews| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 void URLRequestAdapter::Start() { | 119 void URLRequestAdapter::Start() { |
| 120 context_->PostTaskToNetworkThread( | 120 context_->PostTaskToNetworkThread( |
| 121 FROM_HERE, | 121 FROM_HERE, |
| 122 base::Bind(&URLRequestAdapter::OnInitiateConnection, | 122 base::Bind(&URLRequestAdapter::OnInitiateConnection, |
| 123 base::Unretained(this))); | 123 base::Unretained(this))); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, | 126 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, |
| 127 int bytes_len, bool is_last_chunk) { | 127 int bytes_len, bool is_last_chunk) { |
| 128 DCHECK(OnNetworkThread()); | 128 DCHECK(OnNetworkThread()); |
| 129 // Request could have completed and got destroyed on the network thread | |
| 130 // while appendChunk was posting task from application thread. | |
| 131 if (!url_request_) | |
| 132 return; | |
|
miloslav
2014/11/19 18:45:20
Would it make sense to also log something when tha
mef
2014/11/19 19:32:36
Done.
| |
| 129 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk); | 133 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk); |
| 130 } | 134 } |
| 131 | 135 |
| 132 void URLRequestAdapter::OnInitiateConnection() { | 136 void URLRequestAdapter::OnInitiateConnection() { |
| 133 DCHECK(OnNetworkThread()); | 137 DCHECK(OnNetworkThread()); |
| 134 if (canceled_) { | 138 if (canceled_) { |
| 135 return; | 139 return; |
| 136 } | 140 } |
| 137 | 141 |
| 138 VLOG(1) << "Starting chromium request: " | 142 VLOG(1) << "Starting chromium request: " |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 unsigned char* URLRequestAdapter::Data() const { | 341 unsigned char* URLRequestAdapter::Data() const { |
| 338 DCHECK(OnNetworkThread()); | 342 DCHECK(OnNetworkThread()); |
| 339 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); | 343 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); |
| 340 } | 344 } |
| 341 | 345 |
| 342 bool URLRequestAdapter::OnNetworkThread() const { | 346 bool URLRequestAdapter::OnNetworkThread() const { |
| 343 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 347 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); |
| 344 } | 348 } |
| 345 | 349 |
| 346 } // namespace cronet | 350 } // namespace cronet |
| OLD | NEW |