OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/native/input_stream_impl.h" | 5 #include "android_webview/native/input_stream_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 // Disable "Warnings treated as errors" for input_stream_jni as it's a Java | 8 // Disable "Warnings treated as errors" for input_stream_jni as it's a Java |
9 // system class and we have to generate C++ hooks for all methods in the class | 9 // system class and we have to generate C++ hooks for all methods in the class |
10 // even if they're unused. | 10 // even if they're unused. |
11 #pragma GCC diagnostic push | 11 #pragma GCC diagnostic push |
12 #pragma GCC diagnostic ignored "-Wunused-function" | 12 #pragma GCC diagnostic ignored "-Wunused-function" |
13 #include "jni/InputStreamUtil_jni.h" | 13 #include "jni/InputStreamUtil_jni.h" |
14 #pragma GCC diagnostic pop | 14 #pragma GCC diagnostic pop |
15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
16 | 16 |
17 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
18 using base::android::ClearException; | 18 using base::android::ClearException; |
19 using base::android::JavaRef; | 19 using base::android::JavaRef; |
20 | 20 |
21 namespace android_webview { | 21 namespace android_webview { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // This should be the same as InputStramUtil.EXCEPTION_THROWN_STATUS. | 25 // This should be the same as InputStramUtil.EXCEPTION_THROWN_STATUS. |
26 const int kExceptionThrownStatusCode = -2; | 26 const int kExceptionThrownStatusCode = -2; |
27 | 27 |
28 } | 28 } |
29 | 29 |
30 bool RegisterInputStream(JNIEnv* env) { | |
31 return RegisterNativesImpl(env); | |
32 } | |
33 | |
34 // Maximum number of bytes to be read in a single read. | 30 // Maximum number of bytes to be read in a single read. |
35 const int InputStreamImpl::kBufferSize = 4096; | 31 const int InputStreamImpl::kBufferSize = 4096; |
36 | 32 |
37 // static | 33 // static |
38 const InputStreamImpl* InputStreamImpl::FromInputStream( | 34 const InputStreamImpl* InputStreamImpl::FromInputStream( |
39 const InputStream* input_stream) { | 35 const InputStream* input_stream) { |
40 return static_cast<const InputStreamImpl*>(input_stream); | 36 return static_cast<const InputStreamImpl*>(input_stream); |
41 } | 37 } |
42 | 38 |
43 // TODO: Use unsafe version for all Java_InputStream methods in this file | 39 // TODO: Use unsafe version for all Java_InputStream methods in this file |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 dest_write_ptr += transfer_length; | 123 dest_write_ptr += transfer_length; |
128 } | 124 } |
129 // bytes_read can be strictly less than the req. length if EOF is encountered. | 125 // bytes_read can be strictly less than the req. length if EOF is encountered. |
130 DCHECK_GE(remaining_length, 0); | 126 DCHECK_GE(remaining_length, 0); |
131 DCHECK_LE(remaining_length, length); | 127 DCHECK_LE(remaining_length, length); |
132 *bytes_read = length - remaining_length; | 128 *bytes_read = length - remaining_length; |
133 return true; | 129 return true; |
134 } | 130 } |
135 | 131 |
136 } // namespace android_webview | 132 } // namespace android_webview |
OLD | NEW |