[Android] Pass the blacklist file to android gtests run via testing/scripts/.
[chromium-blink-merge.git] / net / base / upload_element_reader.h
blob267df8c89d3a9013100d56b9d0c56a318959b7f1
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 NET_BASE_UPLOAD_ELEMENT_READER_H_
6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_
8 #include "base/basictypes.h"
9 #include "net/base/completion_callback.h"
10 #include "net/base/net_export.h"
12 namespace net {
14 class IOBuffer;
15 class UploadBytesElementReader;
16 class UploadDiskCacheEntryElementReader;
17 class UploadFileElementReader;
19 // An interface to read an upload data element.
20 class NET_EXPORT UploadElementReader {
21 public:
22 UploadElementReader() {}
23 virtual ~UploadElementReader() {}
25 // Returns this instance's pointer as UploadDiskCacheEntryElementReader when
26 // possible, otherwise returns nullptr.
27 virtual const UploadDiskCacheEntryElementReader*
28 AsDiskCacheEntryReaderForTests() const;
30 // Returns this instance's pointer as UploadBytesElementReader when possible,
31 // otherwise returns NULL.
32 virtual const UploadBytesElementReader* AsBytesReader() const;
34 // Returns this instance's pointer as UploadFileElementReader when possible,
35 // otherwise returns NULL.
36 virtual const UploadFileElementReader* AsFileReader() const;
38 // Initializes the instance synchronously when possible, otherwise does
39 // initialization aynschronously, returns ERR_IO_PENDING and runs callback.
40 // Calling this method again after a Init() success results in resetting the
41 // state.
42 virtual int Init(const CompletionCallback& callback) = 0;
44 // Returns the byte-length of the element. For files that do not exist, 0
45 // is returned. This is done for consistency with Mozilla.
46 virtual uint64_t GetContentLength() const = 0;
48 // Returns the number of bytes remaining to read.
49 virtual uint64_t BytesRemaining() const = 0;
51 // Returns true if the upload element is entirely in memory.
52 // The default implementation returns false.
53 virtual bool IsInMemory() const;
55 // Reads up to |buf_length| bytes synchronously and returns the number of
56 // bytes read or error code when possible, otherwise, returns ERR_IO_PENDING
57 // and runs |callback| with the result. |buf_length| must be greater than 0.
58 virtual int Read(IOBuffer* buf,
59 int buf_length,
60 const CompletionCallback& callback) = 0;
62 private:
63 DISALLOW_COPY_AND_ASSIGN(UploadElementReader);
66 } // namespace net
68 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_