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

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

Issue 2889193004: [WebView] Replace AwContentsIoThreadClient, InputStream and AwWebResourceResponse (Closed)
Patch Set: fix test crash Created 3 years, 7 months 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
OLDNEW
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 #ifndef ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
6 #define ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ 6 #define ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13
10 namespace net { 14 namespace net {
11 class IOBuffer; 15 class IOBuffer;
12 } 16 }
13 17
14 namespace android_webview { 18 namespace android_webview {
15 19
16 // Abstract wrapper used to access the InputStream Java class. 20 // Abstract wrapper used to access the InputStream Java class.
17 // This class is safe to pass around between threads (the destructor, 21 // This class is safe to pass around between threads (the destructor,
18 // constructor and methods can be called on different threads) but calling 22 // constructor and methods can be called on different threads) but calling
19 // methods concurrently might have undefined results. 23 // methods concurrently might have undefined results.
20 class InputStream { 24 class InputStream {
21 public: 25 public:
22 virtual ~InputStream() {} 26 // Maximum size of |buffer_|.
27 static const int kBufferSize;
28
29 // |stream| should be an instance of the InputStream Java class.
30 // |stream| can't be null.
31 InputStream(const base::android::JavaRef<jobject>& stream);
32 virtual ~InputStream();
boliu 2017/05/22 23:30:11 does this still need virtual?
33
34 // Gets the underlying Java object. Guaranteed non-NULL.
35 const base::android::JavaRef<jobject>& jobj() const { return jobject_; }
23 36
24 // Sets |bytes_available| to the number of bytes that can be read (or skipped 37 // Sets |bytes_available| to the number of bytes that can be read (or skipped
25 // over) from this input stream without blocking by the next caller of a 38 // over) from this input stream without blocking by the next caller of a
26 // method for this input stream. 39 // method for this input stream.
27 // Returns true if completed successfully or false if an exception was 40 // Returns true if completed successfully or false if an exception was
28 // thrown. 41 // thrown.
29 virtual bool BytesAvailable(int* bytes_available) const = 0; 42 virtual bool BytesAvailable(int* bytes_available) const;
30 43
31 // Skips over and discards |n| bytes of data from this input stream. Sets 44 // Skips over and discards |n| bytes of data from this input stream. Sets
32 // |bytes_skipped| to the number of of bytes skipped. 45 // |bytes_skipped| to the number of of bytes skipped.
33 // Returns true if completed successfully or false if an exception was 46 // Returns true if completed successfully or false if an exception was
34 // thrown. 47 // thrown.
35 virtual bool Skip(int64_t n, int64_t* bytes_skipped) = 0; 48 virtual bool Skip(int64_t n, int64_t* bytes_skipped);
36 49
37 // Reads at most |length| bytes into |dest|. Sets |bytes_read| to the total 50 // Reads at most |length| bytes into |dest|. Sets |bytes_read| to the total
38 // number of bytes read into |dest| or 0 if there is no more data because the 51 // number of bytes read into |dest| or 0 if there is no more data because the
39 // end of the stream was reached. 52 // end of the stream was reached.
40 // |dest| must be at least |length| in size. 53 // |dest| must be at least |length| in size.
41 // Returns true if completed successfully or false if an exception was 54 // Returns true if completed successfully or false if an exception was
42 // thrown. 55 // thrown.
43 virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read) = 0; 56 virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read);
44 57
45 protected: 58 protected:
46 InputStream() {} 59 // Parameterless constructor exposed for testing.
60 InputStream();
61
62 private:
63 base::android::ScopedJavaGlobalRef<jobject> jobject_;
64 base::android::ScopedJavaGlobalRef<jbyteArray> buffer_;
65
66 DISALLOW_COPY_AND_ASSIGN(InputStream);
47 }; 67 };
48 68
49 } // namespace android_webview 69 } // namespace android_webview
50 70
51 #endif // ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_ 71 #endif // ANDROID_WEBVIEW_BROWSER_INPUT_STREAM_H_
OLDNEW
« no previous file with comments | « android_webview/browser/aw_web_resource_response_impl.cc ('k') | android_webview/browser/input_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698