diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 06:29:23 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-20 06:29:23 +0000 |
commit | 3b0032a7abc9cc9350253d4f66dcd9a367e206ab (patch) | |
tree | 3c7ae09453fe79f47ed7e0b5095aef5518bb4e95 /content/browser/plugin_process_host.cc | |
parent | 1027ebc3ec3fbb9fd44112e42bb06906895712bb (diff) | |
download | chromium_src-3b0032a7abc9cc9350253d4f66dcd9a367e206ab.zip chromium_src-3b0032a7abc9cc9350253d4f66dcd9a367e206ab.tar.gz chromium_src-3b0032a7abc9cc9350253d4f66dcd9a367e206ab.tar.bz2 |
Add a Content API around BrowserChildProcessHost, similar to what was done with ChildProcessHost. Now classes like PluginProcessHost don't derive from it, but instead use composition.
I've also moved the iterator class into its own file in the public directory. Since classes don't derive from BrowserChildProcessHost and so can't static_cast from it, I added a template helper that does this.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9150017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/plugin_process_host.cc')
-rw-r--r-- | content/browser/plugin_process_host.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index cd8fb88..d15ffbd 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -21,6 +21,7 @@ #include "base/path_service.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "content/browser/browser_child_process_host.h" #include "content/browser/plugin_service_impl.h" #include "content/common/child_process_host_impl.h" #include "content/common/plugin_messages.h" @@ -36,6 +37,7 @@ #include "ui/gfx/native_widget_types.h" using content::BrowserThread; +using content::ChildProcessData; using content::ChildProcessHost; #if defined(USE_X11) @@ -91,7 +93,7 @@ void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { // Reparent only from the plugin process to our process. DWORD process_id = 0; ::GetWindowThreadProcessId(window, &process_id); - if (process_id != ::GetProcessId(GetChildProcessHandle())) + if (process_id != ::GetProcessId(process_->GetHandle())) return; ::GetWindowThreadProcessId(parent, &process_id); if (process_id != ::GetCurrentProcessId()) @@ -114,11 +116,12 @@ void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, #endif // defined(TOOLKIT_USES_GTK) PluginProcessHost::PluginProcessHost() - : BrowserChildProcessHost(content::PROCESS_TYPE_PLUGIN) #if defined(OS_MACOSX) - , plugin_cursor_visible_(true) + : plugin_cursor_visible_(true) #endif { + process_.reset(new BrowserChildProcessHost( + content::PROCESS_TYPE_PLUGIN, this)); } PluginProcessHost::~PluginProcessHost() { @@ -164,11 +167,15 @@ PluginProcessHost::~PluginProcessHost() { CancelRequests(); } +bool PluginProcessHost::Send(IPC::Message* message) { + return process_->Send(message); +} + bool PluginProcessHost::Init(const webkit::WebPluginInfo& info) { info_ = info; - SetName(info_.name); + process_->SetName(info_.name); - std::string channel_id = child_process_host()->CreateChannel(); + std::string channel_id = process_->GetHost()->CreateChannel(); if (channel_id.empty()) return false; @@ -258,7 +265,7 @@ bool PluginProcessHost::Init(const webkit::WebPluginInfo& info) { #endif #endif - Launch( + process_->Launch( #if defined(OS_WIN) FilePath(), #elif defined(OS_POSIX) @@ -271,7 +278,7 @@ bool PluginProcessHost::Init(const webkit::WebPluginInfo& info) { // called on the plugin. The plugin process exits when it receives the // OnChannelError notification indicating that the browser plugin channel has // been destroyed. - SetTerminateChildOnShutdown(false); + process_->SetTerminateChildOnShutdown(false); content::GetContentClient()->browser()->PluginProcessHostCreated(this); @@ -281,11 +288,11 @@ bool PluginProcessHost::Init(const webkit::WebPluginInfo& info) { void PluginProcessHost::ForceShutdown() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown()); - BrowserChildProcessHost::ForceShutdown(); + process_->ForceShutdown(); } void PluginProcessHost::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { - child_process_host()->AddFilter(filter); + process_->GetHost()->AddFilter(filter); } bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { @@ -320,7 +327,6 @@ bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { } void PluginProcessHost::OnChannelConnected(int32 peer_pid) { - BrowserChildProcessHost::OnChannelConnected(peer_pid); for (size_t i = 0; i < pending_requests_.size(); ++i) { RequestPluginChannel(pending_requests_[i]); } @@ -352,9 +358,8 @@ void PluginProcessHost::CancelRequests() { // static void PluginProcessHost::CancelPendingRequestsForResourceContext( const content::ResourceContext* context) { - for (BrowserChildProcessHost::Iterator host_it(content::PROCESS_TYPE_PLUGIN); - !host_it.Done(); ++host_it) { - PluginProcessHost* host = static_cast<PluginProcessHost*>(*host_it); + for (PluginProcessHostIterator host_it; !host_it.Done(); ++host_it) { + PluginProcessHost* host = *host_it; for (size_t i = 0; i < host->pending_requests_.size(); ++i) { if (&host->pending_requests_[i]->GetResourceContext() == context) { host->pending_requests_[i]->OnError(); @@ -366,9 +371,9 @@ void PluginProcessHost::CancelPendingRequestsForResourceContext( } void PluginProcessHost::OpenChannelToPlugin(Client* client) { - Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); + process_->Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); client->SetPluginInfo(info_); - if (child_process_host()->IsChannelOpening()) { + if (process_->GetHost()->IsChannelOpening()) { // The channel is already in the process of being opened. Put // this "open channel" request into a queue of requests that will // be run once the channel is open. |