summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/renderer_host/render_message_filter.cc28
-rw-r--r--content/browser/renderer_host/render_message_filter.h6
-rw-r--r--content/common/view_messages.h9
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/renderer/pepper/audio_helper.cc1
-rw-r--r--content/renderer/pepper/pepper_browser_connection.cc31
-rw-r--r--content/renderer/pepper/pepper_browser_connection.h14
-rw-r--r--content/renderer/pepper/pepper_file_io_host.cc60
-rw-r--r--content/renderer/pepper/pepper_file_io_host.h21
-rw-r--r--content/renderer/pepper/pepper_graphics_2d_host.cc1
-rw-r--r--content/renderer/pepper/pepper_helper_impl.cc126
-rw-r--r--content/renderer/pepper/pepper_helper_impl.h59
-rw-r--r--content/renderer/pepper/ppb_audio_impl.cc5
-rw-r--r--content/renderer/pepper/ppb_broker_impl.cc6
-rw-r--r--content/renderer/pepper/ppb_buffer_impl.cc1
-rw-r--r--content/renderer/pepper/ppb_file_ref_impl.cc79
-rw-r--r--content/renderer/pepper/ppb_file_ref_impl.h23
-rw-r--r--content/renderer/pepper/ppb_graphics_3d_impl.cc17
-rw-r--r--content/renderer/pepper/ppb_image_data_impl.cc4
-rw-r--r--content/renderer/pepper/ppb_network_monitor_private_impl.cc1
-rw-r--r--content/renderer/pepper/ppb_scrollbar_impl.cc12
-rw-r--r--content/renderer/pepper/ppb_tcp_socket_private_impl.cc153
-rw-r--r--content/renderer/pepper/ppb_tcp_socket_private_impl.h41
-rw-r--r--content/renderer/pepper/ppb_video_decoder_impl.cc6
-rw-r--r--content/renderer/pepper/ppb_widget_impl.cc4
-rw-r--r--content/renderer/pepper/quota_file_io.cc1
-rw-r--r--content/renderer/pepper/renderer_ppapi_host_impl.cc21
-rw-r--r--content/renderer/pepper/renderer_ppapi_host_impl.h3
-rw-r--r--content/renderer/pepper/resource_creation_impl.cc1
-rw-r--r--content/renderer/pepper/resource_helper.cc38
-rw-r--r--content/renderer/pepper/resource_helper.h52
-rw-r--r--content/renderer/pepper/url_request_info_util.cc5
32 files changed, 330 insertions, 501 deletions
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index daab4ed..ace2bcc 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -444,6 +444,8 @@ base::TaskRunner* RenderMessageFilter::OverrideTaskRunnerForMessage(
if (message.type() == ViewHostMsg_GetAudioHardwareConfig::ID)
return audio_manager_->GetMessageLoop().get();
#endif
+ if (message.type() == ViewHostMsg_AsyncOpenPepperFile::ID)
+ return BrowserThread::GetBlockingPool();
return NULL;
}
@@ -989,12 +991,10 @@ void RenderMessageFilter::OnKeygenOnWorkerThread(
Send(reply_msg);
}
-void RenderMessageFilter::OnAsyncOpenPepperFile(const IPC::Message& msg,
+void RenderMessageFilter::OnAsyncOpenPepperFile(int routing_id,
const base::FilePath& path,
int pp_open_flags,
int message_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
int platform_file_flags = 0;
if (!CanOpenWithPepperFlags(pp_open_flags, render_process_id_, path) ||
!ppapi::PepperFileOpenFlagsToPlatformFileFlags(
@@ -1007,18 +1007,6 @@ void RenderMessageFilter::OnAsyncOpenPepperFile(const IPC::Message& msg,
return;
}
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE, base::Bind(
- &RenderMessageFilter::AsyncOpenPepperFileOnFileThread, this,
- path, platform_file_flags, message_id, msg.routing_id()));
-}
-
-void RenderMessageFilter::AsyncOpenPepperFileOnFileThread(
- const base::FilePath& path,
- int platform_file_flags,
- int message_id,
- int routing_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
base::PlatformFile file = base::CreatePlatformFile(
path, platform_file_flags, NULL, &error_code);
@@ -1027,14 +1015,8 @@ void RenderMessageFilter::AsyncOpenPepperFileOnFileThread(
IPC::GetFileHandleForProcess(file, PeerHandle(), true) :
IPC::InvalidPlatformFileForTransit();
- IPC::Message* reply = new ViewMsg_AsyncOpenPepperFile_ACK(
- routing_id,
- error_code,
- file_for_transit,
- message_id);
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(base::IgnoreResult(&RenderMessageFilter::Send), this, reply));
+ Send(new ViewMsg_AsyncOpenPepperFile_ACK(
+ routing_id, error_code, file_for_transit, message_id));
}
void RenderMessageFilter::OnMediaLogEvents(
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index e6f1995..c37594f 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -224,14 +224,10 @@ class RenderMessageFilter : public BrowserMessageFilter {
const std::string& challenge_string,
const GURL& url,
IPC::Message* reply_msg);
- void OnAsyncOpenPepperFile(const IPC::Message& msg,
+ void OnAsyncOpenPepperFile(int routing_id,
const base::FilePath& path,
int pp_open_flags,
int message_id);
- void AsyncOpenPepperFileOnFileThread(const base::FilePath& path,
- int platform_file_flags,
- int message_id,
- int routing_id);
void OnMediaLogEvents(const std::vector<media::MediaLogEvent>&);
// Check the policy for getting cookies. Gets the cookies if allowed.
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index c8e27da..106f52f 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1905,10 +1905,11 @@ IPC_MESSAGE_CONTROL3(ViewHostMsg_OpenChannelToPpapiBroker,
// Opens a Pepper file asynchronously. The response returns a file descriptor
// and an error code from base/platform_file.h.
-IPC_MESSAGE_ROUTED3(ViewHostMsg_AsyncOpenPepperFile,
- base::FilePath /* file path */,
- int /* pp_open_flags */,
- int /* message_id */)
+IPC_MESSAGE_CONTROL4(ViewHostMsg_AsyncOpenPepperFile,
+ int /* routing_id */,
+ base::FilePath /* file path */,
+ int /* pp_open_flags */,
+ int /* message_id */)
// A renderer sends this to the browser process when it wants to access a PPAPI
// broker. In contrast to ViewHostMsg_OpenChannelToPpapiBroker, this is called
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 51e430e..249cab9 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -389,8 +389,6 @@
'renderer/pepper/renderer_restrict_dispatch_group.h',
'renderer/pepper/resource_creation_impl.cc',
'renderer/pepper/resource_creation_impl.h',
- 'renderer/pepper/resource_helper.cc',
- 'renderer/pepper/resource_helper.h',
'renderer/pepper/url_request_info_util.cc',
'renderer/pepper/url_request_info_util.h',
'renderer/pepper/url_response_info_util.cc',
diff --git a/content/renderer/pepper/audio_helper.cc b/content/renderer/pepper/audio_helper.cc
index 32b1057..2bbe991 100644
--- a/content/renderer/pepper/audio_helper.cc
+++ b/content/renderer/pepper/audio_helper.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "content/renderer/pepper/common.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
diff --git a/content/renderer/pepper/pepper_browser_connection.cc b/content/renderer/pepper/pepper_browser_connection.cc
index 88cd363e..718b879 100644
--- a/content/renderer/pepper/pepper_browser_connection.cc
+++ b/content/renderer/pepper/pepper_browser_connection.cc
@@ -17,8 +17,9 @@
namespace content {
-PepperBrowserConnection::PepperBrowserConnection(PepperHelperImpl* helper)
- : helper_(helper),
+PepperBrowserConnection::PepperBrowserConnection(RenderView* render_view)
+ : RenderViewObserver(render_view),
+ RenderViewObserverTracker<PepperBrowserConnection>(render_view),
next_sequence_number_(1) {
}
@@ -45,19 +46,17 @@ void PepperBrowserConnection::DidCreateInProcessInstance(
int render_view_id,
const GURL& document_url,
const GURL& plugin_url) {
- helper_->render_view()->Send(
- new ViewHostMsg_DidCreateInProcessInstance(
- instance,
- // Browser provides the render process id.
- PepperRendererInstanceData(0,
- render_view_id,
- document_url,
- plugin_url)));
+ Send(new ViewHostMsg_DidCreateInProcessInstance(
+ instance,
+ // Browser provides the render process id.
+ PepperRendererInstanceData(0,
+ render_view_id,
+ document_url,
+ plugin_url)));
}
void PepperBrowserConnection::DidDeleteInProcessInstance(PP_Instance instance) {
- helper_->render_view()->Send(
- new ViewHostMsg_DidDeleteInProcessInstance(instance));
+ Send(new ViewHostMsg_DidDeleteInProcessInstance(instance));
}
void PepperBrowserConnection::SendBrowserCreate(
@@ -68,8 +67,8 @@ void PepperBrowserConnection::SendBrowserCreate(
int32_t sequence_number = GetNextSequence();
pending_create_map_[sequence_number] = callback;
ppapi::proxy::ResourceMessageCallParams params(0, sequence_number);
- helper_->Send(new PpapiHostMsg_CreateResourceHostFromHost(
- helper_->routing_id(),
+ Send(new PpapiHostMsg_CreateResourceHostFromHost(
+ routing_id(),
child_process_id,
params,
instance,
@@ -82,8 +81,8 @@ void PepperBrowserConnection::SendBrowserFileRefGetInfo(
const FileRefGetInfoCallback& callback) {
int32_t sequence_number = GetNextSequence();
get_info_map_[sequence_number] = callback;
- helper_->Send(new PpapiHostMsg_FileRef_GetInfoForRenderer(
- helper_->routing_id(), child_process_id, sequence_number, resources));
+ Send(new PpapiHostMsg_FileRef_GetInfoForRenderer(
+ routing_id(), child_process_id, sequence_number, resources));
}
void PepperBrowserConnection::OnMsgCreateResourceHostFromHostReply(
diff --git a/content/renderer/pepper/pepper_browser_connection.h b/content/renderer/pepper/pepper_browser_connection.h
index 7cb35bf..9fde7d2 100644
--- a/content/renderer/pepper/pepper_browser_connection.h
+++ b/content/renderer/pepper/pepper_browser_connection.h
@@ -11,19 +11,20 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "content/public/renderer/render_view_observer.h"
+#include "content/public/renderer/render_view_observer_tracker.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
namespace content {
-class PepperHelperImpl;
-
// This class represents a connection from the renderer to the browser for
// sending/receiving pepper ResourceHost related messages. When the browser
// and renderer communicate about ResourceHosts, they should pass the plugin
// process ID to identify which plugin they are talking about.
-class PepperBrowserConnection {
+class PepperBrowserConnection
+ : public RenderViewObserver,
+ public RenderViewObserverTracker<PepperBrowserConnection> {
public:
typedef base::Callback<void(int)> PendingResourceIDCallback;
typedef base::Callback<void(
@@ -32,10 +33,10 @@ class PepperBrowserConnection {
const std::vector<std::string>&,
const std::vector<base::FilePath>&)> FileRefGetInfoCallback;
- explicit PepperBrowserConnection(PepperHelperImpl* helper);
+ explicit PepperBrowserConnection(RenderView* render_view);
virtual ~PepperBrowserConnection();
- bool OnMessageReceived(const IPC::Message& message);
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// TODO(teravest): Instead of having separate methods per message, we should
// add generic functionality similar to PluginResource::Call().
@@ -78,9 +79,6 @@ class PepperBrowserConnection {
// Return the next sequence number.
int32_t GetNextSequence();
- // The plugin helper that owns us.
- PepperHelperImpl* helper_;
-
// Sequence number to track pending callbacks.
int32_t next_sequence_number_;
diff --git a/content/renderer/pepper/pepper_file_io_host.cc b/content/renderer/pepper/pepper_file_io_host.cc
index c98bc50..4d78f01 100644
--- a/content/renderer/pepper/pepper_file_io_host.cc
+++ b/content/renderer/pepper/pepper_file_io_host.cc
@@ -13,6 +13,7 @@
#include "content/child/fileapi/file_system_dispatcher.h"
#include "content/child/quota_dispatcher.h"
#include "content/common/fileapi/file_system_messages.h"
+#include "content/common/view_messages.h"
#include "content/public/common/content_client.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/pepper/host_globals.h"
@@ -20,7 +21,6 @@
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/ppb_file_ref_impl.h"
#include "content/renderer/pepper/quota_file_io.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/host/dispatch_host_message.h"
@@ -148,11 +148,14 @@ PepperFileIOHost::PepperFileIOHost(RendererPpapiHost* host,
quota_policy_(quota::kQuotaLimitTypeUnknown),
is_running_in_process_(host->IsRunningInProcess()),
open_flags_(0),
- weak_factory_(this) {
+ weak_factory_(this),
+ routing_id_(RenderThreadImpl::current()->GenerateRoutingID()) {
+ ChildThread::current()->AddRoute(routing_id_, this);
}
PepperFileIOHost::~PepperFileIOHost() {
OnHostMsgClose(NULL);
+ ChildThread::current()->RemoveRoute(routing_id_);
}
int32_t PepperFileIOHost::OnResourceMessageReceived(
@@ -187,6 +190,37 @@ int32_t PepperFileIOHost::OnResourceMessageReceived(
return PP_ERROR_FAILED;
}
+bool PepperFileIOHost::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PepperFileIOHost, msg)
+ IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PepperFileIOHost::OnAsyncFileOpened(
+ base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id) {
+ AsyncOpenFileCallback* callback =
+ pending_async_open_files_.Lookup(message_id);
+ DCHECK(callback);
+ pending_async_open_files_.Remove(message_id);
+
+ base::PlatformFile file =
+ IPC::PlatformFileForTransitToPlatformFile(file_for_transit);
+ callback->Run(error_code, base::PassPlatformFile(&file));
+ // Make sure we won't leak file handle if the requester has died.
+ if (file != base::kInvalidPlatformFileValue) {
+ base::FileUtilProxy::Close(
+ RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(),
+ file,
+ base::FileUtilProxy::StatusCallback());
+ }
+ delete callback;
+}
+
int32_t PepperFileIOHost::OnHostMsgOpen(
ppapi::host::HostMessageContext* context,
PP_Resource file_ref_resource,
@@ -229,20 +263,18 @@ int32_t PepperFileIOHost::OnHostMsgOpen(
weak_factory_.GetWeakPtr(),
context->MakeReplyMessageContext());
file_system_dispatcher->OpenFile(
- file_system_url_, platform_file_flags,
- base::Bind(&DidOpenFileSystemURL, callback),
- base::Bind(&DidFailOpenFileSystemURL, callback));
+ file_system_url_, platform_file_flags,
+ base::Bind(&DidOpenFileSystemURL, callback),
+ base::Bind(&DidFailOpenFileSystemURL, callback));
} else {
- PepperHelperImpl* helper = static_cast<PepperPluginInstanceImpl*>(
- PepperPluginInstance::Get(pp_instance()))->helper();
- if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL || !helper)
- return PP_ERROR_FAILED;
- if (!helper->AsyncOpenFile(
- file_ref->GetSystemPath(), open_flags,
- base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext())))
+ if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
return PP_ERROR_FAILED;
+ int message_id = pending_async_open_files_.Add(new AsyncOpenFileCallback(
+ base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
+ weak_factory_.GetWeakPtr(),
+ context->MakeReplyMessageContext())));
+ RenderThreadImpl::current()->Send(new ViewHostMsg_AsyncOpenPepperFile(
+ routing_id_, file_ref->GetSystemPath(), open_flags, message_id));
}
state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
diff --git a/content/renderer/pepper/pepper_file_io_host.h b/content/renderer/pepper/pepper_file_io_host.h
index 88596fe..1d3dbbd 100644
--- a/content/renderer/pepper/pepper_file_io_host.h
+++ b/content/renderer/pepper/pepper_file_io_host.h
@@ -10,9 +10,12 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/id_map.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_platform_file.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/shared_impl/file_io_state_manager.h"
@@ -26,7 +29,8 @@ namespace content {
class QuotaFileIO;
class PepperFileIOHost : public ppapi::host::ResourceHost,
- public base::SupportsWeakPtr<PepperFileIOHost> {
+ public base::SupportsWeakPtr<PepperFileIOHost>,
+ public IPC::Listener {
public:
typedef base::Callback<void (base::PlatformFileError)>
NotifyCloseFileCallback;
@@ -42,6 +46,14 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::host::HostMessageContext* context) OVERRIDE;
private:
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ void OnAsyncFileOpened(
+ base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id);
+
int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
PP_Resource file_ref_resource,
int32_t open_flags);
@@ -124,6 +136,13 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::FileIOStateManager state_manager_;
+ int routing_id_;
+
+ typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
+ AsyncOpenFileCallback;
+
+ IDMap<AsyncOpenFileCallback> pending_async_open_files_;
+
DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost);
};
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc
index 0a8a8ba..f1d7197 100644
--- a/content/renderer/pepper/pepper_graphics_2d_host.cc
+++ b/content/renderer/pepper/pepper_graphics_2d_host.cc
@@ -13,7 +13,6 @@
#include "content/renderer/pepper/gfx_conversion.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/ppb_image_data_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_rect.h"
diff --git a/content/renderer/pepper/pepper_helper_impl.cc b/content/renderer/pepper/pepper_helper_impl.cc
index 6742708..387b9ef 100644
--- a/content/renderer/pepper/pepper_helper_impl.cc
+++ b/content/renderer/pepper/pepper_helper_impl.cc
@@ -13,7 +13,6 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/files/file_util_proxy.h"
#include "base/logging.h"
#include "base/platform_file.h"
#include "base/strings/string_split.h"
@@ -38,6 +37,7 @@
#include "content/renderer/p2p/socket_dispatcher.h"
#include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
#include "content/renderer/pepper/host_dispatcher_wrapper.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_broker.h"
#include "content/renderer/pepper/pepper_browser_connection.h"
#include "content/renderer/pepper/pepper_file_system_host.h"
@@ -52,7 +52,6 @@
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/ppb_tcp_socket_private_impl.h"
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/pepper/url_response_info_util.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
@@ -117,9 +116,9 @@ void CreateHostForInProcessModule(RenderViewImpl* render_view,
PepperHelperImpl::PepperHelperImpl(RenderViewImpl* render_view)
: RenderViewObserver(render_view),
render_view_(render_view),
- pepper_browser_connection_(this),
focused_plugin_(NULL),
last_mouse_event_target_(NULL) {
+ new PepperBrowserConnection(render_view);
}
PepperHelperImpl::~PepperHelperImpl() {
@@ -495,7 +494,9 @@ void PepperHelperImpl::InstanceCreated(
instance->SetContentAreaFocus(render_view_->has_focus());
if (!instance->module()->IsProxied()) {
- pepper_browser_connection_.DidCreateInProcessInstance(
+ PepperBrowserConnection* browser_connection =
+ PepperBrowserConnection::Get(render_view_);
+ browser_connection->DidCreateInProcessInstance(
instance->pp_instance(),
render_view_->GetRoutingID(),
instance->container()->element().document().url(),
@@ -513,7 +514,9 @@ void PepperHelperImpl::InstanceDeleted(
PluginFocusChanged(instance, false);
if (!instance->module()->IsProxied()) {
- pepper_browser_connection_.DidDeleteInProcessInstance(
+ PepperBrowserConnection* browser_connection =
+ PepperBrowserConnection::Get(render_view_);
+ browser_connection->DidDeleteInProcessInstance(
instance->pp_instance());
}
}
@@ -523,7 +526,8 @@ PepperBroker* PepperHelperImpl::ConnectToBroker(
PPB_Broker_Impl* client) {
DCHECK(client);
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(client);
+ PluginModule* plugin_module =
+ HostGlobals::Get()->GetInstance(client->pp_instance())->module();
if (!plugin_module)
return NULL;
@@ -557,7 +561,8 @@ void PepperHelperImpl::OnPpapiBrokerPermissionResult(int request_id,
if (!client.get())
return;
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(client.get());
+ PluginModule* plugin_module =
+ HostGlobals::Get()->GetInstance(client->pp_instance())->module();
if (!plugin_module)
return;
@@ -565,37 +570,6 @@ void PepperHelperImpl::OnPpapiBrokerPermissionResult(int request_id,
broker->OnBrokerPermissionResult(client.get(), result);
}
-bool PepperHelperImpl::AsyncOpenFile(const base::FilePath& path,
- int pp_open_flags,
- const AsyncOpenFileCallback& callback) {
- int message_id = pending_async_open_files_.Add(
- new AsyncOpenFileCallback(callback));
- return Send(new ViewHostMsg_AsyncOpenPepperFile(
- routing_id(), path, pp_open_flags, message_id));
-}
-
-void PepperHelperImpl::OnAsyncFileOpened(
- base::PlatformFileError error_code,
- IPC::PlatformFileForTransit file_for_transit,
- int message_id) {
- AsyncOpenFileCallback* callback =
- pending_async_open_files_.Lookup(message_id);
- DCHECK(callback);
- pending_async_open_files_.Remove(message_id);
-
- base::PlatformFile file =
- IPC::PlatformFileForTransitToPlatformFile(file_for_transit);
- callback->Run(error_code, base::PassPlatformFile(&file));
- // Make sure we won't leak file handle if the requester has died.
- if (file != base::kInvalidPlatformFileValue) {
- base::FileUtilProxy::Close(
- RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(),
- file,
- base::FileUtilProxy::StatusCallback());
- }
- delete callback;
-}
-
void PepperHelperImpl::OnSetFocus(bool has_focus) {
for (std::set<PepperPluginInstanceImpl*>::iterator i =
active_instances_.begin();
@@ -625,19 +599,6 @@ void PepperHelperImpl::WillHandleMouseEvent() {
last_mouse_event_target_ = NULL;
}
-void PepperHelperImpl::RegisterTCPSocket(
- PPB_TCPSocket_Private_Impl* socket,
- uint32 socket_id) {
- tcp_sockets_.AddWithID(socket, socket_id);
-}
-
-void PepperHelperImpl::UnregisterTCPSocket(uint32 socket_id) {
- // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method
- // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress.
- if (tcp_sockets_.Lookup(socket_id))
- tcp_sockets_.Remove(socket_id);
-}
-
void PepperHelperImpl::HandleDocumentLoad(
PepperPluginInstanceImpl* instance,
const WebKit::WebURLResponse& response) {
@@ -714,22 +675,10 @@ void PepperHelperImpl::SampleGamepads(WebKit::WebGamepads* data) {
}
bool PepperHelperImpl::OnMessageReceived(const IPC::Message& message) {
- if (pepper_browser_connection_.OnMessageReceived(message))
- return true;
-
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PepperHelperImpl, message)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK,
- OnTCPSocketConnectACK)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
- OnTCPSocketSSLHandshakeACK)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK,
- OnTCPSocketSetOptionACK)
IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated,
OnPpapiBrokerChannelCreated)
- IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened)
IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult,
OnPpapiBrokerPermissionResult)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -743,62 +692,13 @@ void PepperHelperImpl::OnDestruct() {
// it's non-pointer member in RenderViewImpl.
}
-void PepperHelperImpl::OnTCPSocketConnectACK(
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) {
- PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id);
- if (socket)
- socket->OnConnectCompleted(result, local_addr, remote_addr);
- if (result != PP_OK)
- tcp_sockets_.Remove(socket_id);
-}
-
-void PepperHelperImpl::OnTCPSocketSSLHandshakeACK(
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- bool succeeded,
- const ppapi::PPB_X509Certificate_Fields& certificate_fields) {
- PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id);
- if (socket)
- socket->OnSSLHandshakeCompleted(succeeded, certificate_fields);
-}
-
-void PepperHelperImpl::OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result,
- const std::string& data) {
- PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id);
- if (socket)
- socket->OnReadCompleted(result, data);
-}
-
-void PepperHelperImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result) {
- PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id);
- if (socket)
- socket->OnWriteCompleted(result);
-}
-
-void PepperHelperImpl::OnTCPSocketSetOptionACK(
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result) {
- PPB_TCPSocket_Private_Impl* socket = tcp_sockets_.Lookup(socket_id);
- if (socket)
- socket->OnSetOptionCompleted(result);
-}
-
void PepperHelperImpl::DidDataFromWebURLResponse(
PP_Instance pp_instance,
const WebKit::WebURLResponse& response,
int pending_host_id,
const ppapi::URLResponseInfoData& data) {
PepperPluginInstanceImpl* instance =
- ResourceHelper::PPInstanceToPluginInstance(pp_instance);
+ HostGlobals::Get()->GetInstance(pp_instance);
if (!instance)
return;
diff --git a/content/renderer/pepper/pepper_helper_impl.h b/content/renderer/pepper/pepper_helper_impl.h
index 7545c79..f504f3c 100644
--- a/content/renderer/pepper/pepper_helper_impl.h
+++ b/content/renderer/pepper/pepper_helper_impl.h
@@ -5,26 +5,20 @@
#ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_
-#include <map>
#include <set>
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/id_map.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/observer_list.h"
#include "content/public/renderer/render_view_observer.h"
-#include "content/renderer/pepper/pepper_browser_connection.h"
#include "content/renderer/pepper_helper.h"
-#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/ppb_tcp_socket.h"
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
-#include "ppapi/shared_impl/url_response_info_data.h"
#include "ui/base/ime/text_input_type.h"
namespace base {
@@ -32,12 +26,8 @@ class FilePath;
}
namespace ppapi {
-class PepperFilePath;
class PpapiPermissions;
-class PPB_X509Certificate_Fields;
-namespace host {
-class ResourceHost;
-}
+struct URLResponseInfoData;
}
namespace WebKit {
@@ -53,7 +43,6 @@ class GamepadSharedMemoryReader;
class PepperBroker;
class PluginModule;
class PPB_Broker_Impl;
-class PPB_TCPSocket_Private_Impl;
class RenderViewImpl;
struct WebPluginInfo;
@@ -66,10 +55,6 @@ class PepperHelperImpl : public PepperHelper,
RenderViewImpl* render_view() { return render_view_; }
- PepperBrowserConnection* pepper_browser_connection() {
- return &pepper_browser_connection_;
- }
-
// A pointer is returned immediately, but it is not ready to be used until
// BrokerConnected has been called.
// The caller is responsible for calling Disconnect() on the returned pointer
@@ -79,10 +64,6 @@ class PepperHelperImpl : public PepperHelper,
// Removes broker from pending_connect_broker_ if present. Returns true if so.
bool StopWaitingForBrokerConnection(PepperBroker* broker);
- void RegisterTCPSocket(PPB_TCPSocket_Private_Impl* socket, uint32 socket_id);
- void UnregisterTCPSocket(uint32 socket_id);
- void TCPServerSocketStopListening(uint32 socket_id);
-
// Notifies that |instance| has changed the cursor.
// This will update the cursor appearance if it is currently over the plugin
// instance.
@@ -115,13 +96,6 @@ class PepperHelperImpl : public PepperHelper,
// from this call.
void InstanceDeleted(PepperPluginInstanceImpl* instance);
- // Sends an async IPC to open a local file.
- typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
- AsyncOpenFileCallback;
- bool AsyncOpenFile(const base::FilePath& path,
- int pp_open_flags,
- const AsyncOpenFileCallback& callback);
-
// Retrieve current gamepad data.
void SampleGamepads(WebKit::WebGamepads* data);
@@ -178,32 +152,9 @@ class PepperHelperImpl : public PepperHelper,
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnDestruct() OVERRIDE;
- void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr);
- void OnTCPSocketSSLHandshakeACK(
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- bool succeeded,
- const ppapi::PPB_X509Certificate_Fields& certificate_fields);
- void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result,
- const std::string& data);
- void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result);
- void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id,
- uint32 socket_id,
- int32_t result);
void OnPpapiBrokerChannelCreated(int request_id,
base::ProcessId broker_pid,
const IPC::ChannelHandle& handle);
- void OnAsyncFileOpened(base::PlatformFileError error_code,
- IPC::PlatformFileForTransit file_for_transit,
- int message_id);
void OnPpapiBrokerPermissionResult(int request_id, bool result);
// Attempts to create a PPAPI plugin for the given filepath. On success, it
@@ -242,16 +193,8 @@ class PepperHelperImpl : public PepperHelper,
// Pointer to the RenderView that owns us.
RenderViewImpl* render_view_;
- // Connection for sending and receiving pepper host-related messages to/from
- // the browser.
- PepperBrowserConnection pepper_browser_connection_;
-
std::set<PepperPluginInstanceImpl*> active_instances_;
- IDMap<AsyncOpenFileCallback> pending_async_open_files_;
-
- IDMap<PPB_TCPSocket_Private_Impl> tcp_sockets_;
-
typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap;
BrokerMap pending_connect_broker_;
diff --git a/content/renderer/pepper/ppb_audio_impl.cc b/content/renderer/pepper/ppb_audio_impl.cc
index ba9a836..3f1baca0 100644
--- a/content/renderer/pepper/ppb_audio_impl.cc
+++ b/content/renderer/pepper/ppb_audio_impl.cc
@@ -8,7 +8,6 @@
#include "content/renderer/pepper/common.h"
#include "content/renderer/pepper/pepper_platform_audio_output.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_view_impl.h"
#include "media/audio/audio_output_controller.h"
#include "ppapi/c/pp_completion_callback.h"
@@ -74,7 +73,7 @@ bool PPB_Audio_Impl::Init(PP_Resource config,
return false;
SetCallback(callback, user_data);
- PepperPluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this);
+ PepperPluginInstance* instance = PepperPluginInstance::Get(pp_instance());
if (!instance)
return false;
@@ -124,7 +123,7 @@ int32_t PPB_Audio_Impl::Open(
return PP_ERROR_FAILED;
config_ = config;
- PepperPluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this);
+ PepperPluginInstance* instance = PepperPluginInstance::Get(pp_instance());
if (!instance)
return PP_ERROR_FAILED;
diff --git a/content/renderer/pepper/ppb_broker_impl.cc b/content/renderer/pepper/ppb_broker_impl.cc
index 38943ae..3eba82a 100644
--- a/content/renderer/pepper/ppb_broker_impl.cc
+++ b/content/renderer/pepper/ppb_broker_impl.cc
@@ -6,11 +6,11 @@
#include "base/logging.h"
#include "content/renderer/pepper/common.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_broker.h"
#include "content/renderer/pepper/pepper_helper_impl.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/platform_file.h"
#include "third_party/WebKit/public/web/WebDocument.h"
@@ -56,7 +56,7 @@ int32_t PPB_Broker_Impl::Connect(
}
PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::GetPluginInstance(this);
+ HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
return PP_ERROR_FAILED;
@@ -84,7 +84,7 @@ int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) {
GURL PPB_Broker_Impl::GetDocumentUrl() {
PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::GetPluginInstance(this);
+ HostGlobals::Get()->GetInstance(pp_instance());
return plugin_instance->container()->element().document().url();
}
diff --git a/content/renderer/pepper/ppb_buffer_impl.cc b/content/renderer/pepper/ppb_buffer_impl.cc
index 11fa098..7c6ec83 100644
--- a/content/renderer/pepper/ppb_buffer_impl.cc
+++ b/content/renderer/pepper/ppb_buffer_impl.cc
@@ -9,7 +9,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "content/renderer/pepper/common.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/pp_errors.h"
diff --git a/content/renderer/pepper/ppb_file_ref_impl.cc b/content/renderer/pepper/ppb_file_ref_impl.cc
index 5f392ce..7044208 100644
--- a/content/renderer/pepper/ppb_file_ref_impl.cc
+++ b/content/renderer/pepper/ppb_file_ref_impl.cc
@@ -9,13 +9,12 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/child/fileapi/file_system_dispatcher.h"
+#include "content/common/view_messages.h"
#include "content/renderer/pepper/common.h"
#include "content/renderer/pepper/pepper_file_system_host.h"
#include "content/renderer/pepper/pepper_helper_impl.h"
-#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "net/base/escape.h"
#include "ppapi/c/pp_errors.h"
@@ -220,34 +219,41 @@ PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info,
PP_Resource file_system)
: PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info),
file_system_(file_system),
- external_file_system_path_() {
+ external_file_system_path_(),
+ routing_id_(MSG_ROUTING_NONE) {
+ if (RenderThreadImpl::current()) { // NULL in tests.
+ routing_id_ = RenderThreadImpl::current()->GenerateRoutingID();
+ ChildThread::current()->AddRoute(routing_id_, this);
+ }
}
PPB_FileRef_Impl::PPB_FileRef_Impl(const PPB_FileRef_CreateInfo& info,
const base::FilePath& external_file_path)
: PPB_FileRef_Shared(::ppapi::OBJECT_IS_IMPL, info),
file_system_(),
- external_file_system_path_(external_file_path) {
+ external_file_system_path_(external_file_path),
+ routing_id_(MSG_ROUTING_NONE) {
+ if (RenderThreadImpl::current()) { // NULL in tests.
+ routing_id_ = RenderThreadImpl::current()->GenerateRoutingID();
+ ChildThread::current()->AddRoute(routing_id_, this);
+ }
}
PPB_FileRef_Impl::~PPB_FileRef_Impl() {
+ if (RenderThreadImpl::current())
+ ChildThread::current()->RemoveRoute(routing_id_);
}
// static
PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Instance instance,
PP_Resource pp_file_system,
const std::string& path) {
- PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::PPInstanceToPluginInstance(instance);
- if (!plugin_instance || !plugin_instance->helper())
- return 0;
-
- PepperFileSystemHost* host = GetFileSystemHostInternal(
+ PepperFileSystemHost* fs_host = GetFileSystemHostInternal(
instance, pp_file_system);
- if (!host)
+ if (!fs_host)
return 0;
- PP_FileSystemType type = host->GetType();
+ PP_FileSystemType type = fs_host->GetType();
if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
type != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
type != PP_FILESYSTEMTYPE_EXTERNAL &&
@@ -422,6 +428,37 @@ GURL PPB_FileRef_Impl::GetFileSystemURL() const {
virtual_path.substr(1)));
}
+bool PPB_FileRef_Impl::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPB_FileRef_Impl, msg)
+ IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenPepperFile_ACK, OnAsyncFileOpened)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PPB_FileRef_Impl::OnAsyncFileOpened(
+ base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id) {
+ AsyncOpenFileCallback* callback =
+ pending_async_open_files_.Lookup(message_id);
+ DCHECK(callback);
+ pending_async_open_files_.Remove(message_id);
+
+ base::PlatformFile file =
+ IPC::PlatformFileForTransitToPlatformFile(file_for_transit);
+ callback->Run(error_code, base::PassPlatformFile(&file));
+ // Make sure we won't leak file handle if the requester has died.
+ if (file != base::kInvalidPlatformFileValue) {
+ base::FileUtilProxy::Close(
+ RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(),
+ file,
+ base::FileUtilProxy::StatusCallback());
+ }
+ delete callback;
+}
+
bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
PepperFileSystemHost* host = GetFileSystemHost();
return HasValidFileSystem() && host &&
@@ -442,11 +479,6 @@ int32_t PPB_FileRef_Impl::Query(PP_FileInfo* info,
int32_t PPB_FileRef_Impl::QueryInHost(
linked_ptr<PP_FileInfo> info,
scoped_refptr<TrackedCallback> callback) {
- scoped_refptr<PepperPluginInstanceImpl> plugin_instance =
- ResourceHelper::GetPluginInstance(this);
- if (!plugin_instance.get())
- return PP_ERROR_FAILED;
-
if (!file_system_) {
// External file system
// We have to do something totally different for external file systems.
@@ -454,11 +486,14 @@ int32_t PPB_FileRef_Impl::QueryInHost(
// TODO(teravest): Use the SequencedWorkerPool instead.
scoped_refptr<base::TaskRunner> task_runner =
RenderThreadImpl::current()->GetFileThreadMessageLoopProxy();
- if (!plugin_instance->helper()->AsyncOpenFile(
- GetSystemPath(),
- PP_FILEOPENFLAG_READ,
- base::Bind(&QueryCallback, task_runner, info, callback)))
- return PP_ERROR_FAILED;
+
+ int message_id = pending_async_open_files_.Add(new AsyncOpenFileCallback(
+ base::Bind(&QueryCallback, task_runner, info, callback)));
+ RenderThreadImpl::current()->Send(new ViewHostMsg_AsyncOpenPepperFile(
+ routing_id_,
+ GetSystemPath(),
+ PP_FILEOPENFLAG_READ,
+ message_id));
} else {
// Non-external file system
if (!HasValidFileSystem())
diff --git a/content/renderer/pepper/ppb_file_ref_impl.h b/content/renderer/pepper/ppb_file_ref_impl.h
index bca80c0..2dde933 100644
--- a/content/renderer/pepper/ppb_file_ref_impl.h
+++ b/content/renderer/pepper/ppb_file_ref_impl.h
@@ -8,8 +8,13 @@
#include <string>
#include <vector>
+#include "base/callback_forward.h"
#include "base/files/file_path.h"
+#include "base/id_map.h"
#include "base/memory/linked_ptr.h"
+#include "base/platform_file.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_platform_file.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/ppb_file_ref.h"
#include "ppapi/shared_impl/ppb_file_ref_shared.h"
@@ -29,7 +34,8 @@ using ::ppapi::StringVar;
class PepperFileSystemHost;
-class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared {
+class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared,
+ public IPC::Listener {
public:
PPB_FileRef_Impl(const ::ppapi::PPB_FileRef_CreateInfo& info,
PP_Resource file_system);
@@ -95,6 +101,14 @@ class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared {
private:
virtual ~PPB_FileRef_Impl();
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ void OnAsyncFileOpened(
+ base::PlatformFileError error_code,
+ IPC::PlatformFileForTransit file_for_transit,
+ int message_id);
+
// Many mutation functions are allow only to non-external filesystems, This
// function returns true if the filesystem is opened and isn't external as an
// access check for these functions.
@@ -126,6 +140,13 @@ class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared {
// return the identical string object every time it is requested.
scoped_refptr<StringVar> external_path_var_;
+ int routing_id_;
+
+ typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
+ AsyncOpenFileCallback;
+
+ IDMap<AsyncOpenFileCallback> pending_async_open_files_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl);
};
diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc
index 0c9cb10..6587781 100644
--- a/content/renderer/pepper/ppb_graphics_3d_impl.cc
+++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc
@@ -8,10 +8,10 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_platform_context_3d.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_view_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ppapi/c/ppp_graphics_3d.h"
@@ -205,7 +205,7 @@ int32 PPB_Graphics3D_Impl::DoSwapBuffers() {
//
// Don't need to check for NULL from GetPluginInstance since when we're
// bound, we know our instance is valid.
- ResourceHelper::GetPluginInstance(this)->CommitBackingTexture();
+ HostGlobals::Get()->GetInstance(pp_instance())->CommitBackingTexture();
commit_pending_ = true;
} else {
// Wait for the command to complete on the GPU to allow for throttling.
@@ -239,7 +239,7 @@ bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list) {
PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::GetPluginInstance(this);
+ HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
return false;
@@ -280,7 +280,7 @@ void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message,
if (!bound_to_instance_)
return;
WebPluginContainer* container =
- ResourceHelper::GetPluginInstance(this)->container();
+ HostGlobals::Get()->GetInstance(pp_instance())->container();
if (!container)
return;
WebFrame* frame = container->element().document().frame();
@@ -303,8 +303,10 @@ void PPB_Graphics3D_Impl::OnSwapBuffers() {
void PPB_Graphics3D_Impl::OnContextLost() {
// Don't need to check for NULL from GetPluginInstance since when we're
// bound, we know our instance is valid.
- if (bound_to_instance_)
- ResourceHelper::GetPluginInstance(this)->BindGraphics(pp_instance(), 0);
+ if (bound_to_instance_) {
+ HostGlobals::Get()->GetInstance(pp_instance())->BindGraphics(
+ pp_instance(), 0);
+ }
// Send context lost to plugin. This may have been caused by a PPAPI call, so
// avoid re-entering.
@@ -318,7 +320,8 @@ void PPB_Graphics3D_Impl::SendContextLost() {
// By the time we run this, the instance may have been deleted, or in the
// process of being deleted. Even in the latter case, we don't want to send a
// callback after DidDestroy.
- PepperPluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this);
+ PepperPluginInstanceImpl* instance =
+ HostGlobals::Get()->GetInstance(pp_instance());
if (!instance || !instance->container())
return;
diff --git a/content/renderer/pepper/ppb_image_data_impl.cc b/content/renderer/pepper/ppb_image_data_impl.cc
index c51d1d2..e79e83c 100644
--- a/content/renderer/pepper/ppb_image_data_impl.cc
+++ b/content/renderer/pepper/ppb_image_data_impl.cc
@@ -11,7 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/common/view_messages.h"
#include "content/renderer/pepper/common.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_instance.h"
@@ -255,9 +254,6 @@ bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl,
bool init_to_zero) {
skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
impl->width(), impl->height());
- PepperHelperImpl* plugin_delegate = ResourceHelper::GetHelper(impl);
- if (!plugin_delegate)
- return false;
shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer(
skia_bitmap_.getSize()).release());
return !!shared_memory_.get();
diff --git a/content/renderer/pepper/ppb_network_monitor_private_impl.cc b/content/renderer/pepper/ppb_network_monitor_private_impl.cc
index 44abb45..d43c8f0 100644
--- a/content/renderer/pepper/ppb_network_monitor_private_impl.cc
+++ b/content/renderer/pepper/ppb_network_monitor_private_impl.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "content/renderer/p2p/socket_dispatcher.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/shared_impl/ppb_network_list_private_shared.h"
#include "ppapi/shared_impl/private/net_address_private_impl.h"
diff --git a/content/renderer/pepper/ppb_scrollbar_impl.cc b/content/renderer/pepper/ppb_scrollbar_impl.cc
index d17a8ee..e3da676 100644
--- a/content/renderer/pepper/ppb_scrollbar_impl.cc
+++ b/content/renderer/pepper/ppb_scrollbar_impl.cc
@@ -9,10 +9,10 @@
#include "base/message_loop/message_loop.h"
#include "content/renderer/pepper/common.h"
#include "content/renderer/pepper/event_conversion.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/ppb_image_data_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/dev/ppp_scrollbar_dev.h"
#include "ppapi/thunk/thunk.h"
#include "skia/ext/platform_canvas.h"
@@ -53,12 +53,12 @@ PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {
void PPB_Scrollbar_Impl::Init(bool vertical) {
PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::GetPluginInstance(this);
+ HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
return;
scrollbar_.reset(WebPluginScrollbar::createForPlugin(
vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal,
- ResourceHelper::GetPluginInstance(this)->container(),
+ plugin_instance->container(),
static_cast<WebKit::WebPluginScrollbarClient*>(this)));
}
@@ -169,7 +169,8 @@ void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) {
}
void PPB_Scrollbar_Impl::valueChanged(WebKit::WebPluginScrollbar* scrollbar) {
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
+ PluginModule* plugin_module =
+ HostGlobals::Get()->GetInstance(pp_instance())->module();
if (!plugin_module)
return;
@@ -190,7 +191,8 @@ void PPB_Scrollbar_Impl::valueChanged(WebKit::WebPluginScrollbar* scrollbar) {
}
void PPB_Scrollbar_Impl::overlayChanged(WebPluginScrollbar* scrollbar) {
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
+ PluginModule* plugin_module =
+ HostGlobals::Get()->GetInstance(pp_instance())->module();
if (!plugin_module)
return;
diff --git a/content/renderer/pepper/ppb_tcp_socket_private_impl.cc b/content/renderer/pepper/ppb_tcp_socket_private_impl.cc
index c9e6087..0327203 100644
--- a/content/renderer/pepper/ppb_tcp_socket_private_impl.cc
+++ b/content/renderer/pepper/ppb_tcp_socket_private_impl.cc
@@ -8,7 +8,6 @@
#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_helper_impl.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/socket_option_data.h"
@@ -16,69 +15,42 @@
namespace content {
PPB_TCPSocket_Private_Impl::PPB_TCPSocket_Private_Impl(
- PP_Instance instance, uint32 socket_id)
- : ::ppapi::TCPSocketPrivateImpl(instance, socket_id) {
+ PP_Instance instance,
+ uint32 socket_id,
+ int routing_id)
+ : ::ppapi::TCPSocketPrivateImpl(instance, socket_id),
+ routing_id_(routing_id) {
+ ChildThread::current()->AddRoute(routing_id, this);
}
PPB_TCPSocket_Private_Impl::~PPB_TCPSocket_Private_Impl() {
+ ChildThread::current()->RemoveRoute(routing_id_);
Disconnect();
}
PP_Resource PPB_TCPSocket_Private_Impl::CreateResource(PP_Instance instance) {
- PepperHelperImpl* helper = GetHelper(instance);
- if (!helper)
- return 0;
-
+ int routing_id = RenderThreadImpl::current()->GenerateRoutingID();
uint32 socket_id = 0;
- helper->Send(new PpapiHostMsg_PPBTCPSocket_CreatePrivate(
- helper->routing_id(), 0, &socket_id));
+ RenderThreadImpl::current()->Send(new PpapiHostMsg_PPBTCPSocket_CreatePrivate(
+ routing_id, 0, &socket_id));
if (!socket_id)
return 0;
- return (new PPB_TCPSocket_Private_Impl(instance, socket_id))->GetReference();
-}
-
-PP_Resource PPB_TCPSocket_Private_Impl::CreateConnectedSocket(
- PP_Instance instance,
- uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) {
- PepperHelperImpl* helper = GetHelper(instance);
- if (!helper)
- return 0;
-
- PPB_TCPSocket_Private_Impl* socket =
- new PPB_TCPSocket_Private_Impl(instance, socket_id);
-
- socket->connection_state_ = PPB_TCPSocket_Private_Impl::CONNECTED;
- socket->local_addr_ = local_addr;
- socket->remote_addr_ = remote_addr;
-
- helper->RegisterTCPSocket(socket, socket_id);
-
- return socket->GetReference();
+ return (new PPB_TCPSocket_Private_Impl(
+ instance, socket_id, routing_id))->GetReference();
}
void PPB_TCPSocket_Private_Impl::SendConnect(const std::string& host,
uint16_t port) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->RegisterTCPSocket(this, socket_id_);
- helper->Send(new PpapiHostMsg_PPBTCPSocket_Connect(
- helper->routing_id(), socket_id_, host, port));
+ RenderThreadImpl::current()->Send(new PpapiHostMsg_PPBTCPSocket_Connect(
+ routing_id_, socket_id_, host, port));
}
void PPB_TCPSocket_Private_Impl::SendConnectWithNetAddress(
const PP_NetAddress_Private& addr) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->RegisterTCPSocket(this, socket_id_);
- helper->Send(new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(
- helper->routing_id(), socket_id_, addr));
+ RenderThreadImpl::current()->Send(
+ new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(
+ routing_id_, socket_id_, addr));
}
void PPB_TCPSocket_Private_Impl::SendSSLHandshake(
@@ -86,58 +58,85 @@ void PPB_TCPSocket_Private_Impl::SendSSLHandshake(
uint16_t server_port,
const std::vector<std::vector<char> >& trusted_certs,
const std::vector<std::vector<char> >& untrusted_certs) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
+ RenderThreadImpl::current()->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
socket_id_, server_name, server_port, trusted_certs, untrusted_certs));
}
void PPB_TCPSocket_Private_Impl::SendRead(int32_t bytes_to_read) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->Send(new PpapiHostMsg_PPBTCPSocket_Read(
+ RenderThreadImpl::current()->Send(new PpapiHostMsg_PPBTCPSocket_Read(
socket_id_, bytes_to_read));
}
void PPB_TCPSocket_Private_Impl::SendWrite(const std::string& buffer) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->Send(new PpapiHostMsg_PPBTCPSocket_Write(
- socket_id_, buffer));
+ RenderThreadImpl::current()->Send(
+ new PpapiHostMsg_PPBTCPSocket_Write(socket_id_, buffer));
}
void PPB_TCPSocket_Private_Impl::SendDisconnect() {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
-
- helper->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_));
+ RenderThreadImpl::current()->Send(
+ new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_));
}
void PPB_TCPSocket_Private_Impl::SendSetOption(
PP_TCPSocket_Option name,
const ::ppapi::SocketOptionData& value) {
- PepperHelperImpl* helper = GetHelper(pp_instance());
- if (!helper)
- return;
+ RenderThreadImpl::current()->Send(
+ new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id_, name, value));
+}
+
+bool PPB_TCPSocket_Private_Impl::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Impl, message)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, OnTCPSocketConnectACK)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK,
+ OnTCPSocketSSLHandshakeACK)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK,
+ OnTCPSocketSetOptionACK)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PPB_TCPSocket_Private_Impl::OnTCPSocketConnectACK(
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result,
+ const PP_NetAddress_Private& local_addr,
+ const PP_NetAddress_Private& remote_addr) {
+ OnConnectCompleted(result, local_addr, remote_addr);
+}
+
+void PPB_TCPSocket_Private_Impl::OnTCPSocketSSLHandshakeACK(
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ bool succeeded,
+ const ppapi::PPB_X509Certificate_Fields& certificate_fields) {
+ OnSSLHandshakeCompleted(succeeded, certificate_fields);
+}
- helper->Send(new PpapiHostMsg_PPBTCPSocket_SetOption(
- socket_id_, name, value));
+void PPB_TCPSocket_Private_Impl::OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result,
+ const std::string& data) {
+ OnReadCompleted(result, data);
}
-PepperHelperImpl* PPB_TCPSocket_Private_Impl::GetHelper(PP_Instance instance) {
- PepperPluginInstanceImpl* plugin_instance =
- HostGlobals::Get()->GetInstance(instance);
- if (!plugin_instance)
- return NULL;
- return plugin_instance->helper();
+void PPB_TCPSocket_Private_Impl::OnTCPSocketWriteACK(
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result) {
+ OnWriteCompleted(result);
+}
+
+void PPB_TCPSocket_Private_Impl::OnTCPSocketSetOptionACK(
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result) {
+ OnSetOptionCompleted(result);
}
} // namespace content
diff --git a/content/renderer/pepper/ppb_tcp_socket_private_impl.h b/content/renderer/pepper/ppb_tcp_socket_private_impl.h
index aea82cb..ae53a6e 100644
--- a/content/renderer/pepper/ppb_tcp_socket_private_impl.h
+++ b/content/renderer/pepper/ppb_tcp_socket_private_impl.h
@@ -8,20 +8,15 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "ipc/ipc_listener.h"
#include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
namespace content {
-class PepperHelperImpl;
-
-class PPB_TCPSocket_Private_Impl : public ::ppapi::TCPSocketPrivateImpl {
+class PPB_TCPSocket_Private_Impl : public ::ppapi::TCPSocketPrivateImpl,
+ public IPC::Listener {
public:
static PP_Resource CreateResource(PP_Instance instance);
- static PP_Resource CreateConnectedSocket(
- PP_Instance instance,
- uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr);
virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE;
virtual void SendConnectWithNetAddress(
@@ -38,10 +33,36 @@ class PPB_TCPSocket_Private_Impl : public ::ppapi::TCPSocketPrivateImpl {
const ::ppapi::SocketOptionData& value) OVERRIDE;
private:
- PPB_TCPSocket_Private_Impl(PP_Instance instance, uint32 socket_id);
+ PPB_TCPSocket_Private_Impl(PP_Instance instance,
+ uint32 socket_id,
+ int routing_id);
virtual ~PPB_TCPSocket_Private_Impl();
- static PepperHelperImpl* GetHelper(PP_Instance instance);
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result,
+ const PP_NetAddress_Private& local_addr,
+ const PP_NetAddress_Private& remote_addr);
+ void OnTCPSocketSSLHandshakeACK(
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ bool succeeded,
+ const ppapi::PPB_X509Certificate_Fields& certificate_fields);
+ void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result,
+ const std::string& data);
+ void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result);
+ void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ int32_t result);
+
+ int routing_id_;
DISALLOW_COPY_AND_ASSIGN(PPB_TCPSocket_Private_Impl);
};
diff --git a/content/renderer/pepper/ppb_video_decoder_impl.cc b/content/renderer/pepper/ppb_video_decoder_impl.cc
index 647d6da..06999c9 100644
--- a/content/renderer/pepper/ppb_video_decoder_impl.cc
+++ b/content/renderer/pepper/ppb_video_decoder_impl.cc
@@ -11,12 +11,13 @@
#include "base/metrics/histogram.h"
#include "content/renderer/media/pepper_platform_video_decoder.h"
#include "content/renderer/pepper/common.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_helper_impl.h"
#include "content/renderer/pepper/pepper_platform_context_3d.h"
+#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/ppb_buffer_impl.h"
#include "content/renderer/pepper/ppb_graphics_3d_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "media/video/picture.h"
#include "media/video/video_decode_accelerator.h"
@@ -98,7 +99,8 @@ namespace content {
PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance)
: PPB_VideoDecoder_Shared(instance),
ppp_videodecoder_(NULL) {
- PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
+ PluginModule* plugin_module =
+ HostGlobals::Get()->GetInstance(pp_instance())->module();
if (plugin_module) {
ppp_videodecoder_ = static_cast<const PPP_VideoDecoder_Dev*>(
plugin_module->GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
diff --git a/content/renderer/pepper/ppb_widget_impl.cc b/content/renderer/pepper/ppb_widget_impl.cc
index 39cdf4a..eaeae43 100644
--- a/content/renderer/pepper/ppb_widget_impl.cc
+++ b/content/renderer/pepper/ppb_widget_impl.cc
@@ -4,10 +4,10 @@
#include "content/renderer/pepper/ppb_widget_impl.h"
+#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/ppb_image_data_impl.h"
#include "content/renderer/pepper/plugin_module.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_input_event_api.h"
@@ -65,7 +65,7 @@ void PPB_Widget_Impl::SetScale(float scale) {
void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) {
PepperPluginInstanceImpl* plugin_instance =
- ResourceHelper::GetPluginInstance(this);
+ HostGlobals::Get()->GetInstance(pp_instance());
if (!plugin_instance)
return;
const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>(
diff --git a/content/renderer/pepper/quota_file_io.cc b/content/renderer/pepper/quota_file_io.cc
index 59000a2..a5e4f6b 100644
--- a/content/renderer/pepper/quota_file_io.cc
+++ b/content/renderer/pepper/quota_file_io.cc
@@ -13,7 +13,6 @@
#include "base/stl_util.h"
#include "base/task_runner_util.h"
#include "content/renderer/pepper/host_globals.h"
-#include "content/renderer/pepper/resource_helper.h"
using base::PlatformFile;
using base::PlatformFileError;
diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.cc b/content/renderer/pepper/renderer_ppapi_host_impl.cc
index b9069e4..e110535 100644
--- a/content/renderer/pepper/renderer_ppapi_host_impl.cc
+++ b/content/renderer/pepper/renderer_ppapi_host_impl.cc
@@ -122,21 +122,6 @@ RendererPpapiHostImpl::CreateInProcessResourceCreationAPI(
new PepperInProcessResourceCreation(this, instance));
}
-PepperBrowserConnection*
-RendererPpapiHostImpl::GetBrowserConnection(PP_Instance instance) const {
- PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance);
- if (!instance_object)
- return NULL;
-
- // Since we're the embedder, we can make assumptions about the helper on
- // the instance.
- PepperHelperImpl* helper = instance_object->helper();
- if (!helper)
- return NULL;
-
- return helper->pepper_browser_connection();
-}
-
PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl(
PP_Instance instance) const {
return GetAndValidateInstance(instance);
@@ -245,8 +230,10 @@ void RendererPpapiHostImpl::CreateBrowserResourceHost(
PP_Instance instance,
const IPC::Message& nested_msg,
const base::Callback<void(int)>& callback) const {
- PepperBrowserConnection* browser_connection = GetBrowserConnection(instance);
- if (browser_connection == NULL) {
+ RenderView* render_view = GetRenderViewForInstance(instance);
+ PepperBrowserConnection* browser_connection =
+ PepperBrowserConnection::Get(render_view);
+ if (!browser_connection) {
callback.Run(0);
} else {
browser_connection->SendBrowserCreate(module_->GetPluginChildId(),
diff --git a/content/renderer/pepper/renderer_ppapi_host_impl.h b/content/renderer/pepper/renderer_ppapi_host_impl.h
index beeb40f..4ef47bd 100644
--- a/content/renderer/pepper/renderer_ppapi_host_impl.h
+++ b/content/renderer/pepper/renderer_ppapi_host_impl.h
@@ -29,7 +29,6 @@ class ResourceCreationAPI;
namespace content {
-class PepperBrowserConnection;
class PepperInProcessRouter;
class PepperPluginInstanceImpl;
class PluginModule;
@@ -72,8 +71,6 @@ class RendererPpapiHostImpl : public RendererPpapiHost {
scoped_ptr< ::ppapi::thunk::ResourceCreationAPI>
CreateInProcessResourceCreationAPI(PepperPluginInstanceImpl* instance);
- PepperBrowserConnection* GetBrowserConnection(PP_Instance instance) const;
-
PepperPluginInstanceImpl* GetPluginInstanceImpl(PP_Instance instance) const;
// RendererPpapiHost implementation.
diff --git a/content/renderer/pepper/resource_creation_impl.cc b/content/renderer/pepper/resource_creation_impl.cc
index 93cf52f..d2ddd30 100644
--- a/content/renderer/pepper/resource_creation_impl.cc
+++ b/content/renderer/pepper/resource_creation_impl.cc
@@ -17,7 +17,6 @@
#include "content/renderer/pepper/ppb_tcp_socket_private_impl.h"
#include "content/renderer/pepper/ppb_video_decoder_impl.h"
#include "content/renderer/pepper/ppb_x509_certificate_private_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/shared_impl/ppb_audio_config_shared.h"
#include "ppapi/shared_impl/ppb_image_data_shared.h"
diff --git a/content/renderer/pepper/resource_helper.cc b/content/renderer/pepper/resource_helper.cc
deleted file mode 100644
index 8a4e9dd..0000000
--- a/content/renderer/pepper/resource_helper.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/pepper/resource_helper.h"
-
-#include "base/logging.h"
-#include "content/renderer/pepper/host_globals.h"
-#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
-#include "content/renderer/pepper/plugin_module.h"
-#include "ppapi/shared_impl/resource.h"
-
-namespace content {
-
-// static
-PepperPluginInstanceImpl* ResourceHelper::GetPluginInstance(
- const ::ppapi::Resource* resource) {
- return PPInstanceToPluginInstance(resource->pp_instance());
-}
-
-PepperPluginInstanceImpl* ResourceHelper::PPInstanceToPluginInstance(
- PP_Instance instance) {
- return HostGlobals::Get()->GetInstance(instance);
-}
-
-PluginModule* ResourceHelper::GetPluginModule(
- const ::ppapi::Resource* resource) {
- PepperPluginInstanceImpl* instance = GetPluginInstance(resource);
- return instance ? instance->module() : NULL;
-}
-
-PepperHelperImpl* ResourceHelper::GetHelper(const ::ppapi::Resource* resource) {
- PepperPluginInstanceImpl* instance = GetPluginInstance(resource);
- return instance ? instance->helper() : NULL;
-}
-
-} // namespace content
-
diff --git a/content/renderer/pepper/resource_helper.h b/content/renderer/pepper/resource_helper.h
deleted file mode 100644
index a4c6397..0000000
--- a/content/renderer/pepper/resource_helper.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_PEPPER_RESOURCE_HELPER_H_
-#define CONTENT_RENDERER_PEPPER_RESOURCE_HELPER_H_
-
-#include "base/basictypes.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_resource.h"
-
-namespace ppapi {
-class Resource;
-}
-
-namespace content {
-
-class PepperHelperImpl;
-class PepperPluginInstanceImpl;
-class PluginModule;
-
-// Helper functions for Resoruce implementations.
-//
-// This is specifically not designed to be a base class that derives from
-// ppapi::Resource to avoid diamond inheritance if most of a resource class
-// is implemented in the shared_impl (to share code with the proxy).
-class ResourceHelper {
- public:
- // Returns the instance implementation object for the given resource, or NULL
- // if the resource has outlived its instance.
- static PepperPluginInstanceImpl* GetPluginInstance(
- const ::ppapi::Resource* resource);
-
- // Returns the module for the given resource, or NULL if the resource has
- // outlived its instance.
- static PluginModule* GetPluginModule(const ::ppapi::Resource* resource);
-
- // Returns the plugin delegate for the given resource, or NULL if the
- // resource has outlived its instance.
- static PepperHelperImpl* GetHelper(const ::ppapi::Resource* resource);
-
- // Returns the instance implementation object for the pp_instance.
- static PepperPluginInstanceImpl* PPInstanceToPluginInstance(
- PP_Instance instance);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceHelper);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_PEPPER_RESOURCE_IMPL_HELPER_H_
diff --git a/content/renderer/pepper/url_request_info_util.cc b/content/renderer/pepper/url_request_info_util.cc
index 1948e75..9f13fe0 100644
--- a/content/renderer/pepper/url_request_info_util.cc
+++ b/content/renderer/pepper/url_request_info_util.cc
@@ -10,7 +10,6 @@
#include "content/renderer/pepper/common.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/ppb_file_ref_impl.h"
-#include "content/renderer/pepper/resource_helper.h"
#include "content/renderer/render_thread_impl.h"
#include "net/http/http_util.h"
#include "ppapi/shared_impl/url_request_info_data.h"
@@ -58,10 +57,6 @@ bool AppendFileRefToBody(
const PPB_FileRef_Impl* file_ref =
static_cast<PPB_FileRef_Impl*>(file_ref_api);
- PepperHelperImpl* helper = ResourceHelper::GetHelper(file_ref_resource);
- if (!helper)
- return false;
-
base::FilePath platform_path;
switch (file_ref->GetFileSystemType()) {
case PP_FILESYSTEMTYPE_LOCALTEMPORARY: