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

Unified Diff: ppapi/proxy/file_io_resource.h

Issue 22646005: Do PPB_FileIO Query and Read in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 4 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: ppapi/proxy/file_io_resource.h
diff --git a/ppapi/proxy/file_io_resource.h b/ppapi/proxy/file_io_resource.h
index dffa940b046e904828a6b7ba32e66f1a45bad30a..3ca7bf0c9a92ca0550538b1a3bd56c84c96c441b 100644
--- a/ppapi/proxy/file_io_resource.h
+++ b/ppapi/proxy/file_io_resource.h
@@ -67,6 +67,25 @@ class PPAPI_PROXY_EXPORT FileIOResource
scoped_refptr<TrackedCallback> callback) OVERRIDE;
private:
+ // Class to share file read state between threads.
+ class ReadData : public base::RefCountedThreadSafe<ReadData> {
+ public:
+ explicit ReadData(int32_t bytes_to_read);
+
+ char* buffer() const { return buffer_.get(); }
+ int32_t bytes_read() const { return bytes_read_; }
+ void set_bytes_read(int32_t bytes_read) { bytes_read_ = bytes_read; }
+
+ private:
+ friend class base::RefCountedThreadSafe<ReadData>;
+ virtual ~ReadData();
+
+ // We can't read directly into the plugin's buffer, since we can't be sure
+ // that the call hasn't already aborted. Read into this buffer instead.
+ scoped_ptr<char[]> buffer_;
+ int32_t bytes_read_;
+ };
+
int32_t ReadValidated(int64_t offset,
int32_t bytes_to_read,
const PP_ArrayOutput& array_output,
@@ -74,19 +93,25 @@ class PPAPI_PROXY_EXPORT FileIOResource
void CloseFileHandle();
+ // File tasks. These are called on the file thread (for non-blocking calls)
+ // and on the plugin's thread (for blocking calls).
dmichael (off chromium) 2013/08/09 17:37:42 maybe note that they run without the ProxyLock?
bbudge 2013/08/09 21:43:24 I removed these and put them on the ops classes.
+ void DoQuery();
+ void DoRead(int64_t offset,
+ int32_t bytes_to_read,
+ scoped_refptr<ReadData> read_data);
+
+ void OnFileTaskComplete(scoped_refptr<TrackedCallback> callback);
+
+ // Completion tasks for file operations that are done in the plugin.
+ int32_t OnQueryComplete(PP_FileInfo* info, int32_t result);
+ int32_t OnReadComplete(scoped_refptr<ReadData> read_data,
+ PP_ArrayOutput array_output, int32_t result);
+
// Reply message handlers for operations that are done in the host.
void OnPluginMsgGeneralComplete(scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params);
void OnPluginMsgOpenFileComplete(scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params);
- void OnPluginMsgQueryComplete(scoped_refptr<TrackedCallback> callback,
- PP_FileInfo* output_info_,
- const ResourceMessageReplyParams& params,
- const PP_FileInfo& info);
- void OnPluginMsgReadComplete(scoped_refptr<TrackedCallback> callback,
- PP_ArrayOutput array_output,
- const ResourceMessageReplyParams& params,
- const std::string& data);
void OnPluginMsgRequestOSFileHandleComplete(
scoped_refptr<TrackedCallback> callback,
PP_FileHandle* output_handle,
@@ -96,6 +121,12 @@ class PPAPI_PROXY_EXPORT FileIOResource
PP_FileSystemType file_system_type_;
FileIOStateManager state_manager_;
+ // Temporary state for Query. These are written by the file thread (for
+ // non-blocking calls) or the plugin's thread (for blocking calls), and read
+ // only on the plugin's thread.
+ base::PlatformFileInfo file_info_;
+ int32_t query_result_;
dmichael (off chromium) 2013/08/09 17:37:42 These aren't *that* big. What about making them pa
bbudge 2013/08/09 21:43:24 Added a QueryOp ref counted class to remove these
+
DISALLOW_COPY_AND_ASSIGN(FileIOResource);
};

Powered by Google App Engine
This is Rietveld 408576698