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 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 21 matching lines...) Expand all Loading... |
32 class HttpResponseHeaders; | 32 class HttpResponseHeaders; |
33 class SSLCertRequestInfo; | 33 class SSLCertRequestInfo; |
34 class SSLInfo; | 34 class SSLInfo; |
35 class UploadDataStream; | 35 class UploadDataStream; |
36 } // namespace net | 36 } // namespace net |
37 | 37 |
38 namespace cronet { | 38 namespace cronet { |
39 | 39 |
40 class CronetURLRequestContextAdapter; | 40 class CronetURLRequestContextAdapter; |
41 class IOBufferWithByteBuffer; | 41 class IOBufferWithByteBuffer; |
| 42 class TestUtil; |
42 | 43 |
43 bool CronetUrlRequestAdapterRegisterJni(JNIEnv* env); | 44 bool CronetUrlRequestAdapterRegisterJni(JNIEnv* env); |
44 | 45 |
45 // An adapter from Java CronetUrlRequest object to net::URLRequest. | 46 // An adapter from Java CronetUrlRequest object to net::URLRequest. |
46 // Created and configured from a Java thread. Start, ReadData, and Destroy are | 47 // Created and configured from a Java thread. Start, ReadData, and Destroy are |
47 // posted to network thread and all callbacks into the Java CronetUrlRequest are | 48 // posted to network thread and all callbacks into the Java CronetUrlRequest are |
48 // done on the network thread. Java CronetUrlRequest is expected to initiate the | 49 // done on the network thread. Java CronetUrlRequest is expected to initiate the |
49 // next step like FollowDeferredRedirect, ReadData or Destroy. Public methods | 50 // next step like FollowDeferredRedirect, ReadData or Destroy. Public methods |
50 // can be called on any thread. | 51 // can be called on any thread. |
51 class CronetURLRequestAdapter : public net::URLRequest::Delegate { | 52 class CronetURLRequestAdapter : public net::URLRequest::Delegate { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 bool* defer_redirect) override; | 116 bool* defer_redirect) override; |
116 void OnCertificateRequested( | 117 void OnCertificateRequested( |
117 net::URLRequest* request, | 118 net::URLRequest* request, |
118 net::SSLCertRequestInfo* cert_request_info) override; | 119 net::SSLCertRequestInfo* cert_request_info) override; |
119 void OnSSLCertificateError(net::URLRequest* request, | 120 void OnSSLCertificateError(net::URLRequest* request, |
120 const net::SSLInfo& ssl_info, | 121 const net::SSLInfo& ssl_info, |
121 bool fatal) override; | 122 bool fatal) override; |
122 void OnResponseStarted(net::URLRequest* request, int net_error) override; | 123 void OnResponseStarted(net::URLRequest* request, int net_error) override; |
123 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 124 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
124 | 125 |
125 net::URLRequest* GetURLRequestForTesting(); | 126 private: |
| 127 friend class TestUtil; |
126 | 128 |
127 private: | |
128 void StartOnNetworkThread(); | 129 void StartOnNetworkThread(); |
129 void GetStatusOnNetworkThread( | 130 void GetStatusOnNetworkThread( |
130 const base::android::ScopedJavaGlobalRef<jobject>& jstatus_listener_ref) | 131 const base::android::ScopedJavaGlobalRef<jobject>& jstatus_listener_ref) |
131 const; | 132 const; |
132 // Gets response headers on network thread. | 133 // Gets response headers on network thread. |
133 base::android::ScopedJavaLocalRef<jobjectArray> GetResponseHeaders( | 134 base::android::ScopedJavaLocalRef<jobjectArray> GetResponseHeaders( |
134 JNIEnv* env); | 135 JNIEnv* env); |
135 void FollowDeferredRedirectOnNetworkThread(); | 136 void FollowDeferredRedirectOnNetworkThread(); |
136 void ReadDataOnNetworkThread( | 137 void ReadDataOnNetworkThread( |
137 scoped_refptr<IOBufferWithByteBuffer> read_buffer, | 138 scoped_refptr<IOBufferWithByteBuffer> read_buffer, |
(...skipping 23 matching lines...) Expand all Loading... |
161 // Whether detailed metrics should be collected and reported to Java for this | 162 // Whether detailed metrics should be collected and reported to Java for this |
162 // request. | 163 // request. |
163 const bool enable_metrics_; | 164 const bool enable_metrics_; |
164 | 165 |
165 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); | 166 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); |
166 }; | 167 }; |
167 | 168 |
168 } // namespace cronet | 169 } // namespace cronet |
169 | 170 |
170 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ | 171 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ |
OLD | NEW |