Chromium Code Reviews| Index: android_webview/browser/input_stream.h |
| diff --git a/android_webview/browser/input_stream.h b/android_webview/browser/input_stream.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2d5cfe00dcaca88b9b0f3e406aaf33ce2e62baf6 |
| --- /dev/null |
| +++ b/android_webview/browser/input_stream.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ |
| +#define ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ |
| + |
| +#include "base/android/jni_android.h" |
| + |
| +namespace net { |
| +class IOBuffer; |
| +} |
| + |
| +namespace android_webview { |
| + |
| +class InputStream { |
| + public: |
| + virtual ~InputStream() {} |
| + |
| + // Sets |bytes_available| to the number of bytes that can be read (or skipped |
| + // over) from this input stream without blocking by the next caller of a |
| + // method for this input stream. |
| + // Returns true if completed successfully or false if an exception was |
| + // thrown. |
| + virtual bool BytesAvailable(JNIEnv* env, int* bytes_available) const = 0; |
| + |
| + // Skips over and discards |n| bytes of data from this input stream. Sets |
| + // |bytes_skipped| to the number of of bytes skipped. |
| + // Returns true if completed successfully or false if an exception was |
| + // thrown. |
| + virtual bool Skip(JNIEnv* env, int64_t n, int64_t* bytes_skipped) = 0; |
| + |
| + // Reads |length| bytes into |dest|. Sets |bytes_read| to the total number of |
| + // bytes read into |dest| or -1 if there is no more data because the end of |
| + // the stream was reached. |
| + // |dest| must be at least |length| in size. |
| + // Returns true if completed successfully or false if an exception was |
| + // thrown. |
| + virtual bool Read(JNIEnv* env, |
|
benm (inactive)
2012/11/16 15:43:20
would be nice to eliminate the JNIEnvs here, can t
mkosiba (inactive)
2012/11/19 15:29:33
Done.
|
| + net::IOBuffer* dest, |
| + int length, |
| + int* bytes_read) = 0; |
| + protected: |
| + InputStream() {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(InputStream); |
| +}; |
| + |
| +} // namespace android_webview |
| + |
| +#endif // ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ |