| 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 WEBKIT_BLOB_FILE_READER_H_ | 5 #ifndef WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| 6 #define WEBKIT_BLOB_FILE_READER_H_ | 6 #define WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 #include "webkit/blob/blob_export.h" | 12 #include "webkit/blob/blob_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class FileStream; | |
| 16 class IOBuffer; | 15 class IOBuffer; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace webkit_blob { | 18 namespace webkit_blob { |
| 20 | 19 |
| 21 // A generic interface for reading a file-like object. | 20 // A generic interface for reading a file-like object. |
| 22 class BLOB_EXPORT FileReader { | 21 class BLOB_EXPORT FileStreamReader { |
| 23 public: | 22 public: |
| 24 // It is valid to delete the reader at any time. If the stream is deleted | 23 // It is valid to delete the reader at any time. If the stream is deleted |
| 25 // while it has a pending read, its callback will not be called. | 24 // while it has a pending read, its callback will not be called. |
| 26 virtual ~FileReader() {} | 25 virtual ~FileStreamReader() {} |
| 27 | 26 |
| 28 // Reads from the current cursor position asynchronously. | 27 // Reads from the current cursor position asynchronously. |
| 29 // | 28 // |
| 30 // Up to buf_len bytes will be copied into buf. (In other words, partial | 29 // Up to buf_len bytes will be copied into buf. (In other words, partial |
| 31 // reads are allowed.) Returns the number of bytes copied, 0 if at | 30 // reads are allowed.) Returns the number of bytes copied, 0 if at |
| 32 // end-of-file, or an error code if the operation could not be performed. | 31 // end-of-file, or an error code if the operation could not be performed. |
| 33 // If the read could not complete synchronously, then ERR_IO_PENDING is | 32 // If the read could not complete synchronously, then ERR_IO_PENDING is |
| 34 // returned, and the callback will be run on the thread where Read() | 33 // returned, and the callback will be run on the thread where Read() |
| 35 // was called, when the read has completed. | 34 // was called, when the read has completed. |
| 36 // | 35 // |
| 37 // It is invalid to call Read while there is an in-flight Read operation. | 36 // It is invalid to call Read while there is an in-flight Read operation. |
| 38 // | 37 // |
| 39 // If the stream is deleted while it has an in-flight Read operation | 38 // If the stream is deleted while it has an in-flight Read operation |
| 40 // |callback| will not be called. | 39 // |callback| will not be called. |
| 41 virtual int Read(net::IOBuffer* buf, int buf_len, | 40 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 42 const net::CompletionCallback& callback) = 0; | 41 const net::CompletionCallback& callback) = 0; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 } // namespace webkit_blob | 44 } // namespace webkit_blob |
| 46 | 45 |
| 47 #endif // WEBKIT_BLOB_FILE_READER_H_ | 46 #endif // WEBKIT_BLOB_FILE_STREAM_READER_H_ |
| OLD | NEW |