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..e46b11a325ecad31737324946b1f125d0f5e6717 |
| --- /dev/null |
| +++ b/webkit/fileapi/file_writer.h |
| @@ -0,0 +1,55 @@ |
| +// 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" |
|
kinuko
2012/04/24 09:26:50
This file is probably not needed in .h
kinaba
2012/04/24 09:47:42
Done.
|
| + |
| +namespace net { |
| +class IOBuffer; |
| +} |
| + |
| +namespace fileapi { |
| + |
| +// A generic interface for writing to a file-like object. |
| +class FileWriter { |
| + 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 ~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; |
| + |
| + // 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. 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. |
|
kinuko
2012/04/24 09:26:50
Could you also mention that it returns with ERR_UN
kinaba
2012/04/24 09:47:42
Done.
|
| + // |
| + // 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; |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_FILE_WRITER_H_ |
| + |