OLD | NEW |
---|---|
(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_NATIVE_INPUT_STREAM_READER_H_ | |
6 #define ANDROID_WEBVIEW_NATIVE_INPUT_STREAM_READER_H_ | |
7 | |
8 #include "base/android/jni_android.h" | |
9 #include "base/memory/ref_counted.h" | |
10 | |
11 namespace net { | |
12 class HttpByteRange; | |
13 class IOBuffer; | |
14 } | |
15 | |
16 namespace android_webview { | |
17 | |
18 class InputStream; | |
19 | |
20 // Class responsible for reading the InputStream. | |
21 class InputStreamReader | |
22 : public base::RefCountedThreadSafe<InputStreamReader> { | |
23 public: | |
24 // The constructor is called on the IO thread, not on the WorkerThread. | |
25 InputStreamReader(android_webview::InputStream* stream); | |
26 | |
27 // Perform a seek operation on the InputStream associated with this job. | |
28 // On successful completion the InputStream would have skipped reading the | |
29 // number of bytes equal to the lower range of |byte_range|. | |
30 // This method should be called on the |g_worker_thread| thread. | |
31 // | |
32 // |byte_range| is the range of bytes to be read from |stream| | |
33 // | |
34 // A negative return value will indicate an error code, a positive value | |
35 // will indicate the expected size of the content. | |
36 virtual int Seek(net::HttpByteRange byte_range); | |
37 | |
38 // Read data from |stream_|. This method should be called on the | |
39 // |g_worker_thread| thread. | |
40 // | |
41 // A negative return value will indicate an error code, a positive value | |
42 // will indicate the expected size of the content. | |
43 virtual int ReadRawData(net::IOBuffer* buffer, int buffer_size); | |
44 | |
45 protected: | |
46 virtual ~InputStreamReader(); | |
47 | |
48 private: | |
49 friend class base::RefCountedThreadSafe<InputStreamReader>; | |
50 | |
51 // Verify the requested range against the stream size. | |
52 // net::OK is returned on success, the error code otherwise. | |
53 int VerifyRequestedRange(JNIEnv* env, | |
benm (inactive)
2012/11/16 15:43:20
same comment, can we remove jni from the browser/
mkosiba (inactive)
2012/11/19 15:29:33
Done.
| |
54 net::HttpByteRange* byte_range, | |
55 int* content_size); | |
56 | |
57 // Skip to the first byte of the requested read range. | |
58 // net::OK is returned on success, the error code otherwise. | |
59 int SkipToRequestedRange(JNIEnv* env, const net::HttpByteRange& byte_range); | |
60 | |
61 android_webview::InputStream* stream_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(InputStreamReader); | |
64 }; | |
65 | |
66 } // namespace android_webview | |
67 | |
68 #endif // ANDROID_WEBVIEW_NATIVE_INPUT_STREAM_READER_H_ | |
OLD | NEW |