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