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