| Index: content/browser/renderer_host/pepper/pepper_renderer_connection.cc
|
| diff --git a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
|
| index 8c233bbc6a7c83663e6fba052551729802cd8b57..40feb863671373ea560895b03bae327581565107 100644
|
| --- a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
|
| +++ b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
|
| @@ -11,8 +11,6 @@
|
| #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
|
| #include "content/common/pepper_renderer_instance_data.h"
|
| #include "content/common/view_messages.h"
|
| -#include "content/browser/renderer_host/pepper/pepper_file_ref_host.h"
|
| -#include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h"
|
| #include "content/public/browser/content_browser_client.h"
|
| #include "content/public/common/content_client.h"
|
| #include "ipc/ipc_message_macros.h"
|
| @@ -27,63 +25,6 @@ namespace {
|
|
|
| const uint32 kFilteredMessageClasses[] = {PpapiMsgStart, ViewMsgStart, };
|
|
|
| -// Responsible for creating the pending resource hosts, holding their IDs until
|
| -// all of them have been created for a single message, and sending the reply to
|
| -// say that the hosts have been created.
|
| -class PendingHostCreator : public base::RefCounted<PendingHostCreator> {
|
| - public:
|
| - PendingHostCreator(BrowserPpapiHostImpl* host,
|
| - BrowserMessageFilter* connection,
|
| - int routing_id,
|
| - int sequence_id,
|
| - size_t nested_msgs_size);
|
| -
|
| - // Adds the given resource host as a pending one. The host is remembered as
|
| - // host number |index|, and will ultimately be sent to the plugin to be
|
| - // attached to a real resource.
|
| - void AddPendingResourceHost(
|
| - size_t index,
|
| - scoped_ptr<ppapi::host::ResourceHost> resource_host);
|
| -
|
| - private:
|
| - friend class base::RefCounted<PendingHostCreator>;
|
| -
|
| - // When the last reference to this class is released, all of the resource
|
| - // hosts would have been added. This destructor sends the message to the
|
| - // plugin to tell it to attach real hosts to all of the pending hosts that
|
| - // have been added by this object.
|
| - ~PendingHostCreator();
|
| -
|
| - BrowserPpapiHostImpl* host_;
|
| - BrowserMessageFilter* connection_;
|
| - int routing_id_;
|
| - int sequence_id_;
|
| - std::vector<int> pending_resource_host_ids_;
|
| -};
|
| -
|
| -PendingHostCreator::PendingHostCreator(BrowserPpapiHostImpl* host,
|
| - BrowserMessageFilter* connection,
|
| - int routing_id,
|
| - int sequence_id,
|
| - size_t nested_msgs_size)
|
| - : host_(host),
|
| - connection_(connection),
|
| - routing_id_(routing_id),
|
| - sequence_id_(sequence_id),
|
| - pending_resource_host_ids_(nested_msgs_size, 0) {}
|
| -
|
| -void PendingHostCreator::AddPendingResourceHost(
|
| - size_t index,
|
| - scoped_ptr<ppapi::host::ResourceHost> resource_host) {
|
| - pending_resource_host_ids_[index] =
|
| - host_->GetPpapiHost()->AddPendingResourceHost(resource_host.Pass());
|
| -}
|
| -
|
| -PendingHostCreator::~PendingHostCreator() {
|
| - connection_->Send(new PpapiHostMsg_CreateResourceHostsFromHostReply(
|
| - routing_id_, sequence_id_, pending_resource_host_ids_));
|
| -}
|
| -
|
| } // namespace
|
|
|
| PepperRendererConnection::PepperRendererConnection(int render_process_id)
|
| @@ -140,10 +81,15 @@ bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg) {
|
| IPC_BEGIN_MESSAGE_MAP(PepperRendererConnection, msg)
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost,
|
| OnMsgCreateResourceHostsFromHost)
|
| + IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReplyAck,
|
| + OnMsgCreateResourceHostsFromHostReplyAck)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance,
|
| OnMsgDidCreateInProcessInstance)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance,
|
| OnMsgDidDeleteInProcessInstance)
|
| + IPC_MESSAGE_HANDLER_DELAY_REPLY(
|
| + PpapiHostMsg_GetAllPendingResourceHosts,
|
| + OnMsgGetAllPendingResourceHosts)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
|
|
| @@ -161,64 +107,37 @@ void PepperRendererConnection::OnMsgCreateResourceHostsFromHost(
|
| DLOG(ERROR) << "Invalid plugin process ID.";
|
| return;
|
| }
|
| + host->CreateResourceHostsFromHost(routing_id, params, instance, nested_msgs);
|
| +}
|
|
|
| - scoped_refptr<PendingHostCreator> creator = new PendingHostCreator(
|
| - host, this, routing_id, params.sequence(), nested_msgs.size());
|
| - for (size_t i = 0; i < nested_msgs.size(); ++i) {
|
| - const IPC::Message& nested_msg = nested_msgs[i];
|
| - scoped_ptr<ppapi::host::ResourceHost> resource_host;
|
| - if (host->IsValidInstance(instance)) {
|
| - if (nested_msg.type() == PpapiHostMsg_FileRef_CreateForRawFS::ID) {
|
| - // FileRef_CreateForRawFS is only permitted from the renderer. Because
|
| - // of this, we handle this message here and not in
|
| - // content_browser_pepper_host_factory.cc.
|
| - base::FilePath external_path;
|
| - if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateForRawFS>(
|
| - nested_msg, &external_path)) {
|
| - resource_host.reset(new PepperFileRefHost(
|
| - host, instance, params.pp_resource(), external_path));
|
| - }
|
| - } else if (nested_msg.type() ==
|
| - PpapiHostMsg_FileSystem_CreateFromRenderer::ID) {
|
| - // Similarly, FileSystem_CreateFromRenderer is only permitted from the
|
| - // renderer.
|
| - std::string root_url;
|
| - PP_FileSystemType file_system_type;
|
| - if (ppapi::UnpackMessage<PpapiHostMsg_FileSystem_CreateFromRenderer>(
|
| - nested_msg, &root_url, &file_system_type)) {
|
| - PepperFileSystemBrowserHost* browser_host =
|
| - new PepperFileSystemBrowserHost(
|
| - host, instance, params.pp_resource(), file_system_type);
|
| - resource_host.reset(browser_host);
|
| - // Open the file system resource host. This is an asynchronous
|
| - // operation, and we must only add the pending resource host and
|
| - // send the message once it completes.
|
| - browser_host->OpenExisting(
|
| - GURL(root_url),
|
| - base::Bind(&PendingHostCreator::AddPendingResourceHost,
|
| - creator,
|
| - i,
|
| - base::Passed(&resource_host)));
|
| - // Do not fall through; the fall-through case adds the pending
|
| - // resource host to the list. We must do this asynchronously.
|
| - continue;
|
| - }
|
| - }
|
| - }
|
| -
|
| - if (!resource_host.get()) {
|
| - resource_host = host->GetPpapiHost()->CreateResourceHost(
|
| - params, instance, nested_msg);
|
| - }
|
| -
|
| - if (resource_host.get())
|
| - creator->AddPendingResourceHost(i, resource_host.Pass());
|
| +void PepperRendererConnection::OnMsgCreateResourceHostsFromHostReplyAck(
|
| + int child_process_id,
|
| + PP_Instance instance,
|
| + int sequence_num) {
|
| + BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id);
|
| + if (!host) {
|
| + DLOG(ERROR) << "Invalid plugin process ID.";
|
| + return;
|
| }
|
| + host->RendererDidReceiveHosts(instance, sequence_num);
|
| +}
|
|
|
| - // Note: All of the pending host IDs that were added as part of this
|
| - // operation will automatically be sent to the plugin when |creator| is
|
| - // released. This may happen immediately, or (if there are asynchronous
|
| - // requests to create resource hosts), once all of them complete.
|
| +void PepperRendererConnection::OnMsgGetAllPendingResourceHosts(
|
| + int routing_id,
|
| + int child_process_id,
|
| + PP_Instance instance,
|
| + IPC::Message* reply_msg) {
|
| + BrowserPpapiHostImpl* host = GetHostForChildProcess(child_process_id);
|
| + if (!host) {
|
| + DLOG(ERROR) << "Invalid plugin process ID.";
|
| + return;
|
| + }
|
| + bool success = host->GetAllPendingResourceHosts(
|
| + instance, scoped_ptr<IPC::Message>(reply_msg));
|
| + if (!success) {
|
| + // Make sure to unblock the caller, even though we have no results for them.
|
| + Send(reply_msg);
|
| + }
|
| }
|
|
|
| void PepperRendererConnection::OnMsgDidCreateInProcessInstance(
|
| @@ -226,7 +145,7 @@ void PepperRendererConnection::OnMsgDidCreateInProcessInstance(
|
| const PepperRendererInstanceData& instance_data) {
|
| PepperRendererInstanceData data = instance_data;
|
| data.render_process_id = render_process_id_;
|
| - in_process_host_->AddInstance(instance, data);
|
| + in_process_host_->AddInstance(instance, data, this);
|
| }
|
|
|
| void PepperRendererConnection::OnMsgDidDeleteInProcessInstance(
|
|
|