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

Unified Diff: webkit/plugins/ppapi/quota_file_io.h

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 5 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
Index: webkit/plugins/ppapi/quota_file_io.h
diff --git a/webkit/plugins/ppapi/quota_file_io.h b/webkit/plugins/ppapi/quota_file_io.h
new file mode 100644
index 0000000000000000000000000000000000000000..861b64aaf10066373fae8e6b94e44bef02aab101
--- /dev/null
+++ b/webkit/plugins/ppapi/quota_file_io.h
@@ -0,0 +1,95 @@
+// Copyright (c) 2011 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_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
+#define WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_
+
+#include <deque>
+
+#include "base/file_util_proxy.h"
+#include "base/memory/scoped_callback_factory.h"
+#include "base/platform_file.h"
+#include "googleurl/src/gurl.h"
+#include "ppapi/c/pp_file_info.h"
+#include "webkit/quota/quota_types.h"
+
+namespace webkit {
+namespace ppapi {
+
+class PluginInstance;
+
+// This class is created per PPB_FileIO_Impl instance and provides
+// write operations for quota-managed files (i.e. files of
+// PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}).
+class QuotaFileIO {
+ public:
+ typedef base::FileUtilProxy::WriteCallback WriteCallback;
+ typedef base::FileUtilProxy::StatusCallback StatusCallback;
+
+ QuotaFileIO(PluginInstance* instance,
+ base::PlatformFile file,
+ const GURL& path_url,
+ PP_FileSystemType type);
+ ~QuotaFileIO();
+
+ bool Write(int64_t offset,
yzshen1 2011/07/27 18:26:08 1) Please comment that if returns false the callba
kinuko 2011/07/28 14:11:00 Done.
+ const char* buffer,
+ int32_t bytes_to_write,
+ WriteCallback* callback);
+ bool SetLength(int64_t length, StatusCallback* callback);
+ bool WillWrite(int64_t offset,
+ int32_t bytes_to_write,
+ WriteCallback* callback);
+ bool WillSetLength(int64_t length, StatusCallback* callback);
+
+ private:
+ class PendingOperationBase;
+ class WriteOperation;
+ class SetLengthOperation;
+
+ bool CheckIfExceedsQuota(int64_t new_file_size) const;
+ void WillUpdate();
+ void DidWrite(WriteOperation* op, int64_t written_offset_end);
+ void DidSetLength(base::PlatformFileError error, int64_t new_file_size);
+
+ bool RegisterOperationForQuotaChecks(PendingOperationBase* op);
+ void DidQueryInfoForQuota(base::PlatformFileError error_code,
+ const base::PlatformFileInfo& file_info);
+ void DidQueryAvailableSpace(int64_t avail_space);
+ void DidQueryForQuotaCheck();
+
+ // The plugin instance that owns this (via PPB_FileIO_Impl).
+ PluginInstance* instance_;
+
+ // The file information associated to this instance.
+ base::PlatformFile file_;
+ GURL file_url_;
+ quota::StorageType storage_type_;
+
+ // Operations waiting for a quota check to finish.
+ std::deque<PendingOperationBase*> pending_operations_;
yzshen1 2011/07/27 18:26:08 All you use are *queue* operations. Why to change
kinuko 2011/07/28 14:11:00 I wanted to use methods like size(), begin() and e
yzshen1 2011/07/28 17:40:52 Okay. :) On 2011/07/28 14:11:00, kinuko wrote:
+
+ // Operations queued to dispatch the callbacks.
+ std::deque<PendingOperationBase*> pending_callbacks_;
yzshen1 2011/07/27 18:26:08 It seems to me that you don't need two queues: you
kinuko 2011/07/28 14:11:00 That looks true. Removed.
+
+ // Valid only while there're pending quota checks.
+ int64_t cached_file_size_;
+ int64_t cached_available_space_;
+
+ // Quota-related queries and errors occured during inflight quota checks.
+ int outstanding_quota_queries_;
+ int outstanding_errors_;
+
+ // For parallel writes bookkeeping.
+ int64_t max_written_offset_;
+ int inflight_operations_;
+
+ base::ScopedCallbackFactory<QuotaFileIO> callback_factory_;
+ DISALLOW_COPY_AND_ASSIGN(QuotaFileIO);
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_QUOTA_FILE_IO_H_

Powered by Google App Engine
This is Rietveld 408576698