Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1250)

Side by Side Diff: components/cronet/android/cronet_url_request_adapter.h

Issue 2351793003: Implement timing metrics for UrlRequest (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // use cache, |jdisable_cache| has no effect. |jdisable_connection_migration| 53 // use cache, |jdisable_cache| has no effect. |jdisable_connection_migration|
54 // causes connection migration to be disabled for this request if true. If 54 // causes connection migration to be disabled for this request if true. If
55 // global connection migration flag is not enabled, 55 // global connection migration flag is not enabled,
56 // |jdisable_connection_migration| has no effect. 56 // |jdisable_connection_migration| has no effect.
57 CronetURLRequestAdapter(CronetURLRequestContextAdapter* context, 57 CronetURLRequestAdapter(CronetURLRequestContextAdapter* context,
58 JNIEnv* env, 58 JNIEnv* env,
59 jobject jurl_request, 59 jobject jurl_request,
60 const GURL& url, 60 const GURL& url,
61 net::RequestPriority priority, 61 net::RequestPriority priority,
62 jboolean jdisable_cache, 62 jboolean jdisable_cache,
63 jboolean jdisable_connection_migration); 63 jboolean jdisable_connection_migration,
64 jboolean jenable_metrics);
64 ~CronetURLRequestAdapter() override; 65 ~CronetURLRequestAdapter() override;
65 66
66 // Methods called prior to Start are never called on network thread. 67 // Methods called prior to Start are never called on network thread.
67 68
68 // Sets the request method GET, POST etc. 69 // Sets the request method GET, POST etc.
69 jboolean SetHttpMethod(JNIEnv* env, 70 jboolean SetHttpMethod(JNIEnv* env,
70 const base::android::JavaParamRef<jobject>& jcaller, 71 const base::android::JavaParamRef<jobject>& jcaller,
71 const base::android::JavaParamRef<jstring>& jmethod); 72 const base::android::JavaParamRef<jstring>& jmethod);
72 73
73 // Adds a header to the request before it starts. 74 // Adds a header to the request before it starts.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 JNIEnv* env); 133 JNIEnv* env);
133 void FollowDeferredRedirectOnNetworkThread(); 134 void FollowDeferredRedirectOnNetworkThread();
134 void ReadDataOnNetworkThread( 135 void ReadDataOnNetworkThread(
135 scoped_refptr<IOBufferWithByteBuffer> read_buffer, 136 scoped_refptr<IOBufferWithByteBuffer> read_buffer,
136 int buffer_size); 137 int buffer_size);
137 void DestroyOnNetworkThread(bool send_on_canceled); 138 void DestroyOnNetworkThread(bool send_on_canceled);
138 139
139 // Checks status of the request_adapter, return false if |is_success()| is 140 // Checks status of the request_adapter, return false if |is_success()| is
140 // true, otherwise report error and cancel request_adapter. 141 // true, otherwise report error and cancel request_adapter.
141 bool MaybeReportError(net::URLRequest* request) const; 142 bool MaybeReportError(net::URLRequest* request) const;
143 // Reports metrics collected to the Java layer
144 void MaybeReportMetrics(net::URLRequest* request) const;
145 int64_t ConvertTime(base::TimeTicks ticks,
xunjieli 2016/09/20 14:32:46 #include base/time/time.h
mgersh 2016/09/20 20:48:25 Done.
146 base::Time start_time,
147 base::TimeTicks start_ticks) const;
142 148
143 CronetURLRequestContextAdapter* context_; 149 CronetURLRequestContextAdapter* context_;
144 150
145 // Java object that owns this CronetURLRequestContextAdapter. 151 // Java object that owns this CronetURLRequestContextAdapter.
146 base::android::ScopedJavaGlobalRef<jobject> owner_; 152 base::android::ScopedJavaGlobalRef<jobject> owner_;
147 153
148 const GURL initial_url_; 154 const GURL initial_url_;
149 const net::RequestPriority initial_priority_; 155 const net::RequestPriority initial_priority_;
150 std::string initial_method_; 156 std::string initial_method_;
151 int load_flags_; 157 int load_flags_;
152 net::HttpRequestHeaders initial_request_headers_; 158 net::HttpRequestHeaders initial_request_headers_;
153 std::unique_ptr<net::UploadDataStream> upload_; 159 std::unique_ptr<net::UploadDataStream> upload_;
154 160
155 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; 161 scoped_refptr<IOBufferWithByteBuffer> read_buffer_;
156 std::unique_ptr<net::URLRequest> url_request_; 162 std::unique_ptr<net::URLRequest> url_request_;
157 163
164 bool enable_metrics_;
xunjieli 2016/09/20 14:32:46 nit: Add a documentation. It's clear what this mea
mgersh 2016/09/20 20:48:24 Done.
165
158 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); 166 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter);
159 }; 167 };
160 168
161 } // namespace cronet 169 } // namespace cronet
162 170
163 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ 171 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698