Fix race condition in gyp/ninja builds.
[chromium-blink-merge.git] / android_webview / browser / net / input_stream_reader.h
blob9e781adce83441bf8395413fc29c2c0f76612b28
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.
5 #ifndef ANDROID_WEBVIEW_NATIVE_INPUT_STREAM_READER_H_
6 #define ANDROID_WEBVIEW_NATIVE_INPUT_STREAM_READER_H_
8 #include "base/memory/ref_counted.h"
10 namespace net {
11 class HttpByteRange;
12 class IOBuffer;
15 namespace android_webview {
17 class InputStream;
19 // Class responsible for reading the InputStream.
20 class InputStreamReader {
21 public:
22 // The constructor is called on the IO thread, not on the worker thread.
23 InputStreamReader(android_webview::InputStream* stream);
24 virtual ~InputStreamReader();
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.
31 // |byte_range| is the range of bytes to be read from |stream|
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(const net::HttpByteRange& byte_range);
37 // Read data from |stream_|. This method should be called on the
38 // |g_worker_thread| thread.
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);
44 private:
45 // Verify the requested range against the stream size.
46 // net::OK is returned on success, the error code otherwise.
47 int VerifyRequestedRange(net::HttpByteRange* byte_range,
48 int* content_size);
50 // Skip to the first byte of the requested read range.
51 // net::OK is returned on success, the error code otherwise.
52 int SkipToRequestedRange(const net::HttpByteRange& byte_range);
54 android_webview::InputStream* stream_;
56 DISALLOW_COPY_AND_ASSIGN(InputStreamReader);
59 } // namespace android_webview
61 #endif // ANDROID_WEBVIEW_NATIVE_INPUT_STREAM_READER_H_