summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc35
-rw-r--r--chrome/browser/renderer_host/render_process_host.cc18
-rw-r--r--chrome/browser/renderer_host/render_process_host.h15
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h2
6 files changed, 35 insertions, 41 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 0a7c12b..a0b64c1 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -649,17 +649,20 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() {
// Check for any external tab containers, since they may still be running even
// though this window closed.
- BrowserRenderProcessHost::listeners_iterator iter;
- // NOTE: This is a bit dangerous. We know that for now, listeners are
- // always RenderWidgetHosts. But in theory, they don't have to be.
- for (iter = listeners_begin(); iter != listeners_end(); ++iter) {
- RenderWidgetHost* widget = static_cast<RenderWidgetHost*>(iter->second);
+ BrowserRenderProcessHost::listeners_iterator iter(ListenersIterator());
+ while (!iter.IsAtEnd()) {
+ // NOTE: This is a bit dangerous. We know that for now, listeners are
+ // always RenderWidgetHosts. But in theory, they don't have to be.
+ const RenderWidgetHost* widget =
+ static_cast<const RenderWidgetHost*>(iter.GetCurrentValue());
DCHECK(widget);
- if (!widget || !widget->IsRenderView())
- continue;
- RenderViewHost* rvh = static_cast<RenderViewHost*>(widget);
- if (rvh->delegate()->IsExternalTabContainer())
- return false;
+ if (widget && widget->IsRenderView()) {
+ const RenderViewHost* rvh = static_cast<const RenderViewHost*>(widget);
+ if (rvh->delegate()->IsExternalTabContainer())
+ return false;
+ }
+
+ iter.Advance();
}
// Otherwise, we're allowed to just terminate the process. Using exit code 0
@@ -876,13 +879,11 @@ void BrowserRenderProcessHost::OnChannelError() {
channel_.reset();
- // This process should detach all the listeners, causing the object to be
- // deleted. We therefore need a stack copy of the web view list to avoid
- // crashing when checking for the termination condition the last time.
- IDMap<IPC::Channel::Listener> local_listeners(listeners_);
- for (listeners_iterator i = local_listeners.begin();
- i != local_listeners.end(); ++i) {
- i->second->OnMessageReceived(ViewHostMsg_RenderViewGone(i->first));
+ IDMap<IPC::Channel::Listener>::iterator iter(&listeners_);
+ while (!iter.IsAtEnd()) {
+ iter.GetCurrentValue()->OnMessageReceived(
+ ViewHostMsg_RenderViewGone(iter.GetCurrentKey()));
+ iter.Advance();
}
ClearTransportDIBCache();
diff --git a/chrome/browser/renderer_host/render_process_host.cc b/chrome/browser/renderer_host/render_process_host.cc
index 090ed91..4f0cbc0 100644
--- a/chrome/browser/renderer_host/render_process_host.cc
+++ b/chrome/browser/renderer_host/render_process_host.cc
@@ -125,13 +125,8 @@ void RenderProcessHost::UpdateMaxPageID(int32 page_id) {
}
// static
-RenderProcessHost::iterator RenderProcessHost::begin() {
- return all_hosts.begin();
-}
-
-// static
-RenderProcessHost::iterator RenderProcessHost::end() {
- return all_hosts.end();
+RenderProcessHost::iterator RenderProcessHost::AllHostsIterator() {
+ return iterator(&all_hosts);
}
// static
@@ -165,10 +160,13 @@ RenderProcessHost* RenderProcessHost::GetExistingProcessHost(Profile* profile,
std::vector<RenderProcessHost*> suitable_renderers;
suitable_renderers.reserve(size());
- for (iterator iter = begin(); iter != end(); ++iter) {
+ iterator iter(AllHostsIterator());
+ while (!iter.IsAtEnd()) {
if (run_renderer_in_process() ||
- IsSuitableHost(iter->second, profile, type))
- suitable_renderers.push_back(iter->second);
+ IsSuitableHost(iter.GetCurrentValue(), profile, type))
+ suitable_renderers.push_back(iter.GetCurrentValue());
+
+ iter.Advance();
}
// Now pick a random suitable renderer, if we have any.
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index aee189c..c906235 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -28,7 +28,7 @@ struct ViewMsg_ClosePage_Params;
class RenderProcessHost : public IPC::Channel::Sender,
public IPC::Channel::Listener {
public:
- typedef IDMap<RenderProcessHost>::const_iterator iterator;
+ typedef IDMap<RenderProcessHost>::iterator iterator;
// We classify renderers according to their highest privilege, and try
// to group pages into renderers with similar privileges.
@@ -83,11 +83,9 @@ class RenderProcessHost : public IPC::Channel::Sender,
// Allows iteration over this RenderProcessHost's RenderViewHost listeners.
// Use from UI thread only.
typedef IDMap<IPC::Channel::Listener>::const_iterator listeners_iterator;
- listeners_iterator listeners_begin() {
- return listeners_.begin();
- }
- listeners_iterator listeners_end() {
- return listeners_.end();
+
+ listeners_iterator ListenersIterator() {
+ return listeners_iterator(&listeners_);
}
IPC::Channel::Listener* GetListenerByID(int routing_id) {
@@ -195,10 +193,7 @@ class RenderProcessHost : public IPC::Channel::Sender,
// Allows iteration over all the RenderProcessHosts in the browser. Note
// that each host may not be active, and therefore may have NULL channels.
- // This is just a standard STL iterator, so it is not valid if the list
- // of RenderProcessHosts changes between iterations.
- static iterator begin();
- static iterator end();
+ static iterator AllHostsIterator();
static size_t size(); // TODO(brettw) rename this, it's very unclear.
// Returns the RenderProcessHost given its ID. Returns NULL if the ID does
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 49c4821..8acc403 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -148,7 +148,7 @@ void RenderViewHost::Observe(NotificationType type,
if (rph == process()) {
// Try to get some debugging information on the stack.
size_t num_hosts = RenderProcessHost::size();
- bool no_listeners = rph->listeners_begin() == rph->listeners_end();
+ bool no_listeners = rph->ListenersIterator().IsAtEnd();
bool live_instance = site_instance() != NULL;
CHECK(live_instance);
bool live_process = site_instance()->GetProcess() != NULL;
@@ -164,7 +164,7 @@ void RenderViewHost::Observe(NotificationType type,
bool RenderViewHost::CreateRenderView() {
DCHECK(!IsRenderViewLive()) << "Creating view twice";
CHECK(process());
- CHECK(process()->listeners_begin() != process()->listeners_end()) <<
+ CHECK(!process()->ListenersIterator().IsAtEnd()) <<
"Our process should have us as a listener.";
// The process may (if we're sharing a process with another host that already
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 71a15fe..6381ef1 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -403,7 +403,7 @@ class RenderViewHost : public RenderWidgetHost,
// RenderWidgetHost public overrides.
virtual void Shutdown();
- virtual bool IsRenderView() { return true; }
+ virtual bool IsRenderView() const { return true; }
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void GotFocus();
virtual bool CanBlur() const;
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index edace90..3b52e4a 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -171,7 +171,7 @@ class RenderWidgetHost : public IPC::Channel::Listener,
virtual void Shutdown();
// Manual RTTI FTW. We are not hosting a web page.
- virtual bool IsRenderView() { return false; }
+ virtual bool IsRenderView() const { return false; }
// IPC::Channel::Listener
virtual void OnMessageReceived(const IPC::Message& msg);