| 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 // Abstract class similar to net::FileStream, but supporting only |
| 16 // the asyncronous operations and not necessarily relying on PlatformFile. |
| 17 class AsyncFileStream { |
| 18 public: |
| 19 // Used for Read() and Write(). |result| is the return code of the |
| 20 // operation, and |length| is the length of data read or written. |
| 21 typedef base::Callback<void(PlatformFileError result, |
| 22 int64 length)> ReadWriteCallback; |
| 23 |
| 24 // Used for Seek(). |result| is the return code of the operation. |
| 25 typedef base::Callback<void(PlatformFileError)> SeekCallback; |
| 26 |
| 27 virtual ~AsyncFileStream() {}; |
| 28 |
| 29 // Reads data from the current stream position. Up to |length| bytes |
| 30 // will be read from |buffer|. The memory pointed to by |buffer| must |
| 31 // remain valid until the callback is called. |
| 32 virtual void Read(char* buffer, |
| 33 int64 length, |
| 34 const ReadWriteCallback& callback) = 0; |
| 35 |
| 36 // Writes data at the current stream position. Up to |length| bytes will |
| 37 // be written from |buffer|. The memory pointed to by |buffer| must |
| 38 // remain valid until the callback is called. |
| 39 virtual void Write(const char* buffer, |
| 40 int64 length, |
| 41 const ReadWriteCallback& callback) = 0; |
| 42 |
| 43 virtual void Seek(int64 offset, |
| 44 const SeekCallback& callback) = 0; |
| 45 }; |
| 46 |
| 47 } // namespace fileapi |
| 48 |
| 49 #endif // WEBKIT_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_ |
| OLD | NEW |