diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 21:02:32 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 21:02:32 +0000 |
commit | 4f95dd7ca9883879dc642c2f61cff2edad412b38 (patch) | |
tree | 48daa9a31f86f5029ebe4e33ca5255e3436cd596 /ppapi | |
parent | 7b0d86deed914f1dcf5d206259699b5f692c6d3c (diff) | |
download | chromium_src-4f95dd7ca9883879dc642c2f61cff2edad412b38.zip chromium_src-4f95dd7ca9883879dc642c2f61cff2edad412b38.tar.gz chromium_src-4f95dd7ca9883879dc642c2f61cff2edad412b38.tar.bz2 |
Implement a proxy for Pepper FileIO.
This splits apart the old in-process implementation into a new object in shared_impl that does most of the general tracking. This alllows that code to be shared by the proxy.
BUG=http://crbug.com/101154
Review URL: http://codereview.chromium.org/8764003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/ppb_file_io.idl | 32 | ||||
-rw-r--r-- | ppapi/c/ppb_file_io.h | 34 | ||||
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 2 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 4 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 53 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_param_traits.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_io_proxy.cc | 442 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_io_proxy.h | 93 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_ref_proxy.cc | 9 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_ref_proxy.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 4 | ||||
-rw-r--r-- | ppapi/shared_impl/api_id.h | 1 | ||||
-rw-r--r-- | ppapi/shared_impl/file_type_conversion.cc | 74 | ||||
-rw-r--r-- | ppapi/shared_impl/file_type_conversion.h | 23 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_file_io_shared.cc | 237 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_file_io_shared.h | 157 | ||||
-rw-r--r-- | ppapi/tests/test_file_io.cc | 37 | ||||
-rw-r--r-- | ppapi/tests/test_url_loader.cc | 60 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_stable.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 2 |
22 files changed, 1216 insertions, 64 deletions
diff --git a/ppapi/api/ppb_file_io.idl b/ppapi/api/ppb_file_io.idl index 0d2c845..d595bdc 100644 --- a/ppapi/api/ppb_file_io.idl +++ b/ppapi/api/ppb_file_io.idl @@ -99,8 +99,9 @@ interface PPB_FileIO { [in] PP_CompletionCallback callback); /** - * Query() queries info about the file opened by this FileIO object. This - * function will fail if the FileIO object has not been opened. + * Query() queries info about the file opened by this FileIO object. The + * FileIO object must be opened, and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a * FileIO. @@ -110,6 +111,8 @@ interface PPB_FileIO { * completion of Query(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t Query([in] PP_Resource file_io, [out] PP_FileInfo info, @@ -117,7 +120,9 @@ interface PPB_FileIO { /** * Touch() Updates time stamps for the file opened by this FileIO object. - * This function will fail if the FileIO object has not been opened. + * This function will fail if the FileIO object has not been opened. The + * FileIO object must be opened, and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -127,6 +132,8 @@ interface PPB_FileIO { * completion of Touch(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t Touch([in] PP_Resource file_io, [in] PP_Time last_access_time, @@ -150,7 +157,8 @@ interface PPB_FileIO { * @return An The number of bytes read an error code from * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was * reached. It is valid to call Read() multiple times with a completion - * callback to queue up parallel reads from the file at different offsets. + * callback to queue up parallel reads from the file, but pending reads + * cannot be interleaved with other operations. */ int32_t Read([in] PP_Resource file_io, [in] int64_t offset, @@ -174,7 +182,8 @@ interface PPB_FileIO { * @return An The number of bytes written or an error code from * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was * reached. It is valid to call Write() multiple times with a completion - * callback to queue up parallel writes to the file at different offsets. + * callback to queue up parallel writes to the file, but pending writes + * cannot be interleaved with other operations. */ int32_t Write([in] PP_Resource file_io, [in] int64_t offset, @@ -183,8 +192,9 @@ interface PPB_FileIO { [in] PP_CompletionCallback callback); /** * SetLength() sets the length of the file. If the file size is extended, - * then the extended area of the file is zero-filled. The FileIO object must - * have been opened with write access. + * then the extended area of the file is zero-filled. The FileIO object must + * have been opened with write access and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -193,13 +203,17 @@ interface PPB_FileIO { * completion of SetLength(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t SetLength([in] PP_Resource file_io, [in] int64_t length, [in] PP_CompletionCallback callback); /** - * Flush() flushes changes to disk. This call can be very expensive! + * Flush() flushes changes to disk. This call can be very expensive! The + * FileIO object must have been opened with write access and there must be no + * other operations pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -207,6 +221,8 @@ interface PPB_FileIO { * completion of Flush(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t Flush([in] PP_Resource file_io, [in] PP_CompletionCallback callback); diff --git a/ppapi/c/ppb_file_io.h b/ppapi/c/ppb_file_io.h index 333984b..aa028b1 100644 --- a/ppapi/c/ppb_file_io.h +++ b/ppapi/c/ppb_file_io.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_file_io.idl modified Mon Aug 29 10:11:34 2011. */ +/* From ppb_file_io.idl modified Thu Dec 1 10:47:02 2011. */ #ifndef PPAPI_C_PPB_FILE_IO_H_ #define PPAPI_C_PPB_FILE_IO_H_ @@ -117,8 +117,9 @@ struct PPB_FileIO { int32_t open_flags, struct PP_CompletionCallback callback); /** - * Query() queries info about the file opened by this FileIO object. This - * function will fail if the FileIO object has not been opened. + * Query() queries info about the file opened by this FileIO object. The + * FileIO object must be opened, and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a * FileIO. @@ -128,13 +129,17 @@ struct PPB_FileIO { * completion of Query(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Query)(PP_Resource file_io, struct PP_FileInfo* info, struct PP_CompletionCallback callback); /** * Touch() Updates time stamps for the file opened by this FileIO object. - * This function will fail if the FileIO object has not been opened. + * This function will fail if the FileIO object has not been opened. The + * FileIO object must be opened, and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -144,6 +149,8 @@ struct PPB_FileIO { * completion of Touch(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Touch)(PP_Resource file_io, PP_Time last_access_time, @@ -166,7 +173,8 @@ struct PPB_FileIO { * @return An The number of bytes read an error code from * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was * reached. It is valid to call Read() multiple times with a completion - * callback to queue up parallel reads from the file at different offsets. + * callback to queue up parallel reads from the file, but pending reads + * cannot be interleaved with other operations. */ int32_t (*Read)(PP_Resource file_io, int64_t offset, @@ -189,7 +197,8 @@ struct PPB_FileIO { * @return An The number of bytes written or an error code from * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was * reached. It is valid to call Write() multiple times with a completion - * callback to queue up parallel writes to the file at different offsets. + * callback to queue up parallel writes to the file, but pending writes + * cannot be interleaved with other operations. */ int32_t (*Write)(PP_Resource file_io, int64_t offset, @@ -198,8 +207,9 @@ struct PPB_FileIO { struct PP_CompletionCallback callback); /** * SetLength() sets the length of the file. If the file size is extended, - * then the extended area of the file is zero-filled. The FileIO object must - * have been opened with write access. + * then the extended area of the file is zero-filled. The FileIO object must + * have been opened with write access and there must be no other operations + * pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -208,12 +218,16 @@ struct PPB_FileIO { * completion of SetLength(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*SetLength)(PP_Resource file_io, int64_t length, struct PP_CompletionCallback callback); /** - * Flush() flushes changes to disk. This call can be very expensive! + * Flush() flushes changes to disk. This call can be very expensive! The + * FileIO object must have been opened with write access and there must be no + * other operations pending. * * @param[in] file_io A <code>PP_Resource</code> corresponding to a file * FileIO. @@ -221,6 +235,8 @@ struct PPB_FileIO { * completion of Flush(). * * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * PP_ERROR_FAILED will be returned if the file isn't opened, and + * PP_ERROR_INPROGRESS will be returned if there is another operation pending. */ int32_t (*Flush)(PP_Resource file_io, struct PP_CompletionCallback callback); /** diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 8765d44..20157f2 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -70,6 +70,8 @@ 'proxy/ppb_cursor_control_proxy.h', 'proxy/ppb_file_chooser_proxy.cc', 'proxy/ppb_file_chooser_proxy.h', + 'proxy/ppb_file_io_proxy.cc', + 'proxy/ppb_file_io_proxy.h', 'proxy/ppb_file_ref_proxy.cc', 'proxy/ppb_file_ref_proxy.h', 'proxy/ppb_file_system_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 51b52df..f7a01d9 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -30,6 +30,8 @@ '../base/base.gyp:base', ], 'sources': [ + 'shared_impl/file_type_conversion.cc', + 'shared_impl/file_type_conversion.h', 'shared_impl/function_group_base.cc', 'shared_impl/function_group_base.h', 'shared_impl/host_resource.h', @@ -50,6 +52,8 @@ 'shared_impl/ppb_char_set_shared.cc', 'shared_impl/ppb_char_set_shared.h', 'shared_impl/ppb_crypto_shared.cc', + 'shared_impl/ppb_file_io_shared.cc', + 'shared_impl/ppb_file_io_shared.h', 'shared_impl/ppb_file_ref_shared.cc', 'shared_impl/ppb_file_ref_shared.h', 'shared_impl/ppb_font_shared.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index da978e1..2d5b90b 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -24,6 +24,7 @@ #include "ppapi/c/ppb_audio_config.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_core.h" +#include "ppapi/c/ppb_file_io.h" #include "ppapi/c/ppb_file_ref.h" #include "ppapi/c/ppb_file_system.h" #include "ppapi/c/ppb_fullscreen.h" @@ -53,6 +54,7 @@ #include "ppapi/c/private/ppb_tcp_socket_private.h" #include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/c/trusted/ppb_broker_trusted.h" +#include "ppapi/c/trusted/ppb_file_io_trusted.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/ppb_audio_input_proxy.h" @@ -62,6 +64,7 @@ #include "ppapi/proxy/ppb_core_proxy.h" #include "ppapi/proxy/ppb_cursor_control_proxy.h" #include "ppapi/proxy/ppb_file_chooser_proxy.h" +#include "ppapi/proxy/ppb_file_io_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_file_system_proxy.h" #include "ppapi/proxy/ppb_flash_clipboard_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index b894db9..32ac229 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -238,6 +238,22 @@ IPC_MESSAGE_ROUTED3( int32_t /* result_code (will be != PP_OK on failure */, std::vector<ppapi::PPB_FileRef_CreateInfo> /* chosen_files */) +// PPB_FileIO. +IPC_MESSAGE_ROUTED2(PpapiMsg_PPBFileIO_GeneralComplete, + ppapi::HostResource /* file_io */, + int32_t /* result */) +IPC_MESSAGE_ROUTED2(PpapiMsg_PPBFileIO_OpenFileComplete, + ppapi::HostResource /* file_io */, + int32_t /* result */) +IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFileIO_QueryComplete, + ppapi::HostResource /* file_io */, + int32_t /* result */, + PP_FileInfo /* info */) +IPC_MESSAGE_ROUTED3(PpapiMsg_PPBFileIO_ReadComplete, + ppapi::HostResource /* file_io */, + int32_t /* result */, + std::string /* data */) + // PPB_FileRef. IPC_MESSAGE_ROUTED3( PpapiMsg_PPBFileRef_CallbackComplete, @@ -555,6 +571,43 @@ IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBFileChooser_Show, std::string /* suggested_file_name */, bool /* require_user_gesture */) +// PPB_FileIO. +IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFileIO_Create, + PP_Instance /* instance */, + ppapi::HostResource /* result */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Open, + ppapi::HostResource /* host_resource */, + ppapi::HostResource /* file_ref_resource */, + int32_t /* open_flags */) +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Close, + ppapi::HostResource /* host_resource */) +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Query, + ppapi::HostResource /* host_resource */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Touch, + ppapi::HostResource /* host_resource */, + PP_Time /* last_access_time */, + PP_Time /* last_modified_time */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Read, + ppapi::HostResource /* host_resource */, + int64_t /* offset */, + int32_t /* bytes_to_read */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_Write, + ppapi::HostResource /* host_resource */, + int64_t /* offset */, + std::string /* data */) +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileIO_SetLength, + ppapi::HostResource /* host_resource */, + int64_t /* length */) +IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFileIO_Flush, + ppapi::HostResource /* host_resource */) +IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileIO_WillWrite, + ppapi::HostResource /* host_resource */, + int64_t /* offset */, + int32_t /* bytes_to_write */) +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileIO_WillSetLength, + ppapi::HostResource /* host_resource */, + int64_t /* length */) + // PPB_FileRef. IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFileRef_Create, ppapi::HostResource /* file_system */, diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index ac66648..ca03910 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc @@ -124,7 +124,8 @@ bool ParamTraits<PP_FileInfo>::Read(const Message* m, void** iter, type != PP_FILETYPE_OTHER) return false; r->type = static_cast<PP_FileType>(type); - if (system_type != PP_FILESYSTEMTYPE_EXTERNAL && + if (system_type != PP_FILESYSTEMTYPE_INVALID && + system_type != PP_FILESYSTEMTYPE_EXTERNAL && system_type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) return false; diff --git a/ppapi/proxy/ppb_file_io_proxy.cc b/ppapi/proxy/ppb_file_io_proxy.cc new file mode 100644 index 0000000..0acd3ac --- /dev/null +++ b/ppapi/proxy/ppb_file_io_proxy.cc @@ -0,0 +1,442 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/ppb_file_io_proxy.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/enter_proxy.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/proxy/ppb_file_ref_proxy.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_file_io_shared.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/resource_tracker.h" + +using ppapi::thunk::PPB_FileIO_API; +using ppapi::thunk::PPB_FileRef_API; + +namespace ppapi { +namespace proxy { + +namespace { + +// The maximum size we'll support reading in one chunk. The renderer process +// must allocate a buffer sized according to the request of the plugin. To +// keep things from getting out of control, we cap the read size to this value. +// This should generally be OK since the API specifies that it may perform a +// partial read. +static const int32_t kMaxReadSize = 33554432; // 32MB + +typedef EnterHostFromHostResourceForceCallback<PPB_FileIO_API> EnterHostFileIO; +typedef EnterPluginFromHostResource<PPB_FileIO_API> EnterPluginFileIO; + +class FileIO : public PPB_FileIO_Shared { + public: + explicit FileIO(const HostResource& host_resource); + virtual ~FileIO(); + + // PPB_FileIO_API implementation (not provided by FileIOImpl). + virtual void Close() OVERRIDE; + virtual int32_t GetOSFileDescriptor() OVERRIDE; + virtual int32_t WillWrite(int64_t offset, + int32_t bytes_to_write, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t WillSetLength(int64_t length, + PP_CompletionCallback callback) OVERRIDE; + + private: + // FileIOImpl overrides. + virtual int32_t OpenValidated(PP_Resource file_ref_resource, + PPB_FileRef_API* file_ref_api, + int32_t open_flags, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t QueryValidated(PP_FileInfo* info, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t TouchValidated(PP_Time last_access_time, + PP_Time last_modified_time, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t ReadValidated(int64_t offset, + char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t WriteValidated(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t SetLengthValidated(int64_t length, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t FlushValidated(PP_CompletionCallback callback) OVERRIDE; + + PluginDispatcher* GetDispatcher() const { + return PluginDispatcher::GetForResource(this); + } + + static const ApiID kApiID = API_ID_PPB_FILE_IO; + + DISALLOW_IMPLICIT_CONSTRUCTORS(FileIO); +}; + +FileIO::FileIO(const HostResource& host_resource) + : PPB_FileIO_Shared(host_resource) { +} + +FileIO::~FileIO() { + Close(); +} + +void FileIO::Close() { + if (file_open_) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Close(kApiID, + host_resource())); + } +} + +int32_t FileIO::GetOSFileDescriptor() { + return -1; +} + +int32_t FileIO::WillWrite(int64_t offset, + int32_t bytes_to_write, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_WillWrite( + kApiID, host_resource(), offset, bytes_to_write)); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::WillSetLength(int64_t length, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_WillSetLength( + kApiID, host_resource(), length)); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::OpenValidated(PP_Resource file_ref_resource, + PPB_FileRef_API* file_ref_api, + int32_t open_flags, + PP_CompletionCallback callback) { + Resource* file_ref_object = + PpapiGlobals::Get()->GetResourceTracker()->GetResource(file_ref_resource); + + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Open( + kApiID, host_resource(), file_ref_object->host_resource(), open_flags)); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::QueryValidated(PP_FileInfo* info, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Query( + kApiID, host_resource())); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, info); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::TouchValidated(PP_Time last_access_time, + PP_Time last_modified_time, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Touch( + kApiID, host_resource(), last_access_time, last_modified_time)); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::ReadValidated(int64_t offset, + char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Read( + kApiID, host_resource(), offset, bytes_to_read)); + RegisterCallback(OPERATION_READ, callback, buffer, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::WriteValidated(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) { + // TODO(brettw) it would be nice to use a shared memory buffer for large + // writes rather than having to copy to a string (which will involve a number + // of extra copies to serialize over IPC). + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Write( + kApiID, host_resource(), offset, std::string(buffer, bytes_to_write))); + RegisterCallback(OPERATION_WRITE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::SetLengthValidated(int64_t length, + PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_SetLength( + kApiID, host_resource(), length)); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +int32_t FileIO::FlushValidated(PP_CompletionCallback callback) { + GetDispatcher()->Send(new PpapiHostMsg_PPBFileIO_Flush( + kApiID, host_resource())); + RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); + return PP_OK_COMPLETIONPENDING; +} + +} // namespace + +// ----------------------------------------------------------------------------- + +PPB_FileIO_Proxy::PPB_FileIO_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher), + callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { +} + +PPB_FileIO_Proxy::~PPB_FileIO_Proxy() { +} + +// static +PP_Resource PPB_FileIO_Proxy::CreateProxyResource(PP_Instance instance) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return 0; + + HostResource result; + dispatcher->Send(new PpapiHostMsg_PPBFileIO_Create(kApiID, instance, + &result)); + if (result.is_null()) + return 0; + return (new FileIO(result))->GetReference(); +} + +bool PPB_FileIO_Proxy::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPB_FileIO_Proxy, msg) + // Plugin -> host message. + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Create, OnHostMsgCreate) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Open, OnHostMsgOpen) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Close, OnHostMsgClose) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Query, OnHostMsgQuery) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Touch, OnHostMsgTouch) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Read, OnHostMsgRead) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Write, OnHostMsgWrite) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_SetLength, OnHostMsgSetLength) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Flush, OnHostMsgFlush) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillWrite, OnHostMsgWillWrite) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillSetLength, + OnHostMsgWillSetLength) + + // Host -> plugin messages. + IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_GeneralComplete, + OnPluginMsgGeneralComplete) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_OpenFileComplete, + OnPluginMsgOpenFileComplete) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_QueryComplete, + OnPluginMsgQueryComplete) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_ReadComplete, + OnPluginMsgReadComplete) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPB_FileIO_Proxy::OnHostMsgCreate(PP_Instance instance, + HostResource* result) { + thunk::EnterResourceCreation enter(instance); + if (enter.succeeded()) { + result->SetHostResource(instance, + enter.functions()->CreateFileIO(instance)); + } +} + +void PPB_FileIO_Proxy::OnHostMsgOpen(const HostResource& host_resource, + const HostResource& file_ref_resource, + int32_t open_flags) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost, host_resource); + if (enter.succeeded()) { + enter.SetResult(enter.object()->Open( + file_ref_resource.host_resource(), open_flags, enter.callback())); + } +} + +void PPB_FileIO_Proxy::OnHostMsgClose(const HostResource& host_resource) { + EnterHostFromHostResource<PPB_FileIO_API> enter(host_resource); + if (enter.succeeded()) + enter.object()->Close(); +} + +void PPB_FileIO_Proxy::OnHostMsgQuery(const HostResource& host_resource) { + // The callback will take charge of deleting the FileInfo. The contents must + // be defined so we don't send garbage to the plugin in the failure case. + PP_FileInfo* info = new PP_FileInfo; + memset(info, 0, sizeof(PP_FileInfo)); + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::QueryCallbackCompleteInHost, + host_resource, info); + if (enter.succeeded()) + enter.SetResult(enter.object()->Query(info, enter.callback())); +} + +void PPB_FileIO_Proxy::OnHostMsgTouch(const HostResource& host_resource, + PP_Time last_access_time, + PP_Time last_modified_time) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) { + enter.SetResult(enter.object()->Touch(last_access_time, last_modified_time, + enter.callback())); + } +} + +void PPB_FileIO_Proxy::OnHostMsgRead(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_read) { + // Validate bytes_to_read before allocating below. This value is coming from + // the untrusted plugin. + bytes_to_read = std::min(bytes_to_read, kMaxReadSize); + if (bytes_to_read < 0) { + ReadCallbackCompleteInHost(PP_ERROR_FAILED, host_resource, + new std::string()); + return; + } + + // The callback will take charge of deleting the string. + std::string* dest = new std::string; + dest->resize(bytes_to_read); + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::ReadCallbackCompleteInHost, + host_resource, dest); + if (enter.succeeded()) { + enter.SetResult(enter.object()->Read(offset, + bytes_to_read > 0 ? &(*dest)[0] : NULL, + bytes_to_read, enter.callback())); + } +} + +void PPB_FileIO_Proxy::OnHostMsgWrite(const HostResource& host_resource, + int64_t offset, + const std::string& data) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) { + enter.SetResult(enter.object()->Write(offset, data.data(), data.size(), + enter.callback())); + } +} + +void PPB_FileIO_Proxy::OnHostMsgSetLength(const HostResource& host_resource, + int64_t length) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) + enter.SetResult(enter.object()->SetLength(length, enter.callback())); +} + +void PPB_FileIO_Proxy::OnHostMsgFlush(const HostResource& host_resource) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) + enter.SetResult(enter.object()->Flush(enter.callback())); +} + +void PPB_FileIO_Proxy::OnHostMsgWillWrite(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_write) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) { + enter.SetResult(enter.object()->WillWrite(offset, bytes_to_write, + enter.callback())); + } +} + +void PPB_FileIO_Proxy::OnHostMsgWillSetLength(const HostResource& host_resource, + int64_t length) { + EnterHostFileIO enter(host_resource, callback_factory_, + &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, + host_resource); + if (enter.succeeded()) + enter.SetResult(enter.object()->WillSetLength(length, enter.callback())); +} + +void PPB_FileIO_Proxy::OnPluginMsgGeneralComplete( + const HostResource& host_resource, + int32_t result) { + EnterPluginFileIO enter(host_resource); + if (enter.succeeded()) + static_cast<FileIO*>(enter.object())->ExecuteGeneralCallback(result); +} + +void PPB_FileIO_Proxy::OnPluginMsgOpenFileComplete( + const HostResource& host_resource, + int32_t result) { + EnterPluginFileIO enter(host_resource); + if (enter.succeeded()) + static_cast<FileIO*>(enter.object())->ExecuteOpenFileCallback(result); +} + +void PPB_FileIO_Proxy::OnPluginMsgQueryComplete( + const HostResource& host_resource, + int32_t result, + const PP_FileInfo& info) { + EnterPluginFileIO enter(host_resource); + if (enter.succeeded()) + static_cast<FileIO*>(enter.object())->ExecuteQueryCallback(result, info); +} + +void PPB_FileIO_Proxy::OnPluginMsgReadComplete( + const HostResource& host_resource, + int32_t result, + const std::string& data) { + EnterPluginFileIO enter(host_resource); + if (enter.succeeded()) { + // The result code should contain the data size if it's positive. + DCHECK((result < 0 && data.size() == 0) || + result == static_cast<int32_t>(data.size())); + static_cast<FileIO*>(enter.object())->ExecuteReadCallback(result, + data.data()); + } +} + +void PPB_FileIO_Proxy::GeneralCallbackCompleteInHost( + int32_t pp_error, + const HostResource& host_resource) { + Send(new PpapiMsg_PPBFileIO_GeneralComplete(kApiID, host_resource, pp_error)); +} + +void PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost( + int32_t pp_error, + const HostResource& host_resource) { + Send(new PpapiMsg_PPBFileIO_OpenFileComplete(kApiID, host_resource, + pp_error)); +} + +void PPB_FileIO_Proxy::QueryCallbackCompleteInHost( + int32_t pp_error, + const HostResource& host_resource, + PP_FileInfo* info) { + Send(new PpapiMsg_PPBFileIO_QueryComplete(kApiID, host_resource, pp_error, + *info)); + delete info; +} + +void PPB_FileIO_Proxy::ReadCallbackCompleteInHost( + int32_t pp_error, + const HostResource& host_resource, + std::string* data) { + // Only send the amount of data in the string that was actually read. + if (pp_error >= 0) { + DCHECK(pp_error <= static_cast<int32_t>(data->size())); + data->resize(pp_error); + } + Send(new PpapiMsg_PPBFileIO_ReadComplete(kApiID, host_resource, pp_error, + *data)); + delete data; +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/ppb_file_io_proxy.h b/ppapi/proxy/ppb_file_io_proxy.h new file mode 100644 index 0000000..fbc8a16 --- /dev/null +++ b/ppapi/proxy/ppb_file_io_proxy.h @@ -0,0 +1,93 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ +#define PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ + +#include <string> + +#include "base/basictypes.h" +#include "ppapi/c/pp_file_info.h" +#include "ppapi/proxy/interface_proxy.h" +#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" + +namespace ppapi { + +class HostResource; +namespace proxy { + +class PPB_FileIO_Proxy : public InterfaceProxy { + public: + explicit PPB_FileIO_Proxy(Dispatcher* dispatcher); + virtual ~PPB_FileIO_Proxy(); + + static PP_Resource CreateProxyResource(PP_Instance instance); + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + static const ApiID kApiID = API_ID_PPB_FILE_IO; + + private: + // Plugin -> Host message handlers. + void OnHostMsgCreate(PP_Instance instance, HostResource* result); + void OnHostMsgOpen(const HostResource& host_resource, + const HostResource& file_ref_resource, + int32_t open_flags); + void OnHostMsgClose(const HostResource& host_resource); + void OnHostMsgQuery(const HostResource& host_resource); + void OnHostMsgTouch(const HostResource& host_resource, + PP_Time last_access_time, + PP_Time last_modified_time); + void OnHostMsgRead(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_read); + void OnHostMsgWrite(const HostResource& host_resource, + int64_t offset, + const std::string& data); + void OnHostMsgSetLength(const HostResource& host_resource, + int64_t length); + void OnHostMsgFlush(const HostResource& host_resource); + void OnHostMsgWillWrite(const HostResource& host_resource, + int64_t offset, + int32_t bytes_to_write); + void OnHostMsgWillSetLength(const HostResource& host_resource, + int64_t length); + + // Host -> Plugin message handlers. + void OnPluginMsgGeneralComplete(const HostResource& host_resource, + int32_t result); + void OnPluginMsgOpenFileComplete(const HostResource& host_resource, + int32_t result); + void OnPluginMsgQueryComplete(const HostResource& host_resource, + int32_t result, + const PP_FileInfo& info); + void OnPluginMsgReadComplete(const HostResource& host_resource, + int32_t result, + const std::string& data); + void OnPluginMsgWriteComplete(const HostResource& host_resource, + int32_t result); + + // Host-side callback handlers. These convert the callbacks to an IPC message + // to the plugin. + void GeneralCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource); + void OpenFileCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource); + void QueryCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource, + PP_FileInfo* info); + void ReadCallbackCompleteInHost(int32_t pp_error, + const HostResource& host_resource, + std::string* data); + pp::CompletionCallbackFactory<PPB_FileIO_Proxy, + ProxyNonThreadSafeRefCount> callback_factory_; + + DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PPB_FILE_IO_PROXY_H_ diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc index 20b522c..e481f86 100644 --- a/ppapi/proxy/ppb_file_ref_proxy.cc +++ b/ppapi/proxy/ppb_file_ref_proxy.cc @@ -33,6 +33,9 @@ class FileRef : public PPB_FileRef_Shared { explicit FileRef(const PPB_FileRef_CreateInfo& info); virtual ~FileRef(); + // Resource overrides. + virtual void LastPluginRefWasDeleted() OVERRIDE; + // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). virtual PP_Resource GetParent() OVERRIDE; virtual int32_t MakeDirectory(PP_Bool make_ancestors, @@ -77,6 +80,11 @@ FileRef::FileRef(const PPB_FileRef_CreateInfo& info) } FileRef::~FileRef() { + // The callbacks map should have been cleared by LastPluginRefWasDeleted. + DCHECK(pending_callbacks_.empty()); +} + +void FileRef::LastPluginRefWasDeleted() { // Abort all pending callbacks. Do this by posting a task to avoid reentering // the plugin's Release() call that probably deleted this object. for (PendingCallbackMap::iterator i = pending_callbacks_.begin(); @@ -85,6 +93,7 @@ FileRef::~FileRef() { i->second.func, i->second.user_data, static_cast<int32_t>(PP_ERROR_ABORTED))); } + pending_callbacks_.clear(); } PP_Resource FileRef::GetParent() { diff --git a/ppapi/proxy/ppb_file_ref_proxy.h b/ppapi/proxy/ppb_file_ref_proxy.h index 5f0f947..c0fa23c 100644 --- a/ppapi/proxy/ppb_file_ref_proxy.h +++ b/ppapi/proxy/ppb_file_ref_proxy.h @@ -31,6 +31,8 @@ class PPB_FileRef_Proxy : public InterfaceProxy { static PP_Resource CreateProxyResource(PP_Resource file_system, const char* path); + static PP_Resource CreateProxyResource( + const PPB_FileRef_CreateInfo& serialized); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -60,7 +62,7 @@ class PPB_FileRef_Proxy : public InterfaceProxy { static const ApiID kApiID = API_ID_PPB_FILE_REF; private: - // Message handlers. + // Plugin -> host message handlers. void OnMsgCreate(const HostResource& file_system, const std::string& path, PPB_FileRef_CreateInfo* result); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 52cce18..e758035 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -15,6 +15,7 @@ #include "ppapi/proxy/ppb_buffer_proxy.h" #include "ppapi/proxy/ppb_broker_proxy.h" #include "ppapi/proxy/ppb_file_chooser_proxy.h" +#include "ppapi/proxy/ppb_file_io_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_file_system_proxy.h" #include "ppapi/proxy/ppb_flash_menu_proxy.h" @@ -122,8 +123,7 @@ PP_Resource ResourceCreationProxy::CreateFileChooser( } PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) { - NOTIMPLEMENTED(); // Not proxied yet. - return 0; + return PPB_FileIO_Proxy::CreateProxyResource(instance); } PP_Resource ResourceCreationProxy::CreateFileRef(PP_Resource file_system, diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h index c8c9362..73654b0 100644 --- a/ppapi/shared_impl/api_id.h +++ b/ppapi/shared_impl/api_id.h @@ -21,6 +21,7 @@ enum ApiID { API_ID_PPB_CORE, API_ID_PPB_CURSORCONTROL, API_ID_PPB_FILE_CHOOSER, + API_ID_PPB_FILE_IO, API_ID_PPB_FILE_REF, API_ID_PPB_FILE_SYSTEM, API_ID_PPB_FLASH, diff --git a/ppapi/shared_impl/file_type_conversion.cc b/ppapi/shared_impl/file_type_conversion.cc new file mode 100644 index 0000000..a9bd435 --- /dev/null +++ b/ppapi/shared_impl/file_type_conversion.cc @@ -0,0 +1,74 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/file_type_conversion.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_file_io.h" + +namespace ppapi { + +int PlatformFileErrorToPepperError(base::PlatformFileError error_code) { + switch (error_code) { + case base::PLATFORM_FILE_OK: + return PP_OK; + case base::PLATFORM_FILE_ERROR_EXISTS: + return PP_ERROR_FILEEXISTS; + case base::PLATFORM_FILE_ERROR_NOT_FOUND: + return PP_ERROR_FILENOTFOUND; + case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: + case base::PLATFORM_FILE_ERROR_SECURITY: + return PP_ERROR_NOACCESS; + case base::PLATFORM_FILE_ERROR_NO_MEMORY: + return PP_ERROR_NOMEMORY; + case base::PLATFORM_FILE_ERROR_NO_SPACE: + return PP_ERROR_NOSPACE; + case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: + return PP_ERROR_FAILED; + default: + return PP_ERROR_FAILED; + } +} + +bool PepperFileOpenFlagsToPlatformFileFlags(int32_t pp_open_flags, + int* flags_out) { + if (!flags_out) + return false; + + bool pp_read = !!(pp_open_flags & PP_FILEOPENFLAG_READ); + bool pp_write = !!(pp_open_flags & PP_FILEOPENFLAG_WRITE); + bool pp_create = !!(pp_open_flags & PP_FILEOPENFLAG_CREATE); + bool pp_truncate = !!(pp_open_flags & PP_FILEOPENFLAG_TRUNCATE); + bool pp_exclusive = !!(pp_open_flags & PP_FILEOPENFLAG_EXCLUSIVE); + + int flags = 0; + if (pp_read) + flags |= base::PLATFORM_FILE_READ; + if (pp_write) { + flags |= base::PLATFORM_FILE_WRITE; + flags |= base::PLATFORM_FILE_WRITE_ATTRIBUTES; + } + + if (pp_truncate && !pp_write) + return false; + + if (pp_create) { + if (pp_exclusive) { + flags |= base::PLATFORM_FILE_CREATE; + } else if (pp_truncate) { + flags |= base::PLATFORM_FILE_CREATE_ALWAYS; + } else { + flags |= base::PLATFORM_FILE_OPEN_ALWAYS; + } + } else if (pp_truncate) { + flags |= base::PLATFORM_FILE_OPEN_TRUNCATED; + } else { + flags |= base::PLATFORM_FILE_OPEN; + } + + *flags_out = flags; + return true; +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/file_type_conversion.h b/ppapi/shared_impl/file_type_conversion.h new file mode 100644 index 0000000..3ecd404 --- /dev/null +++ b/ppapi/shared_impl/file_type_conversion.h @@ -0,0 +1,23 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_SHARED_IMPL_FILE_TYPE_CONVERSION_H_ +#define PPAPI_SHARED_IMPL_FILE_TYPE_CONVERSION_H_ + +#include "base/platform_file.h" +#include "ppapi/c/pp_stdint.h" + +namespace ppapi { + +int PlatformFileErrorToPepperError(base::PlatformFileError error_code); + +// Converts a PP_FileOpenFlags_Dev flag combination into a corresponding +// PlatformFileFlags flag combination. +// Returns |true| if okay. +bool PepperFileOpenFlagsToPlatformFileFlags(int32_t pp_open_flags, + int* flags_out); + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_FILE_TYPE_CONVERSION_H_ diff --git a/ppapi/shared_impl/ppb_file_io_shared.cc b/ppapi/shared_impl/ppb_file_io_shared.cc new file mode 100644 index 0000000..a51c33f --- /dev/null +++ b/ppapi/shared_impl/ppb_file_io_shared.cc @@ -0,0 +1,237 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/ppb_file_io_shared.h" + +#include <string.h> + +#include "base/bind.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/file_type_conversion.h" +#include "ppapi/shared_impl/time_conversion.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_file_ref_api.h" + +namespace ppapi { + +using thunk::EnterResourceNoLock; +using thunk::PPB_FileIO_API; +using thunk::PPB_FileRef_API; + +PPB_FileIO_Shared::CallbackEntry::CallbackEntry() + : read_buffer(NULL), + info(NULL) { +} + +PPB_FileIO_Shared::CallbackEntry::CallbackEntry(const CallbackEntry& entry) + : callback(entry.callback), + read_buffer(entry.read_buffer), + info(entry.info) { +} + +PPB_FileIO_Shared::CallbackEntry::~CallbackEntry() { +} + +PPB_FileIO_Shared::PPB_FileIO_Shared(PP_Instance instance) + : Resource(instance), + file_system_type_(PP_FILESYSTEMTYPE_INVALID), + file_open_(false), + pending_op_(OPERATION_NONE) { +} + +PPB_FileIO_Shared::PPB_FileIO_Shared(const HostResource& host_resource) + : Resource(host_resource), + file_system_type_(PP_FILESYSTEMTYPE_INVALID), + file_open_(false), + pending_op_(OPERATION_NONE) { +} + +PPB_FileIO_Shared::~PPB_FileIO_Shared() { + // The callbacks list should have been cleared by LastPluginRefWasDeleted. + DCHECK(callbacks_.empty()); +} + +void PPB_FileIO_Shared::LastPluginRefWasDeleted() { + // Abort all pending callbacks. Do this by posting a task to avoid reentering + // the plugin's Release() call that probably deleted this object. + for (size_t i = 0; i < callbacks_.size(); i++) { + MessageLoop::current()->PostTask(FROM_HERE, base::Bind( + callbacks_[i].callback.func, callbacks_[i].callback.user_data, + static_cast<int32_t>(PP_ERROR_ABORTED))); + } + callbacks_.erase(callbacks_.begin(), callbacks_.end()); +} + +thunk::PPB_FileIO_API* PPB_FileIO_Shared::AsPPB_FileIO_API() { + return this; +} + +int32_t PPB_FileIO_Shared::Open(PP_Resource file_ref, + int32_t open_flags, + PP_CompletionCallback callback) { + EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + + int32_t rv = CommonCallValidation(false, OPERATION_EXCLUSIVE, callback); + if (rv != PP_OK) + return rv; + + PP_FileSystemType type = enter.object()->GetFileSystemType(); + if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && + type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && + type != PP_FILESYSTEMTYPE_EXTERNAL) + return PP_ERROR_FAILED; + file_system_type_ = type; + + return OpenValidated(file_ref, enter.object(), open_flags, callback); +} + +int32_t PPB_FileIO_Shared::Query(PP_FileInfo* info, + PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); + if (rv != PP_OK) + return rv; + if (!info) + return PP_ERROR_BADARGUMENT; + return QueryValidated(info, callback); +} + +int32_t PPB_FileIO_Shared::Touch(PP_Time last_access_time, + PP_Time last_modified_time, + PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); + if (rv != PP_OK) + return rv; + return TouchValidated(last_access_time, last_modified_time, callback); +} + +int32_t PPB_FileIO_Shared::Read(int64_t offset, + char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_READ, callback); + if (rv != PP_OK) + return rv; + return ReadValidated(offset, buffer, bytes_to_read, callback); +} + +int32_t PPB_FileIO_Shared::Write(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_WRITE, callback); + if (rv != PP_OK) + return rv; + return WriteValidated(offset, buffer, bytes_to_write, callback); +} + +int32_t PPB_FileIO_Shared::SetLength(int64_t length, + PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); + if (rv != PP_OK) + return rv; + return SetLengthValidated(length, callback); +} + +int32_t PPB_FileIO_Shared::Flush(PP_CompletionCallback callback) { + int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); + if (rv != PP_OK) + return rv; + return FlushValidated(callback); +} + +void PPB_FileIO_Shared::ExecuteGeneralCallback(int32_t pp_error) { + RunAndRemoveFirstPendingCallback(pp_error); +} + +void PPB_FileIO_Shared::ExecuteOpenFileCallback(int32_t pp_error) { + if (pp_error == PP_OK) + file_open_ = true; + ExecuteGeneralCallback(pp_error); +} + +void PPB_FileIO_Shared::ExecuteQueryCallback(int32_t pp_error, + const PP_FileInfo& info) { + if (pending_op_ != OPERATION_EXCLUSIVE || callbacks_.empty() || + !callbacks_.front().info) { + NOTREACHED(); + return; + } + *callbacks_.front().info = info; + RunAndRemoveFirstPendingCallback(pp_error); +} + +void PPB_FileIO_Shared::ExecuteReadCallback(int32_t pp_error, + const char* data) { + if (pending_op_ != OPERATION_READ || callbacks_.empty()) { + NOTREACHED(); + return; + } + + char* read_buffer = callbacks_.front().read_buffer; + DCHECK(data); + DCHECK(read_buffer); + + // The result code contains the number of bytes if it's positive. + if (pp_error > 0) + memcpy(read_buffer, data, pp_error); + RunAndRemoveFirstPendingCallback(pp_error); +} + +int32_t PPB_FileIO_Shared::CommonCallValidation( + bool should_be_open, + OperationType new_op, + PP_CompletionCallback callback) { + // Only asynchronous operation is supported. + if (!callback.func) + return PP_ERROR_BLOCKS_MAIN_THREAD; + + if (should_be_open) { + if (!file_open_) + return PP_ERROR_FAILED; + } else { + if (file_open_) + return PP_ERROR_FAILED; + } + + if (pending_op_ != OPERATION_NONE && + (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE)) { + return PP_ERROR_INPROGRESS; + } + + return PP_OK; +} + +void PPB_FileIO_Shared::RegisterCallback(OperationType op, + PP_CompletionCallback callback, + char* read_buffer, + PP_FileInfo* info) { + DCHECK(callback.func); + DCHECK(pending_op_ == OPERATION_NONE || + (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == op)); + + CallbackEntry entry; + entry.callback = callback; + entry.read_buffer = read_buffer; + entry.info = info; + callbacks_.push_back(entry); + + pending_op_ = op; +} + +void PPB_FileIO_Shared::RunAndRemoveFirstPendingCallback(int32_t result) { + DCHECK(!callbacks_.empty()); + + CallbackEntry front = callbacks_.front(); + callbacks_.pop_front(); + if (callbacks_.empty()) + pending_op_ = OPERATION_NONE; + + PP_RunCompletionCallback(&front.callback, result); +} + +} // namespace ppapi diff --git a/ppapi/shared_impl/ppb_file_io_shared.h b/ppapi/shared_impl/ppb_file_io_shared.h new file mode 100644 index 0000000..341db46 --- /dev/null +++ b/ppapi/shared_impl/ppb_file_io_shared.h @@ -0,0 +1,157 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ + +#include <deque> + +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_file_io_api.h" + +namespace ppapi { + +namespace thunk { +class PPB_FileRef_API; +} + +class PPAPI_SHARED_EXPORT PPB_FileIO_Shared : public Resource, + public thunk::PPB_FileIO_API { + public: + PPB_FileIO_Shared(PP_Instance instance); + PPB_FileIO_Shared(const HostResource& host_resource); + ~PPB_FileIO_Shared(); + + // Resource overrides. + virtual void LastPluginRefWasDeleted() OVERRIDE; + virtual thunk::PPB_FileIO_API* AsPPB_FileIO_API() OVERRIDE; + + // PPB_FileIO_API implementation. + virtual int32_t Open(PP_Resource file_ref, + int32_t open_flags, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Query(PP_FileInfo* info, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Touch(PP_Time last_access_time, + PP_Time last_modified_time, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Read(int64_t offset, + char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Write(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t SetLength(int64_t length, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; + + // Callback handler for different types of operations. + void ExecuteGeneralCallback(int32_t pp_error); + void ExecuteOpenFileCallback(int32_t pp_error); + void ExecuteQueryCallback(int32_t pp_error, const PP_FileInfo& info); + void ExecuteReadCallback(int32_t pp_error, const char* data); + + protected: + struct CallbackEntry { + CallbackEntry(); + CallbackEntry(const CallbackEntry& entry); + ~CallbackEntry(); + + PP_CompletionCallback callback; + + // Pointer back to the caller's read buffer; only used by |Read()|, NULL + // for non-read operations. Not owned. + char* read_buffer; + + // Pointer back to the caller's PP_FileInfo structure for Query operations. + // NULL for non-query operations. Not owned. + PP_FileInfo* info; + }; + + enum OperationType { + // There is no pending operation right now. + OPERATION_NONE, + + // If there are pending reads, any other kind of async operation is not + // allowed. + OPERATION_READ, + + // If there are pending writes, any other kind of async operation is not + // allowed. + OPERATION_WRITE, + + // If there is a pending operation that is neither read nor write, no + // further async operation is allowed. + OPERATION_EXCLUSIVE + }; + + // Validated versions of the FileIO API. Subclasses in the proxy and impl + // implement these so the common error checking stays here. + virtual int32_t OpenValidated(PP_Resource file_ref_resource, + thunk::PPB_FileRef_API* file_ref_api, + int32_t open_flags, + PP_CompletionCallback callback) = 0; + virtual int32_t QueryValidated(PP_FileInfo* info, + PP_CompletionCallback callback) = 0; + virtual int32_t TouchValidated(PP_Time last_access_time, + PP_Time last_modified_time, + PP_CompletionCallback callback) = 0; + virtual int32_t ReadValidated(int64_t offset, + char* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) = 0; + virtual int32_t WriteValidated(int64_t offset, + const char* buffer, + int32_t bytes_to_write, + PP_CompletionCallback callback) = 0; + virtual int32_t SetLengthValidated(int64_t length, + PP_CompletionCallback callback) = 0; + virtual int32_t FlushValidated(PP_CompletionCallback callback) = 0; + + // Called for every "Validated" function. + // + // This verifies that the callback is valid and that no callback is already + // pending, or it is a read(write) request and currently the pending + // operations are reads(writes). + // + // Returns |PP_OK| to indicate that everything is valid or |PP_ERROR_...| if + // the call should be aborted and that code returned to the plugin. + int32_t CommonCallValidation(bool should_be_open, + OperationType new_op, + PP_CompletionCallback callback); + + // 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, |info| is used only by + // query operations. + void RegisterCallback(OperationType op, + PP_CompletionCallback callback, + char* read_buffer, + PP_FileInfo* info); + + // Pops the oldest callback from the queue and runs it. + void RunAndRemoveFirstPendingCallback(int32_t result); + + // The file system type specified in the Open() call. This will be + // PP_FILESYSTEMTYPE_INVALID before open was called. This value does not + // indicate that the open command actually succeeded. + PP_FileSystemType file_system_type_; + + // Set to true when the file has been successfully opened. + bool file_open_; + + std::deque<CallbackEntry> callbacks_; + OperationType pending_op_; + + DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Shared); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_FILE_IO_SHARED_H_ diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index b04c7e9..057fdef 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -903,6 +903,31 @@ std::string TestFileIO::TestNotAllowMixedReadWrite() { if (rv_2 != PP_ERROR_INPROGRESS) return ReportError("FileIO::Read", rv_2); + // Cannot query while the write is pending. + TestCompletionCallback callback_3(instance_->pp_instance(), force_async_); + PP_FileInfo info; + int32_t rv_3 = file_io.Query(&info, callback_3); + if (rv_3 == PP_OK_COMPLETIONPENDING) + rv_3 = callback_3.WaitForResult(); + if (rv_3 != PP_ERROR_INPROGRESS) + return ReportError("FileIO::Query", rv_3); + + // Cannot touch while the write is pending. + TestCompletionCallback callback_4(instance_->pp_instance(), force_async_); + int32_t rv_4 = file_io.Touch(1234.0, 5678.0, callback_4); + if (rv_4 == PP_OK_COMPLETIONPENDING) + rv_4 = callback_4.WaitForResult(); + if (rv_4 != PP_ERROR_INPROGRESS) + return ReportError("FileIO::Touch", rv_4); + + // Cannot set length while the write is pending. + TestCompletionCallback callback_5(instance_->pp_instance(), force_async_); + int32_t rv_5 = file_io.SetLength(123, callback_5); + if (rv_5 == PP_OK_COMPLETIONPENDING) + rv_5 = callback_5.WaitForResult(); + if (rv_5 != PP_ERROR_INPROGRESS) + return ReportError("FileIO::SetLength", rv_5); + callback_1.WaitForResult(); PASS(); @@ -940,10 +965,14 @@ std::string TestFileIO::TestWillWriteWillSetLength() { if (!trusted) return ReportError("FileIOTrusted", PP_ERROR_FAILED); - // Get file descriptor. - int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource()); - if (fd < 0) - return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; + // Get file descriptor. This is only supported in-process for now, so don't + // test out of process. + const PPB_Testing_Dev* testing_interface = GetTestingInterface(); + if (testing_interface && !testing_interface->IsOutOfProcess()) { + int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource()); + if (fd < 0) + return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; + } // Calling WillWrite. rv = trusted->WillWrite( diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc index ce6f6d9..fc72948 100644 --- a/ppapi/tests/test_url_loader.cc +++ b/ppapi/tests/test_url_loader.cc @@ -71,22 +71,14 @@ bool TestURLLoader::Init() { const PPB_FileIO* file_io_interface = static_cast<const PPB_FileIO*>( pp::Module::Get()->GetBrowserInterface(PPB_FILEIO_INTERFACE)); - if (testing_interface_->IsOutOfProcess() && file_io_interface) { - instance_->AppendError( - "FileIO interface is now supported by ppapi proxy: update this test!"); - } else if (!testing_interface_->IsOutOfProcess() && !file_io_interface) { + if (!file_io_interface) instance_->AppendError("FileIO interface not available"); - } file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted*>( pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); url_loader_trusted_interface_ = static_cast<const PPB_URLLoaderTrusted*>( pp::Module::Get()->GetBrowserInterface(PPB_URLLOADERTRUSTED_INTERFACE)); - if (testing_interface_->IsOutOfProcess() && file_io_trusted_interface_) { - instance_->AppendError( - "FileIOTrusted interface is now supported by ppapi proxy: " - "update this test!"); - } else if (!testing_interface_->IsOutOfProcess()) { + if (!testing_interface_->IsOutOfProcess()) { // Trusted interfaces are not supported under NaCl. #if !(defined __native_client__) if (!file_io_trusted_interface_) @@ -470,36 +462,34 @@ std::string TestURLLoader::TestStreamToFile() { return ReportError("URLLoader::FinishStreamingToFile", rv); // FileIO is not yet supported by ppapi/proxy. - if (!testing_interface_->IsOutOfProcess()) { - pp::FileIO reader(instance_); - rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback); - if (force_async_ && rv != PP_OK_COMPLETIONPENDING) - return ReportError("FileIO::Open force_async", rv); - if (rv == PP_OK_COMPLETIONPENDING) - rv = callback.WaitForResult(); - if (rv != PP_OK) - return ReportError("FileIO::Open", rv); + pp::FileIO reader(instance_); + rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback); + if (force_async_ && rv != PP_OK_COMPLETIONPENDING) + return ReportError("FileIO::Open force_async", rv); + if (rv == PP_OK_COMPLETIONPENDING) + rv = callback.WaitForResult(); + if (rv != PP_OK) + return ReportError("FileIO::Open", rv); - std::string data; - std::string error = ReadEntireFile(&reader, &data); - if (!error.empty()) - return error; + std::string data; + std::string error = ReadEntireFile(&reader, &data); + if (!error.empty()) + return error; - std::string expected_body = "hello\n"; - if (data.size() != expected_body.size()) - return "ReadEntireFile returned unexpected content length"; - if (data != expected_body) - return "ReadEntireFile returned unexpected content"; + std::string expected_body = "hello\n"; + if (data.size() != expected_body.size()) + return "ReadEntireFile returned unexpected content length"; + if (data != expected_body) + return "ReadEntireFile returned unexpected content"; - // FileIOTrusted is not supported by NaCl or ppapi/proxy. - if (!testing_interface_->IsOutOfProcess()) { + // FileIOTrusted is not supported by NaCl or ppapi/proxy. + if (!testing_interface_->IsOutOfProcess()) { #if !(defined __native_client__) - int32_t file_descriptor = file_io_trusted_interface_->GetOSFileDescriptor( - reader.pp_resource()); - if (file_descriptor < 0) - return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; + int32_t file_descriptor = file_io_trusted_interface_->GetOSFileDescriptor( + reader.pp_resource()); + if (file_descriptor < 0) + return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; #endif - } } PASS(); } diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index d7c8b69..c6770f8 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -13,6 +13,8 @@ PROXIED_API(PPB_UDPSocket_Private) PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_2, PPB_BrokerTrusted) PROXIED_IFACE(PPB_FileRef, PPB_FILEREFPRIVATE_INTERFACE_0_1, PPB_FileRefPrivate) +// This uses the FileIO API which is declared in the public stable file. +PROXIED_IFACE(PPB_FileIO, PPB_FILEIOTRUSTED_INTERFACE_0_4, PPB_FileIOTrusted) PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE, PPB_FlashFullscreen) PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE, PPB_NetAddress_Private) diff --git a/ppapi/thunk/interfaces_ppb_public_stable.h b/ppapi/thunk/interfaces_ppb_public_stable.h index b81f744..f4d5ec3 100644 --- a/ppapi/thunk/interfaces_ppb_public_stable.h +++ b/ppapi/thunk/interfaces_ppb_public_stable.h @@ -22,7 +22,7 @@ PROXIED_API(PPB_Audio) // serialize it to a struct when we need it on the host side. UNPROXIED_API(PPB_AudioConfig) PROXIED_API(PPB_Core) -UNPROXIED_API(PPB_FileIO) +PROXIED_API(PPB_FileIO) PROXIED_API(PPB_FileRef) PROXIED_API(PPB_FileSystem) PROXIED_API(PPB_Graphics2D) @@ -50,7 +50,7 @@ PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_0, PPB_Audio) // This has no corresponding _Proxy object since it does no IPC. PROXIED_IFACE(NoAPIName, PPB_AUDIO_CONFIG_INTERFACE_1_0, PPB_AudioConfig) // Note: Core is special and is registered manually. -UNPROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO) +PROXIED_IFACE(PPB_FileIO, PPB_FILEIO_INTERFACE_1_0, PPB_FileIO) PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef) PROXIED_IFACE(PPB_FileSystem, PPB_FILESYSTEM_INTERFACE_1_0, PPB_FileSystem) PROXIED_IFACE(PPB_Graphics2D, PPB_GRAPHICS_2D_INTERFACE_1_0, PPB_Graphics2D) diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index d59c907..00773f3 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -32,7 +32,6 @@ struct PPB_AudioTrusted; struct PPB_BrokerTrusted; struct PPB_BufferTrusted; struct PPB_FileChooserTrusted; -struct PPB_FileIOTrusted; struct PPB_Flash_Clipboard; struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; @@ -59,7 +58,6 @@ PPAPI_THUNK_EXPORT const PPB_BrokerTrusted* GetPPB_Broker_Thunk(); PPAPI_THUNK_EXPORT const PPB_BufferTrusted* GetPPB_BufferTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_FileChooserTrusted* GetPPB_FileChooser_Trusted_Thunk(); -PPAPI_THUNK_EXPORT const PPB_FileIOTrusted* GetPPB_FileIOTrusted_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_Clipboard* GetPPB_Flash_Clipboard_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); PPAPI_THUNK_EXPORT const PPB_Flash_NetConnector* |