Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 16431010: Refactor RenderProcessHost to use IPC::Listener instead of RenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Windows compile error. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 6063e9e47a5a86b1919262fa5a32c7d4afbc5da2..30eed5c3d81f6bd9299e04d2245c782df8492118 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -18,6 +18,7 @@
#include "base/metrics/histogram.h"
#include "base/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "cc/base/hash_pair.h"
jam 2013/06/12 19:59:59 it seems wrong that content uses cc's base (or tha
nasko 2013/06/12 21:18:59 Agreed. ajwong and danakj have taken on moving thi
jam 2013/06/12 22:59:27 Yes, please let's wait on that.
nasko 2013/06/20 23:25:26 I've moved the hash_pair into base/containers/hash
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
@@ -120,6 +121,12 @@ g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
} // namespace
+typedef std::pair<int32, int32> RenderWidgetHostID;
+typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>
+ RoutingIDWidgetMap;
+static base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map =
+ LAZY_INSTANCE_INITIALIZER;
+
// static
void RenderWidgetHost::RemoveAllBackingStores() {
BackingStoreManager::RemoveAllBackingStores();
@@ -198,7 +205,9 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
is_threaded_compositing_enabled_ = IsThreadedCompositingEnabled();
- process_->Attach(this, routing_id_);
+ g_routing_id_widget_map.Get().insert(std::make_pair(
+ RenderWidgetHostID(process->GetID(), routing_id_), this));
+ process_->AddRoute(routing_id_, this);
// Because the widget initializes as is_hidden_ == false,
// tell the process host that we're alive.
process_->WidgetRestored();
@@ -225,13 +234,44 @@ RenderWidgetHostImpl::~RenderWidgetHostImpl() {
GpuSurfaceTracker::Get()->RemoveSurface(surface_id_);
surface_id_ = 0;
- process_->Release(routing_id_);
+ process_->RemoveRoute(routing_id_);
+ g_routing_id_widget_map.Get().erase(
+ RenderWidgetHostID(process_->GetID(), routing_id_));
if (delegate_)
delegate_->RenderWidgetDeleted(this);
}
// static
+RenderWidgetHost* RenderWidgetHost::FromID(
+ int32 process_id,
+ int32 routing_id) {
+ return RenderWidgetHostImpl::FromID(process_id, routing_id);
+}
+
+// static
+RenderWidgetHostImpl* RenderWidgetHostImpl::FromID(
+ int32 process_id,
+ int32 routing_id) {
+ RoutingIDWidgetMap* widgets = g_routing_id_widget_map.Pointer();
+ RoutingIDWidgetMap::iterator it = widgets->find(
+ RenderWidgetHostID(process_id, routing_id));
+ return it == widgets->end() ? NULL : it->second;
+}
+
+// static
+std::vector<RenderWidgetHost*> RenderWidgetHost::GetRenderWidgetHosts() {
+ std::vector<RenderWidgetHost*> hosts;
+ RoutingIDWidgetMap* widgets = g_routing_id_widget_map.Pointer();
+ for (RoutingIDWidgetMap::const_iterator it = widgets->begin();
+ it != widgets->end();
+ ++it) {
+ hosts.push_back(it->second);
+ }
+ return hosts;
+}
+
+// static
RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) {
return rwh->AsRenderWidgetHostImpl();
}
@@ -2543,10 +2583,8 @@ void RenderWidgetHostImpl::CompositorFrameDrawn(
// Matches with GetLatencyComponentId
int routing_id = b->first.second & 0xffffffff;
int process_id = (b->first.second >> 32) & 0xffffffff;
- RenderProcessHost* host = RenderProcessHost::FromID(process_id);
- if (!host)
- continue;
- RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(routing_id);
+ RenderWidgetHost* rwh =
+ RenderWidgetHost::FromID(process_id, routing_id);
if (!rwh)
continue;
RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);

Powered by Google App Engine
This is Rietveld 408576698