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

Unified Diff: content/renderer/render_view_impl.cc

Issue 11316209: RenderViewImpl::FromRoutingID: Use a global Routing ID map to lookup RenderViews (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 0eeaadb18b260e719df671f222b86dedc71492d4..c311e902a2d5d895c7a90f42c57711427a0c7eb3 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -337,6 +337,9 @@ namespace content {
typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap;
static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER;
+typedef std::map<int32, RenderViewImpl*> RoutingIDViewMap;
+static base::LazyInstance<RoutingIDViewMap> g_routing_id_view_map =
+ LAZY_INSTANCE_INITIALIZER;
// Time, in seconds, we delay before sending content state changes (such as form
// state and scroll position) to the browser. We delay sending changes to avoid
@@ -368,8 +371,9 @@ static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) =
NULL;
static RenderViewImpl* FromRoutingID(int32 routing_id) {
- return static_cast<RenderViewImpl*>(
- ChildThread::current()->ResolveRoute(routing_id));
+ RoutingIDViewMap* views = g_routing_id_view_map.Pointer();
+ RoutingIDViewMap::iterator it = views->find(routing_id);
+ return it == views->end() ? NULL : it->second;
}
static WebKit::WebFrame* FindFrameByID(WebKit::WebFrame* root, int frame_id) {
@@ -664,6 +668,7 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
}
g_view_map.Get().insert(std::make_pair(webview(), this));
+ g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this));
webview()->setDeviceScaleFactor(device_scale_factor_);
webkit_preferences_.Apply(webview());
webview()->initializeMainFrame(this);
@@ -748,10 +753,14 @@ RenderViewImpl::~RenderViewImpl() {
#endif
#ifndef NDEBUG
- // Make sure we are no longer referenced by the ViewMap.
+ // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap.
ViewMap* views = g_view_map.Pointer();
for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
DCHECK_NE(this, it->second) << "Failed to call Close?";
+ RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer();
+ for (RoutingIDViewMap::iterator it = routing_id_views->begin();
+ it != routing_id_views->end(); ++it)
+ DCHECK_NE(this, it->second) << "Failed to call Close?";
#endif
FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
@@ -5689,6 +5698,7 @@ void RenderViewImpl::Close() {
WebView* doomed = webview();
RenderWidget::Close();
g_view_map.Get().erase(doomed);
+ g_routing_id_view_map.Get().erase(routing_id_);
}
void RenderViewImpl::DidHandleKeyEvent() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698