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

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

Issue 2360813003: [Cronet] Pass metrics information from C++ BidirectionalStream to Java (Closed)
Patch Set: Rebased Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_BIDIRECTIONAL_STREAM_ADAPTER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ 6 #define COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // or Destroy. Public methods can be called on any thread. 64 // or Destroy. Public methods can be called on any thread.
65 class CronetBidirectionalStreamAdapter 65 class CronetBidirectionalStreamAdapter
66 : public net::BidirectionalStream::Delegate { 66 : public net::BidirectionalStream::Delegate {
67 public: 67 public:
68 static bool RegisterJni(JNIEnv* env); 68 static bool RegisterJni(JNIEnv* env);
69 69
70 CronetBidirectionalStreamAdapter( 70 CronetBidirectionalStreamAdapter(
71 CronetURLRequestContextAdapter* context, 71 CronetURLRequestContextAdapter* context,
72 JNIEnv* env, 72 JNIEnv* env,
73 const base::android::JavaParamRef<jobject>& jbidi_stream, 73 const base::android::JavaParamRef<jobject>& jbidi_stream,
74 bool jsend_request_headers_automatically); 74 bool jsend_request_headers_automatically,
75 bool enable_metrics);
75 ~CronetBidirectionalStreamAdapter() override; 76 ~CronetBidirectionalStreamAdapter() override;
76 77
77 // Validates method and headers, initializes and starts the request. If 78 // Validates method and headers, initializes and starts the request. If
78 // |jend_of_stream| is true, then stream is half-closed after sending header 79 // |jend_of_stream| is true, then stream is half-closed after sending header
79 // frame and no data is expected to be written. 80 // frame and no data is expected to be written.
80 // Returns 0 if request is valid and started successfully, 81 // Returns 0 if request is valid and started successfully,
81 // Returns -1 if |jmethod| is not valid HTTP method name. 82 // Returns -1 if |jmethod| is not valid HTTP method name.
82 // Returns position of invalid header value in |jheaders| if header name is 83 // Returns position of invalid header value in |jheaders| if header name is
83 // not valid. 84 // not valid.
84 jint Start(JNIEnv* env, 85 jint Start(JNIEnv* env,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 void ReadDataOnNetworkThread( 148 void ReadDataOnNetworkThread(
148 scoped_refptr<IOBufferWithByteBuffer> read_buffer, 149 scoped_refptr<IOBufferWithByteBuffer> read_buffer,
149 int buffer_size); 150 int buffer_size);
150 void WritevDataOnNetworkThread( 151 void WritevDataOnNetworkThread(
151 std::unique_ptr<PendingWriteData> pending_write_data); 152 std::unique_ptr<PendingWriteData> pending_write_data);
152 void DestroyOnNetworkThread(bool send_on_canceled); 153 void DestroyOnNetworkThread(bool send_on_canceled);
153 // Gets headers as a Java array. 154 // Gets headers as a Java array.
154 base::android::ScopedJavaLocalRef<jobjectArray> GetHeadersArray( 155 base::android::ScopedJavaLocalRef<jobjectArray> GetHeadersArray(
155 JNIEnv* env, 156 JNIEnv* env,
156 const net::SpdyHeaderBlock& header_block); 157 const net::SpdyHeaderBlock& header_block);
157 158 // Helper method to report metrics to the Java layer.
159 void MaybeReportMetrics();
158 CronetURLRequestContextAdapter* const context_; 160 CronetURLRequestContextAdapter* const context_;
159 161
160 // Java object that owns this CronetBidirectionalStreamAdapter. 162 // Java object that owns this CronetBidirectionalStreamAdapter.
161 base::android::ScopedJavaGlobalRef<jobject> owner_; 163 base::android::ScopedJavaGlobalRef<jobject> owner_;
162 const bool send_request_headers_automatically_; 164 const bool send_request_headers_automatically_;
165 // Whether metrics collection is enabled when |this| is created.
166 const bool enable_metrics_;
163 167
164 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; 168 scoped_refptr<IOBufferWithByteBuffer> read_buffer_;
165 std::unique_ptr<PendingWriteData> pending_write_data_; 169 std::unique_ptr<PendingWriteData> pending_write_data_;
166 std::unique_ptr<net::BidirectionalStream> bidi_stream_; 170 std::unique_ptr<net::BidirectionalStream> bidi_stream_;
167 171
168 // Whether BidirectionalStream::Delegate::OnFailed callback is invoked. 172 // Whether BidirectionalStream::Delegate::OnFailed callback is invoked.
169 bool stream_failed_; 173 bool stream_failed_;
170 174
171 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStreamAdapter); 175 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStreamAdapter);
172 }; 176 };
173 177
174 } // namespace cronet 178 } // namespace cronet
175 179
176 #endif // COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ 180 #endif // COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_
OLDNEW
« no previous file with comments | « components/cronet/android/BUILD.gn ('k') | components/cronet/android/cronet_bidirectional_stream_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698