summaryrefslogtreecommitdiffstats
path: root/webkit/browser/fileapi/file_stream_writer.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 02:08:07 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 02:08:07 +0000
commitc6f9203a46211bb08b84f73b4e1df303f1ab8c42 (patch)
treeb8774c1e80f5e37c7f31a889023962fb3eb1bb7e /webkit/browser/fileapi/file_stream_writer.h
parentba7e19a2704f1c4772d1f1f3a45a2b2b78c0bbd7 (diff)
downloadchromium_src-c6f9203a46211bb08b84f73b4e1df303f1ab8c42.zip
chromium_src-c6f9203a46211bb08b84f73b4e1df303f1ab8c42.tar.gz
chromium_src-c6f9203a46211bb08b84f73b4e1df303f1ab8c42.tar.bz2
Move browser-specific FileAPI code from webkit/fileapi to webkit/browser/fileapi
Moving following files: - file_system_context* - file_system_operation* - file_system_url* - and all others but not in syncable/ ones BUG=239710 TBR=avi@chromium.org, tzik@chromium.org Review URL: https://codereview.chromium.org/15859007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/browser/fileapi/file_stream_writer.h')
-rw-r--r--webkit/browser/fileapi/file_stream_writer.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/webkit/browser/fileapi/file_stream_writer.h b/webkit/browser/fileapi/file_stream_writer.h
new file mode 100644
index 0000000..fe79a24
--- /dev/null
+++ b/webkit/browser/fileapi/file_stream_writer.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 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_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_
+#define WEBKIT_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_
+
+#include "base/basictypes.h"
+#include "net/base/completion_callback.h"
+#include "webkit/storage/webkit_storage_export.h"
+
+namespace net {
+class IOBuffer;
+}
+
+namespace fileapi {
+
+// A generic interface for writing to a file-like object.
+class WEBKIT_STORAGE_EXPORT_PRIVATE FileStreamWriter {
+ public:
+ // Closes the file. If there's an in-flight operation, it is canceled (i.e.,
+ // the callback function associated with the operation is not called).
+ virtual ~FileStreamWriter() {}
+
+ // Writes to the current cursor position asynchronously.
+ //
+ // Up to buf_len bytes will be written. (In other words, partial
+ // writes are allowed.) If the write completed synchronously, it returns
+ // the number of bytes written. If the operation could not be performed, it
+ // returns an error code. Otherwise, net::ERR_IO_PENDING is returned, and the
+ // callback will be run on the thread where Write() was called when the write
+ // has completed.
+ //
+ // This errors out (either synchronously or via callback) with:
+ // net::ERR_FILE_NOT_FOUND: When the target file is not found.
+ // net::ERR_ACCESS_DENIED: When the target file is a directory or
+ // the writer has no permission on the file.
+ // net::ERR_FILE_NO_SPACE: When the write will result in out of quota
+ // or there is not enough room left on the disk.
+ //
+ // It is invalid to call Write while there is an in-flight async operation.
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) = 0;
+
+ // Cancels an in-flight async operation.
+ //
+ // If the cancel is finished synchronously, it returns net::OK. If the
+ // cancel could not be performed, it returns an error code. Especially when
+ // there is no in-flight operation, net::ERR_UNEXPECTED is returned.
+ // Otherwise, net::ERR_IO_PENDING is returned, and the callback will be run on
+ // the thread where Cancel() was called when the cancel has completed. It is
+ // invalid to call Cancel() more than once on the same async operation.
+ //
+ // In either case, the callback function passed to the in-flight async
+ // operation is dismissed immediately when Cancel() is called, and thus
+ // will never be called.
+ virtual int Cancel(const net::CompletionCallback& callback) = 0;
+
+ // Flushes the data written so far.
+ //
+ // If the flush finished synchronously, it return net::OK. If the flush could
+ // not be performed, it returns an error code. Otherwise, net::ERR_IO_PENDING
+ // is returned, and the callback will be run on the thread where Flush() was
+ // called when the flush has completed.
+ //
+ // It is invalid to call Flush while there is an in-flight async operation.
+ virtual int Flush(const net::CompletionCallback& callback) = 0;
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_BROWSER_FILEAPI_FILE_STREAM_WRITER_H_