| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 5 #ifndef CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| 6 #define CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 6 #define CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/process.h" | 14 #include "base/process.h" |
| 15 #include "base/scoped_native_library.h" | 15 #include "base/scoped_native_library.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/common/child_thread.h" | 17 #include "content/common/child_thread.h" |
| 18 #include "ppapi/c/pp_module.h" | 18 #include "ppapi/c/pp_module.h" |
| 19 #include "ppapi/c/trusted/ppp_broker.h" | 19 #include "ppapi/c/trusted/ppp_broker.h" |
| 20 #include "ppapi/proxy/plugin_dispatcher.h" | 20 #include "ppapi/proxy/plugin_dispatcher.h" |
| 21 #include "ppapi/proxy/plugin_globals.h" | 21 #include "ppapi/proxy/plugin_globals.h" |
| 22 #include "ppapi/proxy/plugin_proxy_delegate.h" | 22 #include "ppapi/proxy/plugin_proxy_delegate.h" |
| 23 | 23 |
| 24 class FilePath; | 24 class FilePath; |
| 25 class PpapiWebKitThread; | 25 class PpapiWebKitPlatformSupportImpl; |
| 26 | 26 |
| 27 namespace IPC { | 27 namespace IPC { |
| 28 struct ChannelHandle; | 28 struct ChannelHandle; |
| 29 } | 29 } |
| 30 | 30 |
| 31 class PpapiThread : public ChildThread, | 31 class PpapiThread : public ChildThread, |
| 32 public ppapi::proxy::PluginDispatcher::PluginDelegate, | 32 public ppapi::proxy::PluginDispatcher::PluginDelegate, |
| 33 public ppapi::proxy::PluginProxyDelegate { | 33 public ppapi::proxy::PluginProxyDelegate { |
| 34 public: | 34 public: |
| 35 explicit PpapiThread(bool is_broker); | 35 explicit PpapiThread(bool is_broker); |
| 36 virtual ~PpapiThread(); | 36 virtual ~PpapiThread(); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // ChildThread overrides. | 39 // ChildThread overrides. |
| 40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 41 | 41 |
| 42 // PluginDispatcher::PluginDelegate implementation. | 42 // PluginDispatcher::PluginDelegate implementation. |
| 43 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE; | 43 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE; |
| 44 virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; | 44 virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; |
| 45 virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; | 45 virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; |
| 46 virtual uint32 Register( | 46 virtual uint32 Register( |
| 47 ppapi::proxy::PluginDispatcher* plugin_dispatcher) OVERRIDE; | 47 ppapi::proxy::PluginDispatcher* plugin_dispatcher) OVERRIDE; |
| 48 virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE; | 48 virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE; |
| 49 | 49 |
| 50 // PluginProxyDelegate. | 50 // PluginProxyDelegate. |
| 51 virtual ppapi::WebKitForwarding* GetWebKitForwarding() OVERRIDE; | |
| 52 virtual void PostToWebKitThread(const tracked_objects::Location& from_here, | |
| 53 const base::Closure& task) OVERRIDE; | |
| 54 virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE; | 51 virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE; |
| 55 virtual void PreCacheFont(const void* logfontw) OVERRIDE; | 52 virtual void PreCacheFont(const void* logfontw) OVERRIDE; |
| 56 | 53 |
| 57 // Message handlers. | 54 // Message handlers. |
| 58 void OnMsgLoadPlugin(const FilePath& path); | 55 void OnMsgLoadPlugin(const FilePath& path); |
| 59 void OnMsgCreateChannel(base::ProcessHandle host_process_handle, | 56 void OnMsgCreateChannel(base::ProcessHandle host_process_handle, |
| 60 int renderer_id); | 57 int renderer_id); |
| 61 void OnMsgSetNetworkState(bool online); | 58 void OnMsgSetNetworkState(bool online); |
| 62 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); | 59 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); |
| 63 | 60 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 // for the in-process PPAPI to handle this properly, but for proxied it's | 82 // for the in-process PPAPI to handle this properly, but for proxied it's |
| 86 // unnecessary. The proxy talking to multiple renderers means that each | 83 // unnecessary. The proxy talking to multiple renderers means that each |
| 87 // renderer has a different idea of what the module ID is for this plugin. | 84 // renderer has a different idea of what the module ID is for this plugin. |
| 88 // To force people to "do the right thing" we generate a random module ID | 85 // To force people to "do the right thing" we generate a random module ID |
| 89 // and pass it around as necessary. | 86 // and pass it around as necessary. |
| 90 PP_Module local_pp_module_; | 87 PP_Module local_pp_module_; |
| 91 | 88 |
| 92 // See Dispatcher::Delegate::GetGloballySeenInstanceIDSet. | 89 // See Dispatcher::Delegate::GetGloballySeenInstanceIDSet. |
| 93 std::set<PP_Instance> globally_seen_instance_ids_; | 90 std::set<PP_Instance> globally_seen_instance_ids_; |
| 94 | 91 |
| 95 // Lazily created by GetWebKitForwarding. | |
| 96 scoped_ptr<ppapi::WebKitForwarding> webkit_forwarding_; | |
| 97 | |
| 98 scoped_ptr<PpapiWebKitThread> webkit_thread_; | |
| 99 | |
| 100 // The PluginDispatcher instances contained in the map are not owned by it. | 92 // The PluginDispatcher instances contained in the map are not owned by it. |
| 101 std::map<uint32, ppapi::proxy::PluginDispatcher*> plugin_dispatchers_; | 93 std::map<uint32, ppapi::proxy::PluginDispatcher*> plugin_dispatchers_; |
| 102 uint32 next_plugin_dispatcher_id_; | 94 uint32 next_plugin_dispatcher_id_; |
| 103 | 95 |
| 96 // The WebKitPlatformSupport implementation. |
| 97 scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_; |
| 98 |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread); | 99 DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread); |
| 105 }; | 100 }; |
| 106 | 101 |
| 107 #endif // CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 102 #endif // CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| OLD | NEW |