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

Unified Diff: webkit/fileapi/sandbox_file_writer.h

Issue 10387054: Implement SandboxFileWriter and rewrite FileWriterDelegate to use it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 7 months 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
« no previous file with comments | « webkit/fileapi/file_writer_delegate_unittest.cc ('k') | webkit/fileapi/sandbox_file_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
+ 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_
« no previous file with comments | « webkit/fileapi/file_writer_delegate_unittest.cc ('k') | webkit/fileapi/sandbox_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698