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

Side by Side Diff: content/browser/renderer_host/render_frame_host_impl.cc

Issue 21388003: Move routing to RenderFrameHost instead of RenderViewHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move global map to .cc file. Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_frame_host_impl.h" 5 #include "content/browser/renderer_host/render_frame_host_impl.h"
6 6
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 typedef std::pair<int32, int32> RenderFrameHostID;
12 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*>
13 RoutingIDFrameMap;
14 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
15 LAZY_INSTANCE_INITIALIZER;
16
17 // static
18 RenderFrameHost* RenderFrameHost::FromID(int process_id, int routing_id) {
19 return RenderFrameHostImpl::FromID(process_id, routing_id);
20 }
21
22 // static
23 RenderFrameHostImpl* RenderFrameHostImpl::FromID(
24 int process_id, int routing_id) {
25 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer();
26 RoutingIDFrameMap::iterator it = frames->find(
27 RenderFrameHostID(process_id, routing_id));
28 return it == frames->end() ? NULL : it->second;
29 }
30
11 RenderFrameHostImpl::RenderFrameHostImpl( 31 RenderFrameHostImpl::RenderFrameHostImpl(
12 RenderViewHostImpl* render_view_host, 32 RenderViewHostImpl* render_view_host,
13 int routing_id, 33 int routing_id,
14 bool swapped_out) 34 bool swapped_out)
15 : render_view_host_(render_view_host), 35 : render_view_host_(render_view_host),
16 routing_id_(routing_id) { 36 routing_id_(routing_id) {
37 render_view_host_->GetProcess()->AddRoute(routing_id_, this);
38 g_routing_id_frame_map.Get().insert(std::make_pair(
39 RenderFrameHostID(render_view_host_->GetProcess()->GetID(), routing_id_),
40 this));
17 } 41 }
18 42
19 RenderFrameHostImpl::~RenderFrameHostImpl() { 43 RenderFrameHostImpl::~RenderFrameHostImpl() {
44 render_view_host_->GetProcess()->RemoveRoute(routing_id_);
45 g_routing_id_frame_map.Get().erase(
46 RenderFrameHostID(render_view_host_->GetProcess()->GetID(), routing_id_));
47
48 }
49
50 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() const {
51 return render_view_host_;
52 }
53
54 int RenderFrameHostImpl::GetRoutingID() const {
55 return routing_id_;
20 } 56 }
21 57
22 bool RenderFrameHostImpl::Send(IPC::Message* message) { 58 bool RenderFrameHostImpl::Send(IPC::Message* message) {
23 // Use the RenderViewHost object to send the message. It inherits it from 59 // Use the RenderViewHost object to send the message. It inherits it from
24 // RenderWidgetHost, which ultimately uses the current process's |Send|. 60 // RenderWidgetHost, which ultimately uses the current process's |Send|.
25 return render_view_host_->Send(message); 61 return render_view_host_->Send(message);
26 } 62 }
27 63
28 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { 64 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
29 // Pass the message up to the RenderViewHost, until we have enough 65 // Pass the message up to the RenderViewHost, until we have enough
30 // infrastructure to start processing messages in this object. 66 // infrastructure to start processing messages in this object.
31 return render_view_host_->OnMessageReceived(msg); 67 return render_view_host_->OnMessageReceived(msg);
32 } 68 }
33 69
34 } // namespace content 70 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_frame_host_impl.h ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698