| 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 #include "chrome/ppapi_plugin/ppapi_thread.h" | 5 #include "chrome/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "chrome/common/child_process.h" | 8 #include "chrome/common/child_process.h" |
| 9 #include "ipc/ipc_channel_handle.h" | 9 #include "ipc/ipc_channel_handle.h" |
| 10 #include "ipc/ipc_sync_channel.h" | 10 #include "ipc/ipc_sync_channel.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 pp::proxy::PluginDispatcher::SetGlobal(NULL); | 28 pp::proxy::PluginDispatcher::SetGlobal(NULL); |
| 29 } | 29 } |
| 30 | 30 |
| 31 // The "regular" ChildThread implements this function and does some standard | 31 // The "regular" ChildThread implements this function and does some standard |
| 32 // dispatching, then uses the message router. We don't actually need any of | 32 // dispatching, then uses the message router. We don't actually need any of |
| 33 // this so this function just overrides that one. | 33 // this so this function just overrides that one. |
| 34 // | 34 // |
| 35 // Note that this function is called only for messages from the channel to the | 35 // Note that this function is called only for messages from the channel to the |
| 36 // browser process. Messages from the renderer process are sent via a different | 36 // browser process. Messages from the renderer process are sent via a different |
| 37 // channel that ends up at Dispatcher::OnMessageReceived. | 37 // channel that ends up at Dispatcher::OnMessageReceived. |
| 38 void PpapiThread::OnMessageReceived(const IPC::Message& msg) { | 38 bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { |
| 39 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) | 39 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) |
| 40 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) | 40 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin) |
| 41 | 41 |
| 42 // The rest of the messages go to the dispatcher. | 42 // The rest of the messages go to the dispatcher. |
| 43 /*IPC_MESSAGE_UNHANDLED( | 43 /*IPC_MESSAGE_UNHANDLED( |
| 44 if (dispatcher_.get()) | 44 if (dispatcher_.get()) |
| 45 dispatcher_->OnMessageReceived(msg) | 45 dispatcher_->OnMessageReceived(msg) |
| 46 )*/ | 46 )*/ |
| 47 IPC_END_MESSAGE_MAP() | 47 IPC_END_MESSAGE_MAP() |
| 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void PpapiThread::OnMsgLoadPlugin(base::ProcessHandle host_process_handle, | 51 void PpapiThread::OnMsgLoadPlugin(base::ProcessHandle host_process_handle, |
| 51 const FilePath& path, | 52 const FilePath& path, |
| 52 int renderer_id) { | 53 int renderer_id) { |
| 53 IPC::ChannelHandle channel_handle; | 54 IPC::ChannelHandle channel_handle; |
| 54 if (!LoadPluginLib(host_process_handle, path) || | 55 if (!LoadPluginLib(host_process_handle, path) || |
| 55 !SetupRendererChannel(renderer_id, &channel_handle)) { | 56 !SetupRendererChannel(renderer_id, &channel_handle)) { |
| 56 // An empty channel handle indicates error. | 57 // An empty channel handle indicates error. |
| 57 Send(new PpapiHostMsg_PluginLoaded(IPC::ChannelHandle())); | 58 Send(new PpapiHostMsg_PluginLoaded(IPC::ChannelHandle())); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 #if defined(OS_POSIX) | 121 #if defined(OS_POSIX) |
| 121 void PpapiThread::CloseRendererFD() { | 122 void PpapiThread::CloseRendererFD() { |
| 122 if (renderer_fd_ != -1) { | 123 if (renderer_fd_ != -1) { |
| 123 if (HANDLE_EINTR(close(renderer_fd_)) < 0) | 124 if (HANDLE_EINTR(close(renderer_fd_)) < 0) |
| 124 PLOG(ERROR) << "close"; | 125 PLOG(ERROR) << "close"; |
| 125 renderer_fd_ = -1; | 126 renderer_fd_ = -1; |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 #endif | 129 #endif |
| OLD | NEW |