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 #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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/android/jni_android.h" | 13 #include "base/android/jni_android.h" |
| 14 #include "base/android/jni_array.h" | 14 #include "base/android/jni_array.h" |
| 15 #include "base/android/jni_string.h" | 15 #include "base/android/jni_string.h" |
| 16 #include "base/android/scoped_java_ref.h" | 16 #include "base/android/scoped_java_ref.h" |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/location.h" | 18 #include "base/location.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/time/time.h" | |
| 21 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| 22 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 27 } // namespace base | 28 } // namespace base |
| 28 | 29 |
| 29 namespace net { | 30 namespace net { |
| 30 class HttpRequestHeaders; | 31 class HttpRequestHeaders; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 53 // use cache, |jdisable_cache| has no effect. |jdisable_connection_migration| | 54 // use cache, |jdisable_cache| has no effect. |jdisable_connection_migration| |
| 54 // causes connection migration to be disabled for this request if true. If | 55 // causes connection migration to be disabled for this request if true. If |
| 55 // global connection migration flag is not enabled, | 56 // global connection migration flag is not enabled, |
| 56 // |jdisable_connection_migration| has no effect. | 57 // |jdisable_connection_migration| has no effect. |
| 57 CronetURLRequestAdapter(CronetURLRequestContextAdapter* context, | 58 CronetURLRequestAdapter(CronetURLRequestContextAdapter* context, |
| 58 JNIEnv* env, | 59 JNIEnv* env, |
| 59 jobject jurl_request, | 60 jobject jurl_request, |
| 60 const GURL& url, | 61 const GURL& url, |
| 61 net::RequestPriority priority, | 62 net::RequestPriority priority, |
| 62 jboolean jdisable_cache, | 63 jboolean jdisable_cache, |
| 63 jboolean jdisable_connection_migration); | 64 jboolean jdisable_connection_migration, |
| 65 jboolean jenable_metrics); | |
| 64 ~CronetURLRequestAdapter() override; | 66 ~CronetURLRequestAdapter() override; |
| 65 | 67 |
| 66 // Methods called prior to Start are never called on network thread. | 68 // Methods called prior to Start are never called on network thread. |
| 67 | 69 |
| 68 // Sets the request method GET, POST etc. | 70 // Sets the request method GET, POST etc. |
| 69 jboolean SetHttpMethod(JNIEnv* env, | 71 jboolean SetHttpMethod(JNIEnv* env, |
| 70 const base::android::JavaParamRef<jobject>& jcaller, | 72 const base::android::JavaParamRef<jobject>& jcaller, |
| 71 const base::android::JavaParamRef<jstring>& jmethod); | 73 const base::android::JavaParamRef<jstring>& jmethod); |
| 72 | 74 |
| 73 // Adds a header to the request before it starts. | 75 // Adds a header to the request before it starts. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 JNIEnv* env); | 134 JNIEnv* env); |
| 133 void FollowDeferredRedirectOnNetworkThread(); | 135 void FollowDeferredRedirectOnNetworkThread(); |
| 134 void ReadDataOnNetworkThread( | 136 void ReadDataOnNetworkThread( |
| 135 scoped_refptr<IOBufferWithByteBuffer> read_buffer, | 137 scoped_refptr<IOBufferWithByteBuffer> read_buffer, |
| 136 int buffer_size); | 138 int buffer_size); |
| 137 void DestroyOnNetworkThread(bool send_on_canceled); | 139 void DestroyOnNetworkThread(bool send_on_canceled); |
| 138 | 140 |
| 139 // Checks status of the request_adapter, return false if |is_success()| is | 141 // Checks status of the request_adapter, return false if |is_success()| is |
| 140 // true, otherwise report error and cancel request_adapter. | 142 // true, otherwise report error and cancel request_adapter. |
| 141 bool MaybeReportError(net::URLRequest* request) const; | 143 bool MaybeReportError(net::URLRequest* request) const; |
| 144 // Reports metrics collected to the Java layer | |
| 145 void MaybeReportMetrics(net::URLRequest* request) const; | |
| 146 int64_t ConvertTime(base::TimeTicks ticks, | |
|
xunjieli
2016/09/20 21:53:33
nit: add a documentation for this method.
optiona
mgersh
2016/09/30 23:47:14
Done.
| |
| 147 base::Time start_time, | |
| 148 base::TimeTicks start_ticks) const; | |
| 142 | 149 |
| 143 CronetURLRequestContextAdapter* context_; | 150 CronetURLRequestContextAdapter* context_; |
| 144 | 151 |
| 145 // Java object that owns this CronetURLRequestContextAdapter. | 152 // Java object that owns this CronetURLRequestContextAdapter. |
| 146 base::android::ScopedJavaGlobalRef<jobject> owner_; | 153 base::android::ScopedJavaGlobalRef<jobject> owner_; |
| 147 | 154 |
| 148 const GURL initial_url_; | 155 const GURL initial_url_; |
| 149 const net::RequestPriority initial_priority_; | 156 const net::RequestPriority initial_priority_; |
| 150 std::string initial_method_; | 157 std::string initial_method_; |
| 151 int load_flags_; | 158 int load_flags_; |
| 152 net::HttpRequestHeaders initial_request_headers_; | 159 net::HttpRequestHeaders initial_request_headers_; |
| 153 std::unique_ptr<net::UploadDataStream> upload_; | 160 std::unique_ptr<net::UploadDataStream> upload_; |
| 154 | 161 |
| 155 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; | 162 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; |
| 156 std::unique_ptr<net::URLRequest> url_request_; | 163 std::unique_ptr<net::URLRequest> url_request_; |
| 157 | 164 |
| 165 // Whether detailed metrics should be collected and reported to Java for this | |
| 166 // request. | |
| 167 bool enable_metrics_; | |
|
xunjieli
2016/09/22 18:28:59
const bool.
mgersh
2016/09/30 23:47:14
Done.
| |
| 168 | |
| 158 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); | 169 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); |
| 159 }; | 170 }; |
| 160 | 171 |
| 161 } // namespace cronet | 172 } // namespace cronet |
| 162 | 173 |
| 163 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ | 174 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ |
| OLD | NEW |