Chromium Code Reviews| Index: webkit/fileapi/sandbox_file_writer.h |
| diff --git a/webkit/fileapi/sandbox_file_writer.h b/webkit/fileapi/sandbox_file_writer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f03a6c83677fe9ebe278f2874e41e5e33f78b17 |
| --- /dev/null |
| +++ b/webkit/fileapi/sandbox_file_writer.h |
| @@ -0,0 +1,90 @@ |
| +// 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_SANDBOX_FILE_WRITER_H_ |
| +#define WEBKIT_FILEAPI_SANDBOX_FILE_WRITER_H_ |
| + |
| +#include "base/file_path.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/platform_file.h" |
| +#include "googleurl/src/gurl.h" |
| +#include "webkit/fileapi/file_system_types.h" |
| +#include "webkit/fileapi/file_writer.h" |
| +#include "webkit/quota/quota_types.h" |
| + |
| +namespace fileapi { |
| + |
| +class FileSystemContext; |
| +class FileSystemQuotaUtil; |
| +class LocalFileWriter; |
| + |
| +class SandboxFileWriter : public FileWriter { |
|
ericu
2012/05/16 00:23:17
Side note: FileWriter is a really confusing name f
kinuko
2012/05/16 04:10:12
Right, but we also have duplicated FileReader, Fil
ericu
2012/05/17 00:04:13
That's a great list of names to fix. I think it's
kinuko
2012/05/17 04:45:26
Filed a new bug. Either we change the name immedia
|
| + public: |
| + SandboxFileWriter(FileSystemContext* file_system_context, |
| + const GURL& url, |
| + int64 initial_offset); |
| + virtual ~SandboxFileWriter(); |
| + |
| + // FileWriter overrides. |
| + virtual int Write(net::IOBuffer* buf, int buf_len, |
| + const net::CompletionCallback& callback) OVERRIDE; |
| + virtual int Cancel(const net::CompletionCallback& callback) OVERRIDE; |
| + |
| + // Used only by tests. |
| + void set_default_quota(int64 quota) { |
| + default_quota_ = quota; |
| + } |
| + |
| + private: |
| + // Performs quota calculation and calls local_file_writer_->Write(). |
| + int WriteInternal(net::IOBuffer* buf, int buf_len, |
| + const net::CompletionCallback& callback); |
| + |
| + // Callbacks that are chained for the first write. This eventually calls |
| + // WriteInternal. |
| + void DidGetFileInfo(const net::CompletionCallback& callback, |
| + base::PlatformFileError file_error, |
| + const base::PlatformFileInfo& file_info, |
| + const FilePath& platform_path); |
| + void DidGetUsageAndQuota(const net::CompletionCallback& callback, |
| + quota::QuotaStatusCode status, |
| + int64 usage, int64 quota); |
| + void DidInitializeForWrite(net::IOBuffer* buf, int buf_len, |
| + const net::CompletionCallback& callback, |
| + int init_status); |
| + |
| + void DidWrite(const net::CompletionCallback& callback, int write_response); |
| + |
| + // Stops the in-flight operation, calls |cancel_callback_| and returns true |
| + // if there's a pending cancel request. |
| + bool CancelIfRequested(); |
| + |
| + FileSystemQuotaUtil* quota_util() const; |
| + |
| + scoped_refptr<FileSystemContext> file_system_context_; |
| + const GURL url_; |
| + int64 initial_offset_; |
| + scoped_ptr<LocalFileWriter> local_file_writer_; |
| + net::CompletionCallback cancel_callback_; |
| + |
| + GURL origin_; |
| + FileSystemType file_system_type_; |
| + FilePath virtual_path_; |
| + |
| + FilePath file_path_; |
| + int64 file_size_; |
| + int64 total_bytes_written_; |
| + int64 allowed_bytes_to_write_; |
| + bool has_pending_operation_; |
| + |
| + int64 default_quota_; |
| + |
| + base::WeakPtrFactory<SandboxFileWriter> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SandboxFileWriter); |
| +}; |
| + |
| +} // namespace fileapi |
| + |
| +#endif // WEBKIT_FILEAPI_SANDBOX_FILE_WRITER_H_ |