Chromium Code Reviews| Index: webkit/fileapi/file_writer.h |
| diff --git a/webkit/fileapi/file_writer.h b/webkit/fileapi/file_writer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eaea93396bff84192bd595697855565abb8e6884 |
| --- /dev/null |
| +++ b/webkit/fileapi/file_writer.h |
| @@ -0,0 +1,57 @@ |
| +// 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_FILEAPI_FILE_WRITER_H_ |
| +#define WEBKIT_FILEAPI_FILE_WRITER_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "net/base/completion_callback.h" |
| +#include "net/base/net_errors.h" |
| + |
| +namespace net { |
| +class IOBuffer; |
| +} |
| + |
| +namespace fileapi { |
| + |
| +// A generic interface for writing to a file-like object. |
| +class FileWriter { |
| + public: |
| + // Cancels the in-flight operation (if any) and closes. |
|
kinuko
2012/04/20 11:26:37
This comment sounds like inconsistent from what we
kinaba
2012/04/23 08:56:41
Adjusted the LocalFileWriter's implementation.
|
| + virtual ~FileWriter() {} |
| + |
| + // 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. |
| + // |
| + // 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; |
| + |
| + // Move the current cursor position to |offset| asynchronously. |
|
kinuko
2012/04/20 11:26:37
nit: Moves
kinaba
2012/04/23 08:56:41
Done.
|
| + // |
| + // 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 Seek() was called when the seek has completed. |
| + // |
| + // It is invalid to call Seek while there is an in-flight async operation. |
|
kinuko
2012/04/20 11:26:37
I said we could keep this as is for now, but on th
kinaba
2012/04/23 08:56:41
I'm now inclined to drop Seek() and restrict seeki
|
| + virtual int Seek(int64 offset, |
| + const net::Int64CompletionCallback& callback) = 0; |
| + |
| + // Cancels an in-flight async operation (Write or Seek). When the cancel is |
| + // done, |callback| is called. The callback function passed to the canceled |
| + // async operation is not called. |
| + virtual void Cancel(const net::CompletionCallback& callback) = 0; |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_FILE_WRITER_H_ |
| + |