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 #include "components/cronet/android/org_chromium_net_UrlRequest.h" | 5 #include "components/cronet/android/org_chromium_net_UrlRequest.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "components/cronet/android/url_request_adapter.h" | 10 #include "components/cronet/android/url_request_adapter.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 jlong urlRequestAdapter, | 189 jlong urlRequestAdapter, |
190 jstring content_type, | 190 jstring content_type, |
191 jlong content_length) { | 191 jlong content_length) { |
192 URLRequestAdapter* request = | 192 URLRequestAdapter* request = |
193 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); | 193 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); |
194 SetPostContentType(env, request, content_type); | 194 SetPostContentType(env, request, content_type); |
195 | 195 |
196 request->SetUploadChannel(env, content_length); | 196 request->SetUploadChannel(env, content_length); |
197 } | 197 } |
198 | 198 |
| 199 static void EnableChunkedUpload(JNIEnv* env, |
| 200 jobject object, |
| 201 jlong urlRequestAdapter, |
| 202 jstring content_type) { |
| 203 URLRequestAdapter* request = |
| 204 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); |
| 205 SetPostContentType(env, request, content_type); |
| 206 |
| 207 request->EnableChunkedUpload(); |
| 208 } |
| 209 |
| 210 static void AppendChunk(JNIEnv* env, |
| 211 jobject object, |
| 212 jlong urlRequestAdapter, |
| 213 jobject chunk_byte_buffer, |
| 214 jint chunk_size, |
| 215 jboolean is_last_chunk) { |
| 216 URLRequestAdapter* request = |
| 217 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); |
| 218 DCHECK(chunk_byte_buffer != NULL); |
| 219 |
| 220 void* chunk = env->GetDirectBufferAddress(chunk_byte_buffer); |
| 221 request->AppendChunk( |
| 222 reinterpret_cast<const char*>(chunk), chunk_size, is_last_chunk); |
| 223 } |
199 | 224 |
200 /* synchronized */ | 225 /* synchronized */ |
201 static void Start(JNIEnv* env, jobject object, jlong urlRequestAdapter) { | 226 static void Start(JNIEnv* env, jobject object, jlong urlRequestAdapter) { |
202 URLRequestAdapter* request = | 227 URLRequestAdapter* request = |
203 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); | 228 reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter); |
204 if (request != NULL) { | 229 if (request != NULL) { |
205 request->Start(); | 230 request->Start(); |
206 } | 231 } |
207 } | 232 } |
208 | 233 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 384 |
360 // Some implementations (notably HttpURLConnection) include a mapping for the | 385 // Some implementations (notably HttpURLConnection) include a mapping for the |
361 // null key; in HTTP's case, this maps to the HTTP status line. | 386 // null key; in HTTP's case, this maps to the HTTP status line. |
362 ScopedJavaLocalRef<jstring> status_line = | 387 ScopedJavaLocalRef<jstring> status_line = |
363 ConvertUTF8ToJavaString(env, headers->GetStatusLine()); | 388 ConvertUTF8ToJavaString(env, headers->GetStatusLine()); |
364 Java_UrlRequest_onAppendResponseHeader( | 389 Java_UrlRequest_onAppendResponseHeader( |
365 env, object, headersMap, NULL, status_line.Release()); | 390 env, object, headersMap, NULL, status_line.Release()); |
366 } | 391 } |
367 | 392 |
368 } // namespace cronet | 393 } // namespace cronet |
OLD | NEW |