| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 WEBKIT_BROWSER_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_ | |
| 6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/platform_file.h" | |
| 10 | |
| 11 namespace fileapi { | |
| 12 | |
| 13 using base::PlatformFileError; | |
| 14 | |
| 15 // This class is used for implementing Open() in FileUtilAsync. This class | |
| 16 // is similar to net::FileStream, but supporting only the asynchronous | |
| 17 // operations and not necessarily relying on PlatformFile. | |
| 18 class AsyncFileStream { | |
| 19 public: | |
| 20 // Used for Read() and Write(). |result| is the return code of the | |
| 21 // operation, and |length| is the length of data read or written. | |
| 22 typedef base::Callback<void(PlatformFileError result, | |
| 23 int64 length)> ReadWriteCallback; | |
| 24 | |
| 25 // Used for Seek(). |result| is the return code of the operation. | |
| 26 typedef base::Callback<void(PlatformFileError)> SeekCallback; | |
| 27 | |
| 28 virtual ~AsyncFileStream() {}; | |
| 29 | |
| 30 // Reads data from the current stream position. Up to |length| bytes | |
| 31 // will be read from |buffer|. The memory pointed to by |buffer| must | |
| 32 // remain valid until the callback is called. On success, | |
| 33 // PLATFORM_FILE_OK is passed to |callback| with the number of bytes | |
| 34 // read. On failure, an error code is passed instead. | |
| 35 virtual void Read(char* buffer, | |
| 36 int64 length, | |
| 37 const ReadWriteCallback& callback) = 0; | |
| 38 | |
| 39 // Writes data at the current stream position. Up to |length| bytes will | |
| 40 // be written from |buffer|. The memory pointed to by |buffer| must | |
| 41 // remain valid until the callback is called. On success, | |
| 42 // PLATFORM_FILE_OK is passed to |callback| with the number of bytes | |
| 43 // written. On failure, an error code is passed instead. | |
| 44 virtual void Write(const char* buffer, | |
| 45 int64 length, | |
| 46 const ReadWriteCallback& callback) = 0; | |
| 47 | |
| 48 // Moves the stream position. On success, PLATFORM_FILE_OK is passed to | |
| 49 // |callback|. On error, an error code is passed instead. | |
| 50 virtual void Seek(int64 offset, | |
| 51 const SeekCallback& callback) = 0; | |
| 52 }; | |
| 53 | |
| 54 } // namespace fileapi | |
| 55 | |
| 56 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_ | |
| OLD | NEW |