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 "cronet_url_request_adapter.h" | 5 #include "cronet_url_request_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "components/cronet/android/cronet_url_request_context_adapter.h" | 10 #include "components/cronet/android/cronet_url_request_context_adapter.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 const std::string& value) { | 40 const std::string& value) { |
41 DCHECK(!IsOnNetworkThread()); | 41 DCHECK(!IsOnNetworkThread()); |
42 initial_request_headers_.SetHeader(name, value); | 42 initial_request_headers_.SetHeader(name, value); |
43 } | 43 } |
44 | 44 |
45 void CronetURLRequestAdapter::DisableCache() { | 45 void CronetURLRequestAdapter::DisableCache() { |
46 DCHECK(!IsOnNetworkThread()); | 46 DCHECK(!IsOnNetworkThread()); |
47 load_flags_ |= net::LOAD_DISABLE_CACHE; | 47 load_flags_ |= net::LOAD_DISABLE_CACHE; |
48 } | 48 } |
49 | 49 |
50 bool CronetURLRequestAdapter::PostTaskToNetworkThread( | 50 void CronetURLRequestAdapter::PostTaskToNetworkThread( |
51 const tracked_objects::Location& from_here, | 51 const tracked_objects::Location& from_here, |
52 const base::Closure& task) { | 52 const base::Closure& task) { |
53 DCHECK(!IsOnNetworkThread()); | 53 DCHECK(!IsOnNetworkThread()); |
54 return context_->GetNetworkTaskRunner()->PostTask(from_here, task); | 54 context_->PostTaskToNetworkThread(from_here, task); |
55 } | 55 } |
56 | 56 |
57 bool CronetURLRequestAdapter::IsOnNetworkThread() const { | 57 bool CronetURLRequestAdapter::IsOnNetworkThread() const { |
58 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 58 return context_->IsOnNetworkThread(); |
59 } | 59 } |
60 | 60 |
61 void CronetURLRequestAdapter::Start() { | 61 void CronetURLRequestAdapter::Start() { |
62 DCHECK(IsOnNetworkThread()); | 62 DCHECK(IsOnNetworkThread()); |
63 VLOG(1) << "Starting chromium request: " | 63 VLOG(1) << "Starting chromium request: " |
64 << initial_url_.possibly_invalid_spec().c_str() | 64 << initial_url_.possibly_invalid_spec().c_str() |
65 << " priority: " << RequestPriorityToString(initial_priority_); | 65 << " priority: " << RequestPriorityToString(initial_priority_); |
66 url_request_ = context_->GetURLRequestContext()->CreateRequest( | 66 url_request_ = context_->GetURLRequestContext()->CreateRequest( |
67 initial_url_, net::DEFAULT_PRIORITY, this, NULL); | 67 initial_url_, net::DEFAULT_PRIORITY, this, NULL); |
68 url_request_->SetLoadFlags(load_flags_); | 68 url_request_->SetLoadFlags(load_flags_); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 DCHECK_EQ(request, url_request_); | 155 DCHECK_EQ(request, url_request_); |
156 if (url_request_->status().is_success()) | 156 if (url_request_->status().is_success()) |
157 return false; | 157 return false; |
158 VLOG(1) << "Error " << url_request_->status().error() | 158 VLOG(1) << "Error " << url_request_->status().error() |
159 << " on chromium request: " << initial_url_.possibly_invalid_spec(); | 159 << " on chromium request: " << initial_url_.possibly_invalid_spec(); |
160 delegate_->OnError(url_request_->status().error()); | 160 delegate_->OnError(url_request_->status().error()); |
161 return true; | 161 return true; |
162 } | 162 } |
163 | 163 |
164 } // namespace cronet | 164 } // namespace cronet |
OLD | NEW |