diff options
-rw-r--r-- | chrome/browser/chrome_plugin_host.cc | 13 | ||||
-rw-r--r-- | chrome/common/chrome_plugin_api.h | 9 | ||||
-rw-r--r-- | chrome/plugin/chrome_plugin_host.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/chrome_plugin_host.cc | 13 |
4 files changed, 47 insertions, 1 deletions
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index 37d8b80..702e300 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -679,6 +679,18 @@ CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, return CPERR_FAILURE; } +CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, + void (*func)(void *), + void *user_data) { + MessageLoop *message_loop = ChromeThread::GetMessageLoop(ChromeThread::IO); + if (!message_loop) { + return CPERR_FAILURE; + } + message_loop->PostTask(FROM_HERE, NewRunnableFunction(func, user_data)); + + return CPERR_SUCCESS; +} + } CPBrowserFuncs* GetCPBrowserFuncsForBrowser() { @@ -711,6 +723,7 @@ CPBrowserFuncs* GetCPBrowserFuncsForBrowser() { browser_funcs.request_funcs = &request_funcs; browser_funcs.response_funcs = &response_funcs; browser_funcs.send_sync_message = CPB_SendSyncMessage; + browser_funcs.plugin_thread_async_call = CPB_PluginThreadAsyncCall; request_funcs.size = sizeof(request_funcs); request_funcs.start_request = CPR_StartRequest; diff --git a/chrome/common/chrome_plugin_api.h b/chrome/common/chrome_plugin_api.h index 278787c..14a54e5 100644 --- a/chrome/common/chrome_plugin_api.h +++ b/chrome/common/chrome_plugin_api.h @@ -30,7 +30,7 @@ extern "C" { // The current version of the API, used by the 'version' field of CPPluginFuncs // and CPBrowserFuncs. #define CP_MAJOR_VERSION 0 -#define CP_MINOR_VERSION 7 +#define CP_MINOR_VERSION 8 #define CP_VERSION ((CP_MAJOR_VERSION << 8) | (CP_MINOR_VERSION)) #define CP_GET_MAJOR_VERSION(version) ((version & 0xff00) >> 8) @@ -384,6 +384,12 @@ typedef CPError (STDCALL *CPB_SendSyncMessageFunc)(CPID id, void **retval, uint32 *retval_len); +// This function asynchronously calls the provided function on the plugin +// thread. user_data is passed as the argument to the function. +typedef CPError (STDCALL *CPB_PluginThreadAsyncCallFunc)(CPID id, + void (*func)(void *), + void *user_data); + // Informs the plugin of raw data having been sent from another process. typedef void (STDCALL *CPP_OnMessageFunc)(void *data, uint32 data_len); @@ -462,6 +468,7 @@ typedef struct _CPBrowserFuncs { CPB_AddUICommandFunc add_ui_command; CPB_HandleCommandFunc handle_command; CPB_SendSyncMessageFunc send_sync_message; + CPB_PluginThreadAsyncCallFunc plugin_thread_async_call; } CPBrowserFuncs; diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index ecc9418..bcc397a 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -515,6 +515,18 @@ CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, return CPERR_SUCCESS; } +CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, + void (*func)(void *), + void *user_data) { + MessageLoop *message_loop = PluginThread::GetPluginThread()->message_loop(); + if (!message_loop) { + return CPERR_FAILURE; + } + message_loop->PostTask(FROM_HERE, NewRunnableFunction(func, user_data)); + + return CPERR_SUCCESS; +} + } // namespace CPBrowserFuncs* GetCPBrowserFuncsForPlugin() { @@ -544,6 +556,7 @@ CPBrowserFuncs* GetCPBrowserFuncsForPlugin() { browser_funcs.add_ui_command = CPB_AddUICommand; browser_funcs.handle_command = CPB_HandleCommand; browser_funcs.send_sync_message = CPB_SendSyncMessage; + browser_funcs.plugin_thread_async_call = CPB_PluginThreadAsyncCall; browser_funcs.request_funcs = &request_funcs; browser_funcs.response_funcs = &response_funcs; diff --git a/chrome/renderer/chrome_plugin_host.cc b/chrome/renderer/chrome_plugin_host.cc index b087902..66d4d04 100644 --- a/chrome/renderer/chrome_plugin_host.cc +++ b/chrome/renderer/chrome_plugin_host.cc @@ -521,6 +521,18 @@ CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len, return CPERR_SUCCESS; } +CPError STDCALL CPB_PluginThreadAsyncCall(CPID id, + void (*func)(void *), + void *user_data) { + MessageLoop *message_loop = RenderThread::current()->message_loop(); + if (!message_loop) { + return CPERR_FAILURE; + } + message_loop->PostTask(FROM_HERE, NewRunnableFunction(func, user_data)); + + return CPERR_SUCCESS; +} + } // namespace CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { @@ -550,6 +562,7 @@ CPBrowserFuncs* GetCPBrowserFuncsForRenderer() { browser_funcs.add_ui_command = CPB_AddUICommand; browser_funcs.handle_command = CPB_HandleCommand; browser_funcs.send_sync_message = CPB_SendSyncMessage; + browser_funcs.plugin_thread_async_call = CPB_PluginThreadAsyncCall; browser_funcs.request_funcs = &request_funcs; browser_funcs.response_funcs = &response_funcs; |