| Index: ppapi/proxy/file_io_resource.h
|
| diff --git a/ppapi/proxy/file_io_resource.h b/ppapi/proxy/file_io_resource.h
|
| index a2b928dcd840b81958ffab3bbb32ac3435c97b92..d81bcf326a8d7113f85de3481c3b2ef112cee490 100644
|
| --- a/ppapi/proxy/file_io_resource.h
|
| +++ b/ppapi/proxy/file_io_resource.h
|
| @@ -71,26 +71,54 @@ class PPAPI_PROXY_EXPORT FileIOResource
|
| int32_t bytes_to_read,
|
| const PP_ArrayOutput& array_output,
|
| scoped_refptr<TrackedCallback> callback);
|
| + void CloseFileHandle();
|
|
|
| - // Handlers of reply messages. Note that all of them have a callback
|
| - // parameters bound when call to the host.
|
| + // 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,
|
| const ResourceMessageReplyParams& params);
|
|
|
| + // When we pass a callback to FileUtilProxy code, we must keep the resource
|
| + // alive until it's called. However, we can't directly pass a reference to the
|
| + // resource, since that can cause our destructor to run when when the callback
|
| + // is destroyed, when we don't hold the proxy lock. Instead, pass a scoped_ptr
|
| + // to a scoped_refptr. This keeps the resource alive and allows us to take the
|
| + // reference so the destructor only runs while we hold the lock.
|
| + typedef scoped_ptr<scoped_refptr<FileIOResource> > PassedRef;
|
| +
|
| + // These callbacks can be safely passed to FileUtilProxy. They take the lock,
|
| + // then take the resource reference and run the reply message handler. If
|
| + // this is the last reference, the destructor will run while we hold the lock.
|
| + static void QueryCallback(PassedRef file_io_ref,
|
| + scoped_refptr<TrackedCallback> callback,
|
| + PP_FileInfo* output_info,
|
| + base::PlatformFileError error_code,
|
| + const base::PlatformFileInfo& file_info);
|
| +
|
| + static void ReadCallback(PassedRef file_io_ref,
|
| + scoped_refptr<TrackedCallback> callback,
|
| + PP_ArrayOutput array_output,
|
| + base::PlatformFileError error_code,
|
| + const char* data, int bytes_read);
|
| +
|
| + // Reply message handlers for operations that are done in the plugin process.
|
| + // These should not be called directly.
|
| + void OnQueryComplete(scoped_refptr<TrackedCallback> callback,
|
| + PP_FileInfo* output_info,
|
| + base::PlatformFileError error_code,
|
| + const base::PlatformFileInfo& file_info);
|
| + void OnReadComplete(scoped_refptr<TrackedCallback> callback,
|
| + PP_ArrayOutput array_output,
|
| + base::PlatformFileError error_code,
|
| + const char* data, int bytes_read);
|
| +
|
| + PP_FileHandle file_handle_;
|
| + PP_FileSystemType file_system_type_;
|
| FileIOStateManager state_manager_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(FileIOResource);
|
|
|