OLD | NEW |
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 NET_BASE_UPLOAD_ELEMENT_READER_H_ | 5 #ifndef NET_BASE_UPLOAD_ELEMENT_READER_H_ |
6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_ | 6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual const UploadFileElementReader* AsFileReader() const; | 30 virtual const UploadFileElementReader* AsFileReader() const; |
31 | 31 |
32 // Initializes the instance synchronously when possible, otherwise does | 32 // Initializes the instance synchronously when possible, otherwise does |
33 // initialization aynschronously, returns ERR_IO_PENDING and runs callback. | 33 // initialization aynschronously, returns ERR_IO_PENDING and runs callback. |
34 // Calling this method again after a Init() success results in resetting the | 34 // Calling this method again after a Init() success results in resetting the |
35 // state. | 35 // state. |
36 virtual int Init(const CompletionCallback& callback) = 0; | 36 virtual int Init(const CompletionCallback& callback) = 0; |
37 | 37 |
38 // Returns the byte-length of the element. For files that do not exist, 0 | 38 // Returns the byte-length of the element. For files that do not exist, 0 |
39 // is returned. This is done for consistency with Mozilla. | 39 // is returned. This is done for consistency with Mozilla. |
40 virtual uint64 GetContentLength() const = 0; | 40 virtual uint64_t GetContentLength() const = 0; |
41 | 41 |
42 // Returns the number of bytes remaining to read. | 42 // Returns the number of bytes remaining to read. |
43 virtual uint64 BytesRemaining() const = 0; | 43 virtual uint64_t BytesRemaining() const = 0; |
44 | 44 |
45 // Returns true if the upload element is entirely in memory. | 45 // Returns true if the upload element is entirely in memory. |
46 // The default implementation returns false. | 46 // The default implementation returns false. |
47 virtual bool IsInMemory() const; | 47 virtual bool IsInMemory() const; |
48 | 48 |
49 // Reads up to |buf_length| bytes synchronously and returns the number of | 49 // Reads up to |buf_length| bytes synchronously and returns the number of |
50 // bytes read or error code when possible, otherwise, returns ERR_IO_PENDING | 50 // bytes read or error code when possible, otherwise, returns ERR_IO_PENDING |
51 // and runs |callback| with the result. |buf_length| must be greater than 0. | 51 // and runs |callback| with the result. |buf_length| must be greater than 0. |
52 virtual int Read(IOBuffer* buf, | 52 virtual int Read(IOBuffer* buf, |
53 int buf_length, | 53 int buf_length, |
54 const CompletionCallback& callback) = 0; | 54 const CompletionCallback& callback) = 0; |
55 | 55 |
56 private: | 56 private: |
57 DISALLOW_COPY_AND_ASSIGN(UploadElementReader); | 57 DISALLOW_COPY_AND_ASSIGN(UploadElementReader); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace net | 60 } // namespace net |
61 | 61 |
62 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_ | 62 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_ |
OLD | NEW |