diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 04:37:58 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 04:37:58 +0000 |
commit | f2d7c0483ea6b5ae61c38cf05b4951c0b5fc89e2 (patch) | |
tree | 05183071323228ff4f6dfe4bc69079e82be9e0df | |
parent | bfcf1e9985d66f1ec405154e994ab2966a26e0c0 (diff) | |
download | chromium_src-f2d7c0483ea6b5ae61c38cf05b4951c0b5fc89e2.zip chromium_src-f2d7c0483ea6b5ae61c38cf05b4951c0b5fc89e2.tar.gz chromium_src-f2d7c0483ea6b5ae61c38cf05b4951c0b5fc89e2.tar.bz2 |
Add GetFileThreadMessageLoop method to PpapiGlobals.
This is needed to implement performance critical FileIO functions
on the plugin side.
BUG=194304
Review URL: https://chromiumcodereview.appspot.com/18144004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211019 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ppapi/proxy/plugin_globals.cc | 12 | ||||
-rw-r--r-- | ppapi/proxy/plugin_globals.h | 8 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_globals.h | 6 | ||||
-rw-r--r-- | ppapi/shared_impl/test_globals.cc | 4 | ||||
-rw-r--r-- | ppapi/shared_impl/test_globals.h | 1 | ||||
-rw-r--r-- | webkit/plugins/ppapi/host_globals.cc | 9 | ||||
-rw-r--r-- | webkit/plugins/ppapi/host_globals.h | 1 |
7 files changed, 41 insertions, 0 deletions
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc index fba5b1f..e41cd5e 100644 --- a/ppapi/proxy/plugin_globals.cc +++ b/ppapi/proxy/plugin_globals.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/plugin_globals.h" +#include "base/task_runner.h" +#include "base/threading/thread.h" #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -152,6 +154,16 @@ MessageLoopShared* PluginGlobals::GetCurrentMessageLoop() { return MessageLoopResource::GetCurrent(); } +base::TaskRunner* PluginGlobals::GetFileTaskRunner(PP_Instance instance) { + if (!file_thread_.get()) { + file_thread_.reset(new base::Thread("Plugin::File")); + base::Thread::Options options; + options.message_loop_type = base::MessageLoop::TYPE_IO; + file_thread_->StartWithOptions(options); + } + return file_thread_->message_loop_proxy(); +} + IPC::Sender* PluginGlobals::GetBrowserSender() { if (!browser_sender_.get()) { browser_sender_.reset( diff --git a/ppapi/proxy/plugin_globals.h b/ppapi/proxy/plugin_globals.h index 37fdc1a..014cb26 100644 --- a/ppapi/proxy/plugin_globals.h +++ b/ppapi/proxy/plugin_globals.h @@ -17,6 +17,9 @@ #include "ppapi/shared_impl/callback_tracker.h" #include "ppapi/shared_impl/ppapi_globals.h" +namespace base { +class Thread; +} namespace IPC { class Sender; } @@ -65,6 +68,7 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { const std::string& source, const std::string& value) OVERRIDE; virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; + base::TaskRunner* GetFileTaskRunner(PP_Instance instance) OVERRIDE; // Returns the channel for sending to the browser. IPC::Sender* GetBrowserSender(); @@ -144,6 +148,10 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { scoped_ptr<BrowserSender> browser_sender_; + // Thread for performing potentially blocking file operations. It's created + // lazily, since it might not be needed. + scoped_ptr<base::Thread> file_thread_; + DISALLOW_COPY_AND_ASSIGN(PluginGlobals); }; diff --git a/ppapi/shared_impl/ppapi_globals.h b/ppapi/shared_impl/ppapi_globals.h index 4c094c1..66275e5 100644 --- a/ppapi/shared_impl/ppapi_globals.h +++ b/ppapi/shared_impl/ppapi_globals.h @@ -19,6 +19,7 @@ namespace base { class Lock; class MessageLoopProxy; +class TaskRunner; } namespace ppapi { @@ -114,6 +115,11 @@ class PPAPI_SHARED_EXPORT PpapiGlobals { // supported. virtual MessageLoopShared* GetCurrentMessageLoop() = 0; + // Returns a task runner for file operations that may block. + // TODO(bbudge) Move this to PluginGlobals when we no longer support + // in-process plugins. + virtual base::TaskRunner* GetFileTaskRunner(PP_Instance instance) = 0; + // Returns the command line for the process. virtual std::string GetCmdLine() = 0; diff --git a/ppapi/shared_impl/test_globals.cc b/ppapi/shared_impl/test_globals.cc index 6c6af5b..133b943 100644 --- a/ppapi/shared_impl/test_globals.cc +++ b/ppapi/shared_impl/test_globals.cc @@ -75,6 +75,10 @@ MessageLoopShared* TestGlobals::GetCurrentMessageLoop() { return NULL; } +base::TaskRunner* TestGlobals::GetFileTaskRunner(PP_Instance instance) { + return NULL; +} + bool TestGlobals::IsHostGlobals() const { // Pretend to be the host-side, for code that expects one or the other. // TODO(dmichael): just make it settable which one we're pretending to be? diff --git a/ppapi/shared_impl/test_globals.h b/ppapi/shared_impl/test_globals.h index c4d4aa1..803cfe3 100644 --- a/ppapi/shared_impl/test_globals.h +++ b/ppapi/shared_impl/test_globals.h @@ -71,6 +71,7 @@ class TestGlobals : public PpapiGlobals { const std::string& source, const std::string& value) OVERRIDE; virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; + virtual base::TaskRunner* GetFileTaskRunner(PP_Instance instance) OVERRIDE; // PpapiGlobals overrides: virtual bool IsHostGlobals() const OVERRIDE; diff --git a/webkit/plugins/ppapi/host_globals.cc b/webkit/plugins/ppapi/host_globals.cc index 2572b16..c2b3331 100644 --- a/webkit/plugins/ppapi/host_globals.cc +++ b/webkit/plugins/ppapi/host_globals.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/rand_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/task_runner.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/id_assignment.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -183,6 +184,14 @@ void HostGlobals::BroadcastLogWithSource(PP_Module pp_module, (*i)->element().document().frame()->addMessageToConsole(message); } +base::TaskRunner* HostGlobals::GetFileTaskRunner(PP_Instance instance) { + scoped_refptr<PluginInstance> plugin_instance = GetInstance(instance); + DCHECK(plugin_instance.get()); + scoped_refptr<base::MessageLoopProxy> message_loop = + plugin_instance->delegate()->GetFileThreadMessageLoopProxy(); + return message_loop.get(); +} + ::ppapi::MessageLoopShared* HostGlobals::GetCurrentMessageLoop() { return NULL; } diff --git a/webkit/plugins/ppapi/host_globals.h b/webkit/plugins/ppapi/host_globals.h index 31c22ed..36cbc87 100644 --- a/webkit/plugins/ppapi/host_globals.h +++ b/webkit/plugins/ppapi/host_globals.h @@ -55,6 +55,7 @@ class HostGlobals : public ::ppapi::PpapiGlobals { const std::string& source, const std::string& value) OVERRIDE; virtual ::ppapi::MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; + virtual base::TaskRunner* GetFileTaskRunner(PP_Instance instance) OVERRIDE; HostVarTracker* host_var_tracker() { return &host_var_tracker_; |