summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/plugin')
-rw-r--r--chrome/plugin/plugin_channel.cc23
-rw-r--r--chrome/plugin/plugin_channel.h6
-rw-r--r--chrome/plugin/plugin_thread.cc6
-rw-r--r--chrome/plugin/plugin_thread.h2
4 files changed, 17 insertions, 20 deletions
diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc
index 4774d8c..675a46f 100644
--- a/chrome/plugin/plugin_channel.cc
+++ b/chrome/plugin/plugin_channel.cc
@@ -8,29 +8,23 @@
#include "chrome/common/plugin_messages.h"
#include "base/command_line.h"
+#include "base/process_util.h"
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/plugin/plugin_process.h"
#include "chrome/plugin/plugin_thread.h"
-PluginChannel* PluginChannel::GetPluginChannel(
- int process_id, HANDLE renderer_handle, MessageLoop* ipc_message_loop) {
- // map renderer's process id to a (single) channel to that process
+PluginChannel* PluginChannel::GetPluginChannel(MessageLoop* ipc_message_loop) {
+ static int next_id;
std::wstring channel_name = StringPrintf(
- L"%d.r%d", GetCurrentProcessId(), process_id);
+ L"%d.r%d", GetCurrentProcessId(), ++next_id);
- PluginChannelBase* result = PluginChannelBase::GetChannel(
+ return static_cast<PluginChannel*>(PluginChannelBase::GetChannel(
channel_name,
IPC::Channel::MODE_SERVER,
ClassFactory,
ipc_message_loop,
- false);
-
- PluginChannel* channel = static_cast<PluginChannel*>(result);
- if (channel && !channel->renderer_handle())
- channel->renderer_handle_.Set(renderer_handle);
-
- return channel;
+ false));
}
PluginChannel::PluginChannel() : in_send_(0) {
@@ -105,6 +99,11 @@ int PluginChannel::GenerateRouteID() {
return InterlockedIncrement(&last_id);
}
+void PluginChannel::OnChannelConnected(int32 peer_pid) {
+ renderer_handle_.Set(base::OpenProcessHandle(peer_pid));
+ PluginChannelBase::OnChannelConnected(peer_pid);
+}
+
void PluginChannel::OnChannelError() {
renderer_handle_.Set(NULL);
PluginChannelBase::OnChannelError();
diff --git a/chrome/plugin/plugin_channel.h b/chrome/plugin/plugin_channel.h
index 4802a6e..22ebbfa 100644
--- a/chrome/plugin/plugin_channel.h
+++ b/chrome/plugin/plugin_channel.h
@@ -14,10 +14,7 @@
// process. On the renderer side there's a corresponding PluginChannelHost.
class PluginChannel : public PluginChannelBase {
public:
- // renderer_handle is the the handle to the renderer process requesting the
- // channel. The handle has to be valid in the context of the plugin process.
- static PluginChannel* GetPluginChannel(
- int process_id, HANDLE renderer_handle, MessageLoop* ipc_message_loop);
+ static PluginChannel* GetPluginChannel(MessageLoop* ipc_message_loop);
~PluginChannel();
@@ -31,6 +28,7 @@ class PluginChannel : public PluginChannelBase {
protected:
// IPC::Channel::Listener implementation:
+ virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelError();
virtual void CleanUp();
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 891a9df..1590250 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -90,14 +90,14 @@ void PluginThread::CleanUp() {
TerminateProcess(GetCurrentProcess(), 0);
}
-void PluginThread::OnCreateChannel(int process_id, HANDLE renderer) {
+void PluginThread::OnCreateChannel() {
std::wstring channel_name;
scoped_refptr<PluginChannel> channel =
- PluginChannel::GetPluginChannel(process_id, renderer, owner_loop());
+ PluginChannel::GetPluginChannel(owner_loop());
if (channel.get())
channel_name = channel->channel_name();
- Send(new PluginProcessHostMsg_ChannelCreated(process_id, channel_name));
+ Send(new PluginProcessHostMsg_ChannelCreated(channel_name));
}
void PluginThread::OnShutdownResponse(bool ok_to_shutdown) {
diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h
index e701490..1be1c7a 100644
--- a/chrome/plugin/plugin_thread.h
+++ b/chrome/plugin/plugin_thread.h
@@ -35,7 +35,7 @@ class PluginThread : public ChildThread {
virtual void Init();
virtual void CleanUp();
- void OnCreateChannel(int process_id, HANDLE renderer);
+ void OnCreateChannel();
void OnShutdownResponse(bool ok_to_shutdown);
void OnPluginMessage(const std::vector<uint8> &data);
void OnBrowserShutdown();