diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 05:38:42 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-21 05:38:42 +0000 |
commit | f9132e9700af6f4ff57fc7b063ff6fe27299f30a (patch) | |
tree | 790452cfd462454fea49d3d5e8a8b268dcf8e284 /content | |
parent | 91065c3b1bc6f188a00191ea75a0cd2ccd975270 (diff) | |
download | chromium_src-f9132e9700af6f4ff57fc7b063ff6fe27299f30a.zip chromium_src-f9132e9700af6f4ff57fc7b063ff6fe27299f30a.tar.gz chromium_src-f9132e9700af6f4ff57fc7b063ff6fe27299f30a.tar.bz2 |
Revert 189376 "Revert 189298 "Remove NaCl usage in content PPAPI..."
The revert was speculative and mistaken.
> Revert 189298 "Remove NaCl usage in content PPAPI code."
>
> This appears to have caused some errors in Linux bots, such as:
> http://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29/builds/24087/steps/browser_tests/logs/FileIO
>
> The error is ReadWriteSetLengthForceAsync FAIL: FileIO::SetLength failed with error: -2, ReadToArrayWriteSetLengthForceAsync FAIL: FileIO::SetLength failed with error: -2, WillWriteWillSetLengthForceAsync FAIL: FileIO::SetLength failed with error: -2"
>
> > Remove NaCl usage in content PPAPI code.
> >
> > BUG=191682
> > Review URL: https://codereview.chromium.org/12566036
>
> TBR=jam@chromium.org
> Review URL: https://codereview.chromium.org/12661004
TBR=xusydoc@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
13 files changed, 68 insertions, 66 deletions
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index e91b2b4..369140a7 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -202,13 +202,11 @@ PpapiPluginProcessHost::PpapiPluginProcessHost( process_.reset(new BrowserChildProcessHostImpl( PROCESS_TYPE_PPAPI_PLUGIN, this)); - filter_ = new PepperMessageFilter(process_->GetData().type, - permissions_, - host_resolver); + filter_ = new PepperMessageFilter(permissions_, host_resolver); host_impl_.reset(new BrowserPpapiHostImpl(this, permissions_, info.name, profile_data_directory, - process_->GetData().type)); + false)); process_->GetHost()->AddFilter(filter_.get()); process_->GetHost()->AddFilter(host_impl_->message_filter()); @@ -232,7 +230,7 @@ PpapiPluginProcessHost::PpapiPluginProcessHost() base::FilePath profile_data_directory; host_impl_.reset(new BrowserPpapiHostImpl(this, permissions, plugin_name, profile_data_directory, - process_->GetData().type)); + false)); } bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc index 5337874..ff4284a 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc @@ -30,12 +30,11 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( BrowserPpapiHostImpl* browser_ppapi_host = new BrowserPpapiHostImpl(sender, permissions, plugin_name, profile_data_directory, - PROCESS_TYPE_NACL_LOADER); + true); browser_ppapi_host->set_plugin_process_handle(plugin_child_process); channel->AddFilter( - new PepperMessageFilter(PROCESS_TYPE_NACL_LOADER, - permissions, + new PepperMessageFilter(permissions, host_resolver, render_process_id, render_view_id)); @@ -50,12 +49,12 @@ BrowserPpapiHostImpl::BrowserPpapiHostImpl( const ppapi::PpapiPermissions& permissions, const std::string& plugin_name, const base::FilePath& profile_data_directory, - ProcessType plugin_process_type) + bool external_plugin) : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), plugin_process_handle_(base::kNullProcessHandle), plugin_name_(plugin_name), profile_data_directory_(profile_data_directory), - plugin_process_type_(plugin_process_type) { + external_plugin_(external_plugin) { message_filter_ = new HostMessageFilter(ppapi_host_.get()); ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( new ContentBrowserPepperHostFactory(this))); diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h index 626866b..4254833 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h @@ -27,11 +27,13 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { // The creator is responsible for calling set_plugin_process_handle as soon // as it is known (we start the process asynchronously so it won't be known // when this object is created). + // |external_plugin| signfies that this is a proxy created for an embedder's + // plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess. BrowserPpapiHostImpl(IPC::Sender* sender, const ppapi::PpapiPermissions& permissions, const std::string& plugin_name, const base::FilePath& profile_data_directory, - ProcessType plugin_process_type); + bool external_plugin); virtual ~BrowserPpapiHostImpl(); // BrowserPpapiHost. @@ -50,7 +52,7 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { plugin_process_handle_ = handle; } - ProcessType plugin_process_type() { return plugin_process_type_; } + bool external_plugin() { return external_plugin_; } // These two functions are notifications that an instance has been created // or destroyed. They allow us to maintain a mapping of PP_Instance to data @@ -88,7 +90,10 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost { base::ProcessHandle plugin_process_handle_; std::string plugin_name_; base::FilePath profile_data_directory_; - ProcessType plugin_process_type_; + + // If true, this is an external plugin, i.e. created by the embedder using + // BrowserPpapiHost::CreateExternalPluginProcess. + bool external_plugin_; // Tracks all PP_Instances in this plugin and associated renderer-related // data. diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc index 0f0b9bd..75a2725 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc @@ -16,7 +16,7 @@ BrowserPpapiHostTest::BrowserPpapiHostTest() ppapi::PpapiPermissions::AllPermissions(), std::string(), base::FilePath(), - PROCESS_TYPE_UNKNOWN)); + false)); ppapi_host_->set_plugin_process_handle(base::GetCurrentProcessHandle()); } diff --git a/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.cc b/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.cc index c04aafe..d42cb56 100644 --- a/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.cc @@ -79,7 +79,7 @@ void CreateNetAddressListFromAddressList( PepperHostResolverPrivateMessageFilter::PepperHostResolverPrivateMessageFilter( BrowserPpapiHostImpl* host, PP_Instance instance) - : plugin_process_type_(host->plugin_process_type()), + : external_plugin_(host->external_plugin()), render_process_id_(0), render_view_id_(0) { DCHECK(host); @@ -126,7 +126,7 @@ int32_t PepperHostResolverPrivateMessageFilter::OnMsgResolve( RenderViewHost* render_view_host = RenderViewHost::FromID(render_process_id_, render_view_id_); if (!render_view_host || - !pepper_socket_utils::CanUseSocketAPIs(plugin_process_type_, + !pepper_socket_utils::CanUseSocketAPIs(external_plugin_, request, render_view_host)) { return PP_ERROR_FAILED; diff --git a/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.h b/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.h index 829ad5a5..9b34cd0 100644 --- a/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_host_resolver_private_message_filter.h @@ -74,7 +74,7 @@ class CONTENT_EXPORT PepperHostResolverPrivateMessageFilter const ppapi::host::ReplyMessageContext& context); void SendResolveError(const ppapi::host::ReplyMessageContext& context); - ProcessType plugin_process_type_; + bool external_plugin_; int render_process_id_; int render_view_id_; diff --git a/content/browser/renderer_host/pepper/pepper_message_filter.cc b/content/browser/renderer_host/pepper/pepper_message_filter.cc index 4654898..069678c 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_message_filter.cc @@ -49,17 +49,15 @@ const uint32 kInvalidSocketID = 0; } // namespace -PepperMessageFilter::PepperMessageFilter(ProcessType process_type, - int process_id, +PepperMessageFilter::PepperMessageFilter(int process_id, BrowserContext* browser_context) - : process_type_(process_type), + : plugin_type_(PLUGIN_TYPE_IN_PROCESS), permissions_(), process_id_(process_id), - nacl_render_view_id_(0), + external_plugin_render_view_id_(0), resource_context_(browser_context->GetResourceContext()), host_resolver_(NULL), next_socket_id_(1) { - DCHECK(process_type == PROCESS_TYPE_RENDERER); DCHECK(browser_context); // Keep BrowserContext data in FILE-thread friendly storage. browser_path_ = browser_context->GetPath(); @@ -68,35 +66,31 @@ PepperMessageFilter::PepperMessageFilter(ProcessType process_type, } PepperMessageFilter::PepperMessageFilter( - ProcessType process_type, const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver) - : process_type_(process_type), + : plugin_type_(PLUGIN_TYPE_OUT_OF_PROCESS), permissions_(permissions), process_id_(0), - nacl_render_view_id_(0), + external_plugin_render_view_id_(0), resource_context_(NULL), host_resolver_(host_resolver), next_socket_id_(1), incognito_(false) { - DCHECK(process_type == PROCESS_TYPE_PPAPI_PLUGIN); DCHECK(host_resolver); } PepperMessageFilter::PepperMessageFilter( - ProcessType process_type, const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver, int process_id, int render_view_id) - : process_type_(process_type), + : plugin_type_(PLUGIN_TYPE_EXTERNAL_PLUGIN), permissions_(permissions), process_id_(process_id), - nacl_render_view_id_(render_view_id), + external_plugin_render_view_id_(render_view_id), resource_context_(NULL), host_resolver_(host_resolver), next_socket_id_(1) { - DCHECK(process_type == PROCESS_TYPE_NACL_LOADER); DCHECK(host_resolver); } @@ -407,7 +401,7 @@ void PepperMessageFilter::OnTCPServerAccept(int32 tcp_client_socket_routing_id, void PepperMessageFilter::OnNetworkMonitorStart(uint32 plugin_dispatcher_id) { // Support all in-process plugins, and ones with "private" permissions. - if (process_type_ != PROCESS_TYPE_RENDERER && + if (plugin_type_ != PLUGIN_TYPE_IN_PROCESS && !permissions_.HasPermission(ppapi::PERMISSION_PRIVATE)) { return; } @@ -421,7 +415,7 @@ void PepperMessageFilter::OnNetworkMonitorStart(uint32 plugin_dispatcher_id) { void PepperMessageFilter::OnNetworkMonitorStop(uint32 plugin_dispatcher_id) { // Support all in-process plugins, and ones with "private" permissions. - if (process_type_ != PROCESS_TYPE_RENDERER && + if (plugin_type_ != PLUGIN_TYPE_IN_PROCESS && !permissions_.HasPermission(ppapi::PERMISSION_PRIVATE)) { return; } @@ -470,16 +464,19 @@ bool PepperMessageFilter::CanUseSocketAPIs(int32 render_id, const content::SocketPermissionRequest& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - // NACL plugins always get their own PepperMessageFilter, initialized with + // External plugins always get their own PepperMessageFilter, initialized with // a render view id. Use this instead of the one that came with the message, // which is actually an API ID. - if (process_type_ == PROCESS_TYPE_NACL_LOADER) - render_id = nacl_render_view_id_; + bool external_plugin = false; + if (plugin_type_ == PLUGIN_TYPE_EXTERNAL_PLUGIN) { + external_plugin = true; + render_id = external_plugin_render_view_id_; + } RenderViewHostImpl* render_view_host = RenderViewHostImpl::FromID(process_id_, render_id); - return pepper_socket_utils::CanUseSocketAPIs(process_type_, + return pepper_socket_utils::CanUseSocketAPIs(external_plugin, params, render_view_host); } diff --git a/content/browser/renderer_host/pepper/pepper_message_filter.h b/content/browser/renderer_host/pepper/pepper_message_filter.h index 2494b6e..cb8f0e0 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_message_filter.h @@ -58,22 +58,17 @@ class PepperMessageFilter : public BrowserMessageFilter, public net::NetworkChangeNotifier::IPAddressObserver { public: - // Constructor when used in the context of a render process (the argument is - // provided for sanity checking and must be PROCESS_TYPE_RENDERER). - PepperMessageFilter(ProcessType process_type, - int process_id, + // Constructor when used in the context of a render process. + PepperMessageFilter(int process_id, BrowserContext* browser_context); - // Constructor when used in the context of a PPAPI process (the argument is - // provided for sanity checking and must be PROCESS_TYPE_PPAPI_PLUGIN). - PepperMessageFilter(ProcessType process_type, - const ppapi::PpapiPermissions& permissions, + // Constructor when used in the context of a PPAPI process.. + PepperMessageFilter(const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver); - // Constructor when used in the context of a NaCl process (the argument is - // provided for sanity checking and must be PROCESS_TYPE_NACL_LOADER). - PepperMessageFilter(ProcessType process_type, - const ppapi::PpapiPermissions& permissions, + // Constructor when used in the context of an external plugin, i.e. created by + // the embedder using BrowserPpapiHost::CreateExternalPluginProcess. + PepperMessageFilter(const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver, int process_id, int render_view_id); @@ -186,7 +181,15 @@ class PepperMessageFilter void DoGetNetworkList(); void SendNetworkList(scoped_ptr<net::NetworkInterfaceList> list); - ProcessType process_type_; + enum PluginType { + PLUGIN_TYPE_IN_PROCESS, + PLUGIN_TYPE_OUT_OF_PROCESS, + // External plugin means it was created through + // BrowserPpapiHost::CreateExternalPluginProcess. + PLUGIN_TYPE_EXTERNAL_PLUGIN, + }; + + PluginType plugin_type_; // When attached to an out-of-process plugin (be it native or NaCl) this // will have the Pepper permissions for the plugin. When attached to the @@ -197,10 +200,10 @@ class PepperMessageFilter // Render process ID. int process_id_; - // NACL RenderView id to determine private API access. Normally, we handle - // messages coming from multiple RenderViews, but NaClProcessHost always - // creates a new PepperMessageFilter for each RenderView. - int nacl_render_view_id_; + // External plugin RenderView id to determine private API access. Normally, we + // handle messages coming from multiple RenderViews, but external plugins + // always creates a new PepperMessageFilter for each RenderView. + int external_plugin_render_view_id_; // When non-NULL, this should be used instead of the host_resolver_. ResourceContext* const resource_context_; diff --git a/content/browser/renderer_host/pepper/pepper_socket_utils.cc b/content/browser/renderer_host/pepper/pepper_socket_utils.cc index b5e43b3..69e6ddc 100644 --- a/content/browser/renderer_host/pepper/pepper_socket_utils.cc +++ b/content/browser/renderer_host/pepper/pepper_socket_utils.cc @@ -32,13 +32,15 @@ SocketPermissionRequest CreateSocketPermissionRequest( return SocketPermissionRequest(type, host, port); } -bool CanUseSocketAPIs(ProcessType plugin_process_type, +bool CanUseSocketAPIs(bool external_plugin, const SocketPermissionRequest& params, RenderViewHost* render_view_host) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (plugin_process_type == PROCESS_TYPE_PPAPI_PLUGIN) { - // Always allow socket APIs for out-process plugins (except NACL). + if (!external_plugin) { + // Always allow socket APIs for out-process plugins (other than external + // plugins instantiated by the embeeder through + // BrowserPpapiHost::CreateExternalPluginProcess). return true; } diff --git a/content/browser/renderer_host/pepper/pepper_socket_utils.h b/content/browser/renderer_host/pepper/pepper_socket_utils.h index 4e1b0fc..4630ee2 100644 --- a/content/browser/renderer_host/pepper/pepper_socket_utils.h +++ b/content/browser/renderer_host/pepper/pepper_socket_utils.h @@ -5,7 +5,6 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_ #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_SOCKET_UTILS_H_ -#include "content/public/common/process_type.h" #include "content/public/common/socket_permission_request.h" struct PP_NetAddress_Private; @@ -20,7 +19,7 @@ SocketPermissionRequest CreateSocketPermissionRequest( SocketPermissionRequest::OperationType type, const PP_NetAddress_Private& net_addr); -bool CanUseSocketAPIs(ProcessType plugin_process_type, +bool CanUseSocketAPIs(bool external_plugin, const SocketPermissionRequest& params, RenderViewHost* render_view_host); diff --git a/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.cc b/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.cc index 3a5f8f5..08384e78 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.cc @@ -35,13 +35,13 @@ namespace content { namespace { bool CanUseSocketAPIs(const SocketPermissionRequest& request, - ProcessType plugin_process_type, + bool external_plugin, int render_process_id, int render_view_id) { RenderViewHost* render_view_host = RenderViewHost::FromID(render_process_id, render_view_id); return render_view_host && - pepper_socket_utils::CanUseSocketAPIs(plugin_process_type, + pepper_socket_utils::CanUseSocketAPIs(external_plugin, request, render_view_host); } @@ -54,7 +54,7 @@ PepperUDPSocketPrivateMessageFilter::PepperUDPSocketPrivateMessageFilter( : allow_address_reuse_(false), allow_broadcast_(false), closed_(false), - plugin_process_type_(host->plugin_process_type()), + external_plugin_(host->external_plugin()), render_process_id_(0), render_view_id_(0) { DCHECK(host); @@ -142,7 +142,7 @@ int32_t PepperUDPSocketPrivateMessageFilter::OnMsgBind( SocketPermissionRequest request = pepper_socket_utils::CreateSocketPermissionRequest( SocketPermissionRequest::UDP_BIND, addr); - if (!CanUseSocketAPIs(request, plugin_process_type_, + if (!CanUseSocketAPIs(request, external_plugin_, render_process_id_, render_view_id_)) { return PP_ERROR_FAILED; } @@ -192,7 +192,7 @@ int32_t PepperUDPSocketPrivateMessageFilter::OnMsgSendTo( SocketPermissionRequest request = pepper_socket_utils::CreateSocketPermissionRequest( SocketPermissionRequest::UDP_SEND_TO, addr); - if (!CanUseSocketAPIs(request, plugin_process_type_, + if (!CanUseSocketAPIs(request, external_plugin_, render_process_id_, render_view_id_)) { return PP_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.h b/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.h index eb62a1f..90f433f 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_udp_socket_private_message_filter.h @@ -110,7 +110,7 @@ class CONTENT_EXPORT PepperUDPSocketPrivateMessageFilter net::IPEndPoint recvfrom_address_; - ProcessType plugin_process_type_; + bool external_plugin_; int render_process_id_; int render_view_id_; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index ca648f5..407387c 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -596,8 +596,7 @@ void RenderProcessHostImpl::CreateMessageFilters() { channel_->AddFilter(new MediaStreamDispatcherHost(GetID())); #endif #if defined(ENABLE_PLUGINS) - channel_->AddFilter(new PepperMessageFilter(PROCESS_TYPE_RENDERER, - GetID(), browser_context)); + channel_->AddFilter(new PepperMessageFilter(GetID(), browser_context)); #endif #if defined(ENABLE_INPUT_SPEECH) channel_->AddFilter(new InputTagSpeechDispatcherHost( |