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

Side by Side Diff: android_webview/browser/input_stream.h

Issue 11363123: [android_webview] Don't block the IO thread when reading from an InputStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reinterpret_cast->static_cast Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
6 #define ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
7
8 #include "base/android/jni_android.h"
9
10 namespace net {
11 class IOBuffer;
12 }
13
14 namespace android_webview {
15
16 class InputStream {
17 public:
18 virtual ~InputStream() {}
19
20 // Sets |bytes_available| to the number of bytes that can be read (or skipped
21 // over) from this input stream without blocking by the next caller of a
22 // method for this input stream.
23 // Returns true if completed successfully or false if an exception was
24 // thrown.
25 virtual bool BytesAvailable(JNIEnv* env, int* bytes_available) const = 0;
26
27 // Skips over and discards |n| bytes of data from this input stream. Sets
28 // |bytes_skipped| to the number of of bytes skipped.
29 // Returns true if completed successfully or false if an exception was
30 // thrown.
31 virtual bool Skip(JNIEnv* env, int64_t n, int64_t* bytes_skipped) = 0;
32
33 // Reads |length| bytes into |dest|. Sets |bytes_read| to the total number of
34 // bytes read into |dest| or -1 if there is no more data because the end of
35 // the stream was reached.
36 // |dest| must be at least |length| in size.
37 // Returns true if completed successfully or false if an exception was
38 // thrown.
39 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.
40 net::IOBuffer* dest,
41 int length,
42 int* bytes_read) = 0;
43 protected:
44 InputStream() {}
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(InputStream);
48 };
49
50 } // namespace android_webview
51
52 #endif // ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698