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

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: Defer buffer allocation until we read. 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..1ed3f683cc14426e52ca539b09dbb461b996a7c0 100644
--- a/ppapi/proxy/file_io_resource.h
+++ b/ppapi/proxy/file_io_resource.h
@@ -67,6 +67,46 @@ class PPAPI_PROXY_EXPORT FileIOResource
scoped_refptr<TrackedCallback> callback) OVERRIDE;
private:
+ // Class to perform file query operations across multiple threads.
+ class QueryOp : public base::RefCountedThreadSafe<QueryOp> {
+ public:
+ QueryOp(PP_FileHandle file_handle);
dmichael (off chromium) 2013/08/09 22:20:56 nit: explicit
bbudge 2013/08/09 23:05:28 Done.
+
+ // Queries the file. Called on the file thread (non-blocking) or the plugin
+ // thread (blocking).
dmichael (off chromium) 2013/08/09 22:20:56 please note it does not hold the ProxyLock (same f
bbudge 2013/08/09 23:05:28 Done.
+ int32_t DoWork();
+
+ const base::PlatformFileInfo& file_info() const { return file_info_; }
+
+ private:
+ friend class base::RefCountedThreadSafe<QueryOp>;
+ virtual ~QueryOp();
dmichael (off chromium) 2013/08/09 22:20:56 FWIW... You don't actually need to make it virtua
bbudge 2013/08/09 23:05:28 Done.
+
+ PP_FileHandle file_handle_;
+ base::PlatformFileInfo file_info_;
+ };
+
+ // Class to perform file read operations across multiple threads.
+ class ReadOp : public base::RefCountedThreadSafe<ReadOp> {
+ public:
+ ReadOp(PP_FileHandle file_handle, int64_t offset, int32_t bytes_to_read);
+
+ // Reads the file. Called on the file thread (non-blocking) or the plugin
+ // thread (blocking).
+ int32_t DoWork();
+
+ char* buffer() const { return buffer_.get(); }
+
+ private:
+ friend class base::RefCountedThreadSafe<ReadOp>;
+ virtual ~ReadOp();
+
+ PP_FileHandle file_handle_;
+ int64_t offset_;
+ int32_t bytes_to_read_;
+ scoped_ptr<char[]> buffer_;
+ };
+
int32_t ReadValidated(int64_t offset,
int32_t bytes_to_read,
const PP_ArrayOutput& array_output,
@@ -74,19 +114,23 @@ class PPAPI_PROXY_EXPORT FileIOResource
void CloseFileHandle();
+
+ void OnFileTaskComplete(scoped_refptr<TrackedCallback> callback,
+ int32_t result);
+
+ // Completion tasks for file operations that are done in the plugin.
+ int32_t OnQueryComplete(scoped_refptr<QueryOp> query_op,
+ PP_FileInfo* info,
+ int32_t result);
+ int32_t OnReadComplete(scoped_refptr<ReadOp> read_op,
+ 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,

Powered by Google App Engine
This is Rietveld 408576698