| 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 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 20 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 25 } // namespace base | 25 } // namespace base |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 class HttpRequestHeaders; | 28 class HttpRequestHeaders; |
| 29 class HttpResponseHeaders; | 29 class HttpResponseHeaders; |
| 30 class SSLInfo; |
| 30 class UploadDataStream; | 31 class UploadDataStream; |
| 31 } // namespace net | 32 } // namespace net |
| 32 | 33 |
| 33 namespace cronet { | 34 namespace cronet { |
| 34 | 35 |
| 35 class CronetURLRequestContextAdapter; | 36 class CronetURLRequestContextAdapter; |
| 36 | 37 |
| 37 bool CronetUrlRequestAdapterRegisterJni(JNIEnv* env); | 38 bool CronetUrlRequestAdapterRegisterJni(JNIEnv* env); |
| 38 | 39 |
| 39 // An adapter from Java CronetUrlRequest object to net::URLRequest. | 40 // An adapter from Java CronetUrlRequest object to net::URLRequest. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Returns true if response is coming from the cache. | 115 // Returns true if response is coming from the cache. |
| 115 jboolean GetWasCached(JNIEnv* env, jobject jcaller) const; | 116 jboolean GetWasCached(JNIEnv* env, jobject jcaller) const; |
| 116 | 117 |
| 117 // net::URLRequest::Delegate implementations: | 118 // net::URLRequest::Delegate implementations: |
| 118 | 119 |
| 119 void OnReceivedRedirect(net::URLRequest* request, | 120 void OnReceivedRedirect(net::URLRequest* request, |
| 120 const net::RedirectInfo& redirect_info, | 121 const net::RedirectInfo& redirect_info, |
| 121 bool* defer_redirect) override; | 122 bool* defer_redirect) override; |
| 122 void OnResponseStarted(net::URLRequest* request) override; | 123 void OnResponseStarted(net::URLRequest* request) override; |
| 123 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 124 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 125 void OnSSLCertificateError(net::URLRequest* request, |
| 126 const net::SSLInfo& ssl_info, |
| 127 bool fatal) override; |
| 124 | 128 |
| 125 private: | 129 private: |
| 126 class IOBufferWithByteBuffer; | 130 class IOBufferWithByteBuffer; |
| 127 | 131 |
| 128 void StartOnNetworkThread(); | 132 void StartOnNetworkThread(); |
| 129 void GetStatusOnNetworkThread( | 133 void GetStatusOnNetworkThread( |
| 130 const base::android::ScopedJavaGlobalRef<jobject>& jstatus_listener_ref) | 134 const base::android::ScopedJavaGlobalRef<jobject>& jstatus_listener_ref) |
| 131 const; | 135 const; |
| 132 void FollowDeferredRedirectOnNetworkThread(); | 136 void FollowDeferredRedirectOnNetworkThread(); |
| 133 void ReadDataOnNetworkThread( | 137 void ReadDataOnNetworkThread( |
| 134 scoped_refptr<IOBufferWithByteBuffer> read_buffer, | 138 scoped_refptr<IOBufferWithByteBuffer> read_buffer, |
| 135 int buffer_size); | 139 int buffer_size); |
| 136 void DestroyOnNetworkThread(); | 140 void DestroyOnNetworkThread(); |
| 137 | 141 |
| 138 // Checks status of the request_adapter, return false if |is_success()| is | 142 // Checks status of the request_adapter, return false if |is_success()| is |
| 139 // true, otherwise report error and cancel request_adapter. | 143 // true, otherwise report error and cancel request_adapter. |
| 140 bool MaybeReportError(net::URLRequest* request) const; | 144 bool MaybeReportError(net::URLRequest* request) const; |
| 141 | 145 |
| 142 CronetURLRequestContextAdapter* context_; | 146 CronetURLRequestContextAdapter* context_; |
| 143 | 147 |
| 144 // Java object that owns this CronetURLRequestContextAdapter. | 148 // Java object that owns this CronetURLRequestContextAdapter. |
| 145 base::android::ScopedJavaGlobalRef<jobject> owner_; | 149 base::android::ScopedJavaGlobalRef<jobject> owner_; |
| 146 | 150 |
| 147 const GURL initial_url_; | 151 const GURL initial_url_; |
| 148 const net::RequestPriority initial_priority_; | 152 const net::RequestPriority initial_priority_; |
| 149 std::string initial_method_; | 153 std::string initial_method_; |
| 150 int load_flags_; | 154 int load_flags_; |
| 155 bool has_ssl_cert_error_; |
| 151 net::HttpRequestHeaders initial_request_headers_; | 156 net::HttpRequestHeaders initial_request_headers_; |
| 152 scoped_ptr<net::UploadDataStream> upload_; | 157 scoped_ptr<net::UploadDataStream> upload_; |
| 153 | 158 |
| 154 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; | 159 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; |
| 155 scoped_ptr<net::URLRequest> url_request_; | 160 scoped_ptr<net::URLRequest> url_request_; |
| 156 | 161 |
| 157 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); | 162 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); |
| 158 }; | 163 }; |
| 159 | 164 |
| 160 } // namespace cronet | 165 } // namespace cronet |
| 161 | 166 |
| 162 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ | 167 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ |
| OLD | NEW |