summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/memory_details.cc11
-rw-r--r--chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc7
-rw-r--r--chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc9
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.cc4
-rw-r--r--content/browser/renderer_host/mock_render_process_host.cc23
-rw-r--r--content/browser/renderer_host/mock_render_process_host.h11
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc40
-rw-r--r--content/browser/renderer_host/render_process_host_impl.h20
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc7
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc14
-rw-r--r--content/public/browser/render_process_host.h14
-rw-r--r--content/public/browser/render_widget_host.h6
12 files changed, 75 insertions, 91 deletions
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc
index 3237eb7..04b248a 100644
--- a/chrome/browser/memory_details.cc
+++ b/chrome/browser/memory_details.cc
@@ -194,15 +194,10 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
// The RenderProcessHost may host multiple TabContents. Any
// of them which contain diagnostics information make the whole
// process be considered a diagnostics process.
- //
- // NOTE: This is a bit dangerous. We know that for now, listeners
- // are always RenderWidgetHosts. But in theory, they don't
- // have to be.
- content::RenderProcessHost::listeners_iterator iter(
- render_process_host->ListenersIterator());
+ content::RenderProcessHost::RenderWidgetHostsIterator iter(
+ render_process_host->GetRenderWidgetHostsIterator());
for (; !iter.IsAtEnd(); iter.Advance()) {
- const RenderWidgetHost* widget =
- RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue());
+ const RenderWidgetHost* widget = iter.GetCurrentValue();
DCHECK(widget);
if (!widget || !widget->IsRenderView())
continue;
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
index 34aa193..a9757ce 100644
--- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
+++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
@@ -27,11 +27,10 @@ RenderViewHost* FindFirstDevToolsHost() {
DCHECK(render_process_host);
if (!render_process_host->HasConnection())
continue;
- content::RenderProcessHost::listeners_iterator iter(
- render_process_host->ListenersIterator());
+ content::RenderProcessHost::RenderWidgetHostsIterator iter(
+ render_process_host->GetRenderWidgetHostsIterator());
for (; !iter.IsAtEnd(); iter.Advance()) {
- const RenderWidgetHost* widget =
- RenderWidgetHost::FromIPCChannelListener(iter.GetCurrentValue());
+ const RenderWidgetHost* widget = iter.GetCurrentValue();
DCHECK(widget);
if (!widget || !widget->IsRenderView())
continue;
diff --git a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc
index 215854b..2d5de417 100644
--- a/chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc
+++ b/chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.cc
@@ -123,15 +123,14 @@ void ChromeWebContentsViewDelegateGtk::ShowContextMenu(
content::RenderWidgetHostView* view = NULL;
if (params.custom_context.render_widget_id !=
content::CustomContextMenuContext::kCurrentRenderWidget) {
- IPC::Channel::Listener* listener =
- web_contents_->GetRenderProcessHost()->GetListenerByID(
+ content::RenderWidgetHost* host =
+ web_contents_->GetRenderProcessHost()->GetRenderWidgetHostByID(
params.custom_context.render_widget_id);
- if (!listener) {
+ if (!host) {
NOTREACHED();
return;
}
- view =
- content::RenderWidgetHost::FromIPCChannelListener(listener)->GetView();
+ view = host->GetView();
} else {
view = web_contents_->GetRenderWidgetHostView();
}
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc
index 0917f49..eda47e1 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.cc
+++ b/content/browser/gpu/gpu_process_host_ui_shim.cc
@@ -89,8 +89,8 @@ RenderWidgetHostViewPort* GetRenderWidgetHostViewFromSurfaceID(
if (!process)
return NULL;
- RenderWidgetHostImpl* host = static_cast<RenderWidgetHostImpl*>(
- process->GetListenerByID(render_widget_id));
+ content::RenderWidgetHost* host = process->GetRenderWidgetHostByID(
+ render_widget_id);
return host ? RenderWidgetHostViewPort::FromRWHV(host->GetView()) : NULL;
}
diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc
index d9e807c..7270d84 100644
--- a/content/browser/renderer_host/mock_render_process_host.cc
+++ b/content/browser/renderer_host/mock_render_process_host.cc
@@ -14,6 +14,7 @@
#include "content/public/browser/notification_types.h"
using content::ChildProcessHostImpl;
+using content::RenderWidgetHost;
MockRenderProcessHost::MockRenderProcessHost(
content::BrowserContext* browser_context)
@@ -143,18 +144,18 @@ bool MockRenderProcessHost::IgnoreInputEvents() const {
return false;
}
-void MockRenderProcessHost::Attach(IPC::Channel::Listener* listener,
+void MockRenderProcessHost::Attach(RenderWidgetHost* host,
int routing_id) {
- listeners_.AddWithID(listener, routing_id);
+ render_widget_hosts_.AddWithID(host, routing_id);
}
-void MockRenderProcessHost::Release(int listener_id) {
- listeners_.Remove(listener_id);
+void MockRenderProcessHost::Release(int routing_id) {
+ render_widget_hosts_.Remove(routing_id);
Cleanup();
}
void MockRenderProcessHost::Cleanup() {
- if (listeners_.IsEmpty()) {
+ if (render_widget_hosts_.IsEmpty()) {
content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::Source<RenderProcessHost>(this),
@@ -177,9 +178,9 @@ bool MockRenderProcessHost::SuddenTerminationAllowed() const {
return true;
}
-IPC::Channel::Listener* MockRenderProcessHost::GetListenerByID(
+content::RenderWidgetHost* MockRenderProcessHost::GetRenderWidgetHostByID(
int routing_id) {
- return listeners_.Lookup(routing_id);
+ return render_widget_hosts_.Lookup(routing_id);
}
content::BrowserContext* MockRenderProcessHost::GetBrowserContext() const {
@@ -191,7 +192,7 @@ IPC::ChannelProxy* MockRenderProcessHost::GetChannel() {
}
bool MockRenderProcessHost::FastShutdownForPageCount(size_t count) {
- if (listeners_.size() == count)
+ if (render_widget_hosts_.size() == count)
return FastShutdownIfPossible();
return false;
}
@@ -203,9 +204,9 @@ base::TimeDelta MockRenderProcessHost::GetChildProcessIdleTime() const {
void MockRenderProcessHost::SurfaceUpdated(int32 surface_id) {
}
-content::RenderProcessHost::listeners_iterator
- MockRenderProcessHost::ListenersIterator() {
- return listeners_iterator(&listeners_);
+content::RenderProcessHost::RenderWidgetHostsIterator
+ MockRenderProcessHost::GetRenderWidgetHostsIterator() {
+ return RenderWidgetHostsIterator(&render_widget_hosts_);
}
bool MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) {
diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h
index 969a6fe..58db264 100644
--- a/content/browser/renderer_host/mock_render_process_host.h
+++ b/content/browser/renderer_host/mock_render_process_host.h
@@ -53,18 +53,19 @@ class MockRenderProcessHost : public content::RenderProcessHost {
virtual bool HasConnection() const OVERRIDE;
virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
virtual bool IgnoreInputEvents() const OVERRIDE;
- virtual void Attach(IPC::Channel::Listener* listener,
+ virtual void Attach(content::RenderWidgetHost* host,
int routing_id) OVERRIDE;
- virtual void Release(int listener_id) OVERRIDE;
+ virtual void Release(int routing_id) OVERRIDE;
virtual void Cleanup() OVERRIDE;
virtual void AddPendingView() OVERRIDE;
virtual void RemovePendingView() OVERRIDE;
virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE;
virtual bool SuddenTerminationAllowed() const OVERRIDE;
- virtual IPC::Channel::Listener* GetListenerByID(int routing_id) OVERRIDE;
+ virtual content::RenderWidgetHost* GetRenderWidgetHostByID(int routing_id)
+ OVERRIDE;
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
virtual IPC::ChannelProxy* GetChannel() OVERRIDE;
- virtual listeners_iterator ListenersIterator() OVERRIDE;
+ virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() OVERRIDE;
virtual bool FastShutdownForPageCount(size_t count) OVERRIDE;
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
@@ -91,7 +92,7 @@ class MockRenderProcessHost : public content::RenderProcessHost {
int id_;
content::BrowserContext* browser_context_;
- IDMap<IPC::Channel::Listener> listeners_;
+ IDMap<content::RenderWidgetHost> render_widget_hosts_;
bool fast_shutdown_started_;
DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost);
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 869bdf0..1cba35f 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -124,6 +124,8 @@ using content::BrowserMessageFilter;
using content::BrowserThread;
using content::ChildProcessHost;
using content::ChildProcessHostImpl;
+using content::RenderWidgetHost;
+using content::RenderWidgetHostImpl;
using content::UserMetricsAction;
using content::WebUIControllerFactory;
@@ -913,8 +915,8 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
}
// Dispatch incoming messages to the appropriate RenderView/WidgetHost.
- IPC::Channel::Listener* listener = GetListenerByID(msg.routing_id());
- if (!listener) {
+ RenderWidgetHost* rwh = render_widget_hosts_.Lookup(msg.routing_id());
+ if (!rwh) {
if (msg.is_sync()) {
// The listener has gone away, so we must respond or else the caller will
// hang waiting for a reply.
@@ -924,7 +926,7 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
}
return true;
}
- return listener->OnMessageReceived(msg);
+ return RenderWidgetHostImpl::From(rwh)->OnMessageReceived(msg);
}
void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) {
@@ -991,9 +993,9 @@ bool RenderProcessHostImpl::HasConnection() const {
return channel_.get() != NULL;
}
-IPC::Channel::Listener* RenderProcessHostImpl::GetListenerByID(
+RenderWidgetHost* RenderProcessHostImpl::GetRenderWidgetHostByID(
int routing_id) {
- return listeners_.Lookup(routing_id);
+ return render_widget_hosts_.Lookup(routing_id);
}
void RenderProcessHostImpl::SetIgnoreInputEvents(bool ignore_input_events) {
@@ -1004,17 +1006,17 @@ bool RenderProcessHostImpl::IgnoreInputEvents() const {
return ignore_input_events_;
}
-void RenderProcessHostImpl::Attach(IPC::Channel::Listener* listener,
- int routing_id) {
- listeners_.AddWithID(listener, routing_id);
+void RenderProcessHostImpl::Attach(RenderWidgetHost* host,
+ int routing_id) {
+ render_widget_hosts_.AddWithID(host, routing_id);
}
-void RenderProcessHostImpl::Release(int listener_id) {
- DCHECK(listeners_.Lookup(listener_id) != NULL);
- listeners_.Remove(listener_id);
+void RenderProcessHostImpl::Release(int routing_id) {
+ DCHECK(render_widget_hosts_.Lookup(routing_id) != NULL);
+ render_widget_hosts_.Remove(routing_id);
// Make sure that all associated resource requests are stopped.
- CancelResourceRequests(listener_id);
+ CancelResourceRequests(routing_id);
#if defined(OS_WIN)
// Dump the handle table if handle auditing is enabled.
@@ -1034,7 +1036,7 @@ void RenderProcessHostImpl::Release(int listener_id) {
void RenderProcessHostImpl::Cleanup() {
// When no other owners of this object, we can delete ourselves
- if (listeners_.IsEmpty()) {
+ if (render_widget_hosts_.IsEmpty()) {
content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::Source<RenderProcessHost>(this),
@@ -1089,13 +1091,13 @@ IPC::ChannelProxy* RenderProcessHostImpl::GetChannel() {
return channel_.get();
}
-content::RenderProcessHost::listeners_iterator
- RenderProcessHostImpl::ListenersIterator() {
- return listeners_iterator(&listeners_);
+content::RenderProcessHost::RenderWidgetHostsIterator
+ RenderProcessHostImpl::GetRenderWidgetHostsIterator() {
+ return RenderWidgetHostsIterator(&render_widget_hosts_);
}
bool RenderProcessHostImpl::FastShutdownForPageCount(size_t count) {
- if (listeners_.size() == count)
+ if (render_widget_hosts_.size() == count)
return FastShutdownIfPossible();
return false;
}
@@ -1229,9 +1231,9 @@ void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle,
channel_.reset();
gpu_message_filter_ = NULL;
- IDMap<IPC::Channel::Listener>::iterator iter(&listeners_);
+ IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_);
while (!iter.IsAtEnd()) {
- iter.GetCurrentValue()->OnMessageReceived(
+ RenderWidgetHostImpl::From(iter.GetCurrentValue())->OnMessageReceived(
ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
static_cast<int>(status),
exit_code));
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index eeace2a..e67224e 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -29,6 +29,11 @@ namespace base {
class WaitableEvent;
}
+namespace content {
+class RenderWidgetHost;
+class RenderWidgetHostImpl;
+}
+
// Implements a concrete RenderProcessHost for the browser process for talking
// to actual renderer processes (as opposed to mocks).
//
@@ -72,19 +77,20 @@ class CONTENT_EXPORT RenderProcessHostImpl
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
virtual int GetID() const OVERRIDE;
virtual bool HasConnection() const OVERRIDE;
- virtual IPC::Channel::Listener* GetListenerByID(int routing_id) OVERRIDE;
+ virtual content::RenderWidgetHost* GetRenderWidgetHostByID(int routing_id)
+ OVERRIDE;
virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
virtual bool IgnoreInputEvents() const OVERRIDE;
- virtual void Attach(IPC::Channel::Listener* listener, int routing_id)
+ virtual void Attach(content::RenderWidgetHost* host, int routing_id)
OVERRIDE;
- virtual void Release(int listener_id) OVERRIDE;
+ virtual void Release(int routing_id) OVERRIDE;
virtual void Cleanup() OVERRIDE;
virtual void AddPendingView() OVERRIDE;
virtual void RemovePendingView() OVERRIDE;
virtual void SetSuddenTerminationAllowed(bool enabled) OVERRIDE;
virtual bool SuddenTerminationAllowed() const OVERRIDE;
virtual IPC::ChannelProxy* GetChannel() OVERRIDE;
- virtual listeners_iterator ListenersIterator() OVERRIDE;
+ virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() OVERRIDE;
virtual bool FastShutdownForPageCount(size_t count) OVERRIDE;
virtual bool FastShutdownStarted() const OVERRIDE;
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
@@ -127,9 +133,9 @@ class CONTENT_EXPORT RenderProcessHostImpl
// browser_process.h)
scoped_ptr<IPC::ChannelProxy> channel_;
- // The registered listeners. When this list is empty or all NULL, we should
- // delete ourselves
- IDMap<IPC::Channel::Listener> listeners_;
+ // The registered render widget hosts. When this list is empty or all NULL,
+ // we should delete ourselves
+ IDMap<content::RenderWidgetHost> render_widget_hosts_;
// True if fast shutdown has been performed on this RPH.
bool fast_shutdown_started_;
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 4a24674..b2e76fc 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -103,8 +103,7 @@ RenderViewHost* RenderViewHost::FromID(int render_process_id,
RenderProcessHost* process = RenderProcessHost::FromID(render_process_id);
if (!process)
return NULL;
- RenderWidgetHost* widget = RenderWidgetHost::FromIPCChannelListener(
- process->GetListenerByID(render_view_id));
+ RenderWidgetHost* widget = process->GetRenderWidgetHostByID(render_view_id);
if (!widget || !widget->IsRenderView())
return NULL;
return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget));
@@ -670,8 +669,8 @@ void RenderViewHostImpl::AllowBindings(int bindings_flags) {
GetProcess()->GetID())) {
// This process has no bindings yet. Make sure it does not have more
// than this single view.
- RenderProcessHost::listeners_iterator iter(
- GetProcess()->ListenersIterator());
+ RenderProcessHostImpl::RenderWidgetHostsIterator iter(
+ GetProcess()->GetRenderWidgetHostsIterator());
iter.Advance();
if (!iter.IsAtEnd())
return;
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index e797f92..c47a28a 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -86,20 +86,6 @@ bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event,
namespace content {
// static
-RenderWidgetHost* RenderWidgetHost::FromIPCChannelListener(
- IPC::Channel::Listener* listener) {
- return static_cast<RenderWidgetHost*>(
- static_cast<RenderWidgetHostImpl*>(listener));
-}
-
-// static
-const RenderWidgetHost* RenderWidgetHost::FromIPCChannelListener(
- const IPC::Channel::Listener* listener) {
- return static_cast<const RenderWidgetHost*>(
- static_cast<const RenderWidgetHostImpl*>(listener));
-}
-
-// static
void RenderWidgetHost::RemoveAllBackingStores() {
BackingStoreManager::RemoveAllBackingStores();
}
diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h
index fa95d17..dc64905 100644
--- a/content/public/browser/render_process_host.h
+++ b/content/public/browser/render_process_host.h
@@ -20,6 +20,7 @@ struct ViewMsg_SwapOut_Params;
namespace content {
class BrowserContext;
+class RenderWidgetHost;
}
namespace base {
@@ -35,7 +36,7 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender,
public IPC::Channel::Listener {
public:
typedef IDMap<RenderProcessHost>::iterator iterator;
- typedef IDMap<IPC::Channel::Listener>::const_iterator listeners_iterator;
+ typedef IDMap<RenderWidgetHost>::const_iterator RenderWidgetHostsIterator;
// Details for RENDERER_PROCESS_CLOSED notifications.
struct RendererClosedDetails {
@@ -133,8 +134,8 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender,
// etc. It is generated by ChildProcessInfo.
virtual int GetID() const = 0;
- // Returns the listener for the routing id passed in.
- virtual IPC::Channel::Listener* GetListenerByID(int routing_id) = 0;
+ // Returns the render widget host for the routing id passed in.
+ virtual RenderWidgetHost* GetRenderWidgetHostByID(int routing_id) = 0;
// Returns true iff channel_ has been set to non-NULL. Use this for checking
// if there is connection or not. Virtual for mocking out for tests.
@@ -147,7 +148,8 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender,
// Returns the renderer channel.
virtual IPC::ChannelProxy* GetChannel() = 0;
- virtual listeners_iterator ListenersIterator() = 0;
+ // Returns the list of attached render widget hosts.
+ virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() = 0;
// Try to shutdown the associated render process as fast as possible
virtual bool FastShutdownForPageCount(size_t count) = 0;
@@ -161,10 +163,10 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Message::Sender,
// Used for refcounting, each holder of this object must Attach and Release
// just like it would for a COM object. This object should be allocated on
// the heap; when no listeners own it any more, it will delete itself.
- virtual void Attach(IPC::Channel::Listener* listener, int routing_id) = 0;
+ virtual void Attach(content::RenderWidgetHost* host, int routing_id) = 0;
// See Attach()
- virtual void Release(int listener_id) = 0;
+ virtual void Release(int routing_id) = 0;
// Schedules the host for deletion and removes it from the all_hosts list.
virtual void Cleanup() = 0;
diff --git a/content/public/browser/render_widget_host.h b/content/public/browser/render_widget_host.h
index b9f5204..4c0f983 100644
--- a/content/public/browser/render_widget_host.h
+++ b/content/public/browser/render_widget_host.h
@@ -111,12 +111,6 @@ class RenderWidgetHostView;
// the RenderWidgetHost's IPC message map.
class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender {
public:
- // Gets a RenderVidgetHost pointer from an IPC::Channel::Listener pointer.
- static RenderWidgetHost* FromIPCChannelListener(
- IPC::Channel::Listener* listener);
- static const RenderWidgetHost* FromIPCChannelListener(
- const IPC::Channel::Listener* listener);
-
// Free all backing stores used for rendering to drop memory usage.
static void RemoveAllBackingStores();