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

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

Issue 7433006: Pepper quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated 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/ppb_file_io_impl.h
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 327f713c9c508241a6e5540ca394ed3fd2211276..348d870ee5bace12e56ae748a64b1e7ea99e16ad 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -8,6 +8,7 @@
#include <queue>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
@@ -93,6 +94,20 @@ class PPB_FileIO_Impl : public Resource,
OPERATION_NONE,
};
+ struct PendingOperation {
+ enum Type { UNKNOWN, WRITE, SETLENGTH };
+ PendingOperation();
+ Type type;
+
+ // For WRITE.
+ int64_t offset;
+ const char* buffer;
+ int32_t bytes_to_write;
+
+ // For SETLENGTH.
+ int64_t length;
+ };
+
// Verifies:
// - that |callback| is valid (only nonblocking operation supported);
// - that the file is already open or not, depending on |should_be_open|; and
@@ -107,26 +122,42 @@ class PPB_FileIO_Impl : public Resource,
// Sets up a pending callback. This should only be called once it is certain
// that |PP_OK_COMPLETIONPENDING| will be returned.
// |read_buffer| is only used by read operations.
- void RegisterCallback(OperationType op,
+ void RegisterCallback(std::queue<CallbackEntry>* callbacks,
+ OperationType op,
PP_CompletionCallback callback,
char* rend_buffer);
-
- void RunAndRemoveFirstPendingCallback(int32_t result);
+ void RunAndRemoveFirstPendingCallback(std::queue<CallbackEntry>* callbacks,
+ int32_t result);
void StatusCallback(base::PlatformFileError error_code);
void AsyncOpenFileCallback(base::PlatformFileError error_code,
- base::PassPlatformFile file);
+ base::PassPlatformFile file,
+ int64_t file_size);
void QueryInfoCallback(base::PlatformFileError error_code,
const base::PlatformFileInfo& file_info);
void ReadCallback(base::PlatformFileError error_code,
const char* data, int bytes_read);
void WriteCallback(base::PlatformFileError error_code, int bytes_written);
+ void SetLengthCallback(base::PlatformFileError error_code);
+
+ bool DoesRequireQuotaCheck() const;
+ bool HasNoPendingWrites() const;
+ void QueryAvailableSpace(const PendingOperation& op);
+ void DidQueryAvailableSpace(int64_t avail_space);
base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_;
base::PlatformFile file_;
PP_FileSystemType file_system_type_;
+ // They are valid only for files of
+ // PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}.
+ GURL origin_url_;
+ int64_t file_size_;
+
+ // Valid only while there're pending write requests.
+ int64_t cached_available_space_;
+
std::queue<CallbackEntry> callbacks_;
OperationType pending_op_;
@@ -134,6 +165,12 @@ class PPB_FileIO_Impl : public Resource,
// pending for it.
PP_FileInfo* info_;
+ std::queue<PendingOperation> pending_quota_checks_;
+ std::queue<CallbackEntry> pending_quota_check_callbacks_;
+
+ std::queue<int64_t> pending_write_offset_;
+ int64_t pending_setlength_length_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl);
};

Powered by Google App Engine
This is Rietveld 408576698