Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: webkit/chromeos/fileapi/async_file_stream.h

Issue 8907014: Implement async verision of FileSystemFileUtil and in-memory file system for testing purposes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add webkit/chromeos/OWNERS Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/chromeos/fileapi/async_file_stream.h
diff --git a/webkit/chromeos/fileapi/async_file_stream.h b/webkit/chromeos/fileapi/async_file_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d27fe2cf2043e94f6beb6969cf0f866ce91b513
--- /dev/null
+++ b/webkit/chromeos/fileapi/async_file_stream.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_
+#define WEBKIT_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_
+
+#include "base/platform_file.h"
+#include "base/callback.h"
tony 2011/12/16 18:13:25 Nit: Sort includes.
satorux1 2011/12/16 22:53:22 Done.
+
+namespace fileapi {
+
+using base::PlatformFileError;
+
+// This class is used for implementing Open() in FileUtilAsync. This class
+// is similar to net::FileStream, but supporting only the asynchronous
+// operations and not necessarily relying on PlatformFile.
+class AsyncFileStream {
+ public:
+ // Used for Read() and Write(). |result| is the return code of the
+ // operation, and |length| is the length of data read or written.
+ typedef base::Callback<void(PlatformFileError result,
+ int64 length)> ReadWriteCallback;
+
+ // Used for Seek(). |result| is the return code of the operation.
+ typedef base::Callback<void(PlatformFileError)> SeekCallback;
+
+ virtual ~AsyncFileStream() {};
+
+ // Reads data from the current stream position. Up to |length| bytes
+ // will be read from |buffer|. The memory pointed to by |buffer| must
+ // remain valid until the callback is called. On success,
+ // PLATFORM_FILE_OK is passed to |callback| with the number of bytes
+ // read. On failure, an error code is passed instead.
+ virtual void Read(char* buffer,
+ int64 length,
+ const ReadWriteCallback& callback) = 0;
+
+ // Writes data at the current stream position. Up to |length| bytes will
+ // be written from |buffer|. The memory pointed to by |buffer| must
+ // remain valid until the callback is called. On success,
+ // PLATFORM_FILE_OK is passed to |callback| with the number of bytes
+ // written. On failure, an error code is passed instead.
+ virtual void Write(const char* buffer,
+ int64 length,
+ const ReadWriteCallback& callback) = 0;
+
+ // Moves the stream position. On success, PLATFORM_FILE_OK is passed to
+ // |callback|. On error, an error code is passed instead.
+ virtual void Seek(int64 offset,
+ const SeekCallback& callback) = 0;
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_CHROMEOS_FILEAPI_ASYNC_FILE_STREAM_H_

Powered by Google App Engine
This is Rietveld 408576698