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