| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 5 #ifndef CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| 6 #define CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 6 #define CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| 11 #include "base/scoped_native_library.h" | 11 #include "base/scoped_native_library.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/common/child_thread.h" | 14 #include "chrome/common/child_thread.h" |
| 15 #include "ppapi/c/pp_module.h" |
| 16 #include "ppapi/proxy/dispatcher.h" |
| 15 | 17 |
| 16 class FilePath; | 18 class FilePath; |
| 17 | 19 |
| 18 namespace IPC { | 20 namespace IPC { |
| 19 struct ChannelHandle; | 21 struct ChannelHandle; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace pp { | 24 namespace pp { |
| 23 namespace proxy { | 25 namespace proxy { |
| 24 class PluginDispatcher; | 26 class PluginDispatcher; |
| 25 } | 27 } |
| 26 } | 28 } |
| 27 | 29 |
| 28 class PpapiThread : public ChildThread { | 30 class PpapiThread : public ChildThread { |
| 29 public: | 31 public: |
| 30 PpapiThread(); | 32 PpapiThread(); |
| 31 ~PpapiThread(); | 33 ~PpapiThread(); |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 // ChildThread overrides. | 36 // ChildThread overrides. |
| 35 virtual bool OnMessageReceived(const IPC::Message& msg); | 37 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 36 | 38 |
| 37 // Message handlers. | 39 // Message handlers. |
| 38 void OnMsgLoadPlugin(base::ProcessHandle renderer_handle, | 40 void OnMsgLoadPlugin(const FilePath& path); |
| 39 const FilePath& path, | 41 void OnMsgCreateChannel(base::ProcessHandle host_process_handle, |
| 40 int renderer_id); | 42 int renderer_id); |
| 41 | |
| 42 bool LoadPluginLib(base::ProcessHandle host_process_handle, | |
| 43 const FilePath& path); | |
| 44 | 43 |
| 45 // Sets up the channel to the given renderer. On success, returns true and | 44 // Sets up the channel to the given renderer. On success, returns true and |
| 46 // fills the given ChannelHandle with the information from the new channel. | 45 // fills the given ChannelHandle with the information from the new channel. |
| 47 bool SetupRendererChannel(int renderer_id, | 46 bool SetupRendererChannel(base::ProcessHandle host_process_handle, |
| 47 int renderer_id, |
| 48 IPC::ChannelHandle* handle); | 48 IPC::ChannelHandle* handle); |
| 49 | 49 |
| 50 #if defined(OS_POSIX) | |
| 51 // Close the plugin process' copy of the renderer's side of the plugin | |
| 52 // channel. This can be called after the renderer is known to have its own | |
| 53 // copy of renderer_fd_. | |
| 54 void CloseRendererFD(); | |
| 55 #endif | |
| 56 | |
| 57 base::ScopedNativeLibrary library_; | 50 base::ScopedNativeLibrary library_; |
| 58 | 51 |
| 59 scoped_ptr<pp::proxy::PluginDispatcher> dispatcher_; | 52 pp::proxy::Dispatcher::GetInterfaceFunc get_plugin_interface_; |
| 60 | 53 |
| 61 #if defined(OS_POSIX) | 54 // Local concept of the module ID. Some functions take this. It's necessary |
| 62 // FD for the renderer end of the socket. It is closed when the IPC layer | 55 // for the in-process PPAPI to handle this properly, but for proxied it's |
| 63 // indicates that the channel is connected, proving that the renderer has | 56 // unnecessary. The proxy talking to multiple renderers means that each |
| 64 // access to its side of the socket. | 57 // renderer has a different idea of what the module ID is for this plugin. |
| 65 int renderer_fd_; | 58 // To force people to "do the right thing" we generate a random module ID |
| 66 #endif | 59 // and pass it around as necessary. |
| 60 PP_Module local_pp_module_; |
| 67 | 61 |
| 68 DISALLOW_COPY_AND_ASSIGN(PpapiThread); | 62 DISALLOW_COPY_AND_ASSIGN(PpapiThread); |
| 69 }; | 63 }; |
| 70 | 64 |
| 71 #endif // CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ | 65 #endif // CHROME_PPAPI_PLUGIN_PPAPI_THREAD_H_ |
| OLD | NEW |