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

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: '' 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..9ad29452e5566ca54b2580f558ffc16063325a32 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -93,6 +93,20 @@ class PPB_FileIO_Impl : public Resource,
OPERATION_NONE,
};
+ struct PendingOperation {
yzshen1 2011/07/21 22:23:34 It seems we have two kinds of "pending" now. - cal
kinuko 2011/07/26 16:27:46 I've moved all the quota-related 'pending' bookkee
+ enum Type { UNKNOWN, WRITE, SETLENGTH, WILL_WRITE, WILL_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,11 +121,12 @@ 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,
@@ -121,12 +136,25 @@ class PPB_FileIO_Impl : public Resource,
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);
+
+ // Quota related methods.
+ bool DoesRequireQuotaCheck() const;
+ bool QueryFileSizeAndQuota(const PendingOperation& op);
+ void DidQueryInfoForQuota(base::PlatformFileError error_code,
+ const base::PlatformFileInfo& file_info);
+ void DidQueryAvailableSpace(int64_t avail_space);
+ void DidQueryFileSizeAndQuota();
+ bool CommonQuotaCheck(int64_t growth);
base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_;
base::PlatformFile file_;
PP_FileSystemType file_system_type_;
+ // Valid only for PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY}.
+ GURL path_url_;
+
std::queue<CallbackEntry> callbacks_;
OperationType pending_op_;
@@ -134,6 +162,21 @@ class PPB_FileIO_Impl : public Resource,
// pending for it.
PP_FileInfo* info_;
+ // Valid only while there're pending write requests.
yzshen1 2011/07/21 22:23:34 I think SetLength/Will* also use this, right? (PS
kinuko 2011/07/26 16:27:46 Fixed the comment (in quota_file_io.h)
+ int64_t cached_file_size_;
+ int64_t cached_available_space_;
+
+ // For async quota query bookkeeping.
+ int outstanding_quota_queries_;
+ int outstanding_errors_;
+ std::queue<PendingOperation> pending_quota_checks_;
+ std::queue<CallbackEntry> pending_quota_check_callbacks_;
yzshen1 2011/07/21 22:23:34 I would suggest that you don't keep another Callba
kinuko 2011/07/26 16:27:46 In the new QuotaFileIO class I organized the code/
+ bool did_notify_will_update_;
+
+ std::queue<int64_t> pending_write_offset_;
yzshen1 2011/07/21 22:23:34 I think this should be part of CallbackEntry, righ
kinuko 2011/07/26 16:27:46 Similarly they now belong to each (QuotaFileIO's)
+ int64_t pending_setlength_length_;
+ int64_t max_written_offset_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl);
};

Powered by Google App Engine
This is Rietveld 408576698