summaryrefslogtreecommitdiffstats
path: root/content/ppapi_plugin
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 17:19:02 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 17:19:02 +0000
commit24498a8e674e456f5d778f3e192d886fa4573ec9 (patch)
tree3a01d312cd4fc1bc5b329b05e04f4e21acd380d2 /content/ppapi_plugin
parenta64ccdb0c5dbe674a3cdc368ab758fdde0b4a5d9 (diff)
downloadchromium_src-24498a8e674e456f5d778f3e192d886fa4573ec9.zip
chromium_src-24498a8e674e456f5d778f3e192d886fa4573ec9.tar.gz
chromium_src-24498a8e674e456f5d778f3e192d886fa4573ec9.tar.bz2
Define PPB_Flash_TCPSocket and PPB_Flash_SSLSocket.
TEST=None BUG=None Review URL: http://codereview.chromium.org/7191005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc44
-rw-r--r--content/ppapi_plugin/ppapi_thread.h10
2 files changed, 53 insertions, 1 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index 9b3c846..c3b42ed 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -41,7 +41,8 @@ PpapiThread::PpapiThread(bool is_broker)
get_plugin_interface_(NULL),
connect_instance_func_(NULL),
local_pp_module_(
- base::RandInt(0, std::numeric_limits<PP_Module>::max())) {
+ base::RandInt(0, std::numeric_limits<PP_Module>::max())),
+ next_plugin_dispatcher_id_(1) {
}
PpapiThread::~PpapiThread() {
@@ -70,6 +71,12 @@ bool PpapiThread::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnMsgLoadPlugin)
IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnMsgCreateChannel)
+ IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_ConnectACK,
+ OnPluginDispatcherMessageReceived(msg))
+ IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_ReadACK,
+ OnPluginDispatcherMessageReceived(msg))
+ IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBFlashTCPSocket_WriteACK,
+ OnPluginDispatcherMessageReceived(msg))
IPC_END_MESSAGE_MAP()
return true;
}
@@ -103,6 +110,27 @@ bool PpapiThread::SendToBrowser(IPC::Message* msg) {
return Send(msg);
}
+uint32 PpapiThread::Register(pp::proxy::PluginDispatcher* plugin_dispatcher) {
+ if (!plugin_dispatcher ||
+ plugin_dispatchers_.size() >= std::numeric_limits<uint32>::max()) {
+ return 0;
+ }
+
+ uint32 id = 0;
+ do {
+ // Although it is unlikely, make sure that we won't cause any trouble when
+ // the counter overflows.
+ id = next_plugin_dispatcher_id_++;
+ } while (id == 0 ||
+ plugin_dispatchers_.find(id) != plugin_dispatchers_.end());
+ plugin_dispatchers_[id] = plugin_dispatcher;
+ return id;
+}
+
+void PpapiThread::Unregister(uint32 plugin_dispatcher_id) {
+ plugin_dispatchers_.erase(plugin_dispatcher_id);
+}
+
void PpapiThread::OnMsgLoadPlugin(const FilePath& path) {
base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, NULL));
@@ -192,6 +220,20 @@ void PpapiThread::OnMsgCreateChannel(base::ProcessHandle host_process_handle,
Send(new PpapiHostMsg_ChannelCreated(channel_handle));
}
+void PpapiThread::OnPluginDispatcherMessageReceived(const IPC::Message& msg) {
+ // The first parameter should be a plugin dispatcher ID.
+ void* iter = NULL;
+ uint32 id = 0;
+ if (!msg.ReadUInt32(&iter, &id)) {
+ NOTREACHED();
+ return;
+ }
+ std::map<uint32, pp::proxy::PluginDispatcher*>::iterator dispatcher =
+ plugin_dispatchers_.find(id);
+ if (dispatcher != plugin_dispatchers_.end())
+ dispatcher->second->OnMessageReceived(msg);
+}
+
bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle,
int renderer_id,
IPC::ChannelHandle* handle) {
diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h
index 3d20387..5b77f24 100644
--- a/content/ppapi_plugin/ppapi_thread.h
+++ b/content/ppapi_plugin/ppapi_thread.h
@@ -6,6 +6,8 @@
#define CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_
#pragma once
+#include <map>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -42,11 +44,15 @@ class PpapiThread : public ChildThread,
virtual void PostToWebKitThread(const tracked_objects::Location& from_here,
const base::Closure& task) OVERRIDE;
virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE;
+ virtual uint32 Register(
+ pp::proxy::PluginDispatcher* plugin_dispatcher) OVERRIDE;
+ virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;
// Message handlers.
void OnMsgLoadPlugin(const FilePath& path);
void OnMsgCreateChannel(base::ProcessHandle host_process_handle,
int renderer_id);
+ void OnPluginDispatcherMessageReceived(const IPC::Message& msg);
// Sets up the channel to the given renderer. On success, returns true and
// fills the given ChannelHandle with the information from the new channel.
@@ -81,6 +87,10 @@ class PpapiThread : public ChildThread,
scoped_ptr<PpapiWebKitThread> webkit_thread_;
+ // The PluginDispatcher instances contained in the map are not owned by it.
+ std::map<uint32, pp::proxy::PluginDispatcher*> plugin_dispatchers_;
+ uint32 next_plugin_dispatcher_id_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread);
};