OLD | NEW |
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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" |
| 11 #include "content/browser/frame_host/navigator.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 #include "content/common/frame_messages.h" | 13 #include "content/common/frame_messages.h" |
12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/site_instance.h" |
14 #include "url/gurl.h" | 17 #include "url/gurl.h" |
15 | 18 |
16 namespace content { | 19 namespace content { |
17 | 20 |
18 // The (process id, routing id) pair that identifies one RenderFrame. | 21 // The (process id, routing id) pair that identifies one RenderFrame. |
19 typedef std::pair<int32, int32> RenderFrameHostID; | 22 typedef std::pair<int32, int32> RenderFrameHostID; |
20 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> | 23 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> |
21 RoutingIDFrameMap; | 24 RoutingIDFrameMap; |
22 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = | 25 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = |
23 LAZY_INSTANCE_INITIALIZER; | 26 LAZY_INSTANCE_INITIALIZER; |
24 | 27 |
25 // static | 28 // static |
26 RenderFrameHostImpl* RenderFrameHostImpl::FromID( | 29 RenderFrameHostImpl* RenderFrameHostImpl::FromID( |
27 int process_id, int routing_id) { | 30 int process_id, int routing_id) { |
28 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); | 31 RoutingIDFrameMap* frames = g_routing_id_frame_map.Pointer(); |
29 RoutingIDFrameMap::iterator it = frames->find( | 32 RoutingIDFrameMap::iterator it = frames->find( |
30 RenderFrameHostID(process_id, routing_id)); | 33 RenderFrameHostID(process_id, routing_id)); |
31 return it == frames->end() ? NULL : it->second; | 34 return it == frames->end() ? NULL : it->second; |
32 } | 35 } |
33 | 36 |
34 RenderFrameHostImpl::RenderFrameHostImpl( | 37 RenderFrameHostImpl::RenderFrameHostImpl( |
35 RenderViewHostImpl* render_view_host, | 38 RenderViewHostImpl* render_view_host, |
36 FrameTree* frame_tree, | 39 FrameTree* frame_tree, |
| 40 FrameTreeNode* frame_tree_node, |
37 int routing_id, | 41 int routing_id, |
38 bool is_swapped_out) | 42 bool is_swapped_out) |
39 : render_view_host_(render_view_host), | 43 : render_view_host_(render_view_host), |
40 frame_tree_(frame_tree), | 44 frame_tree_(frame_tree), |
| 45 frame_tree_node_(frame_tree_node), |
41 routing_id_(routing_id), | 46 routing_id_(routing_id), |
42 is_swapped_out_(is_swapped_out) { | 47 is_swapped_out_(is_swapped_out) { |
43 GetProcess()->AddRoute(routing_id_, this); | 48 GetProcess()->AddRoute(routing_id_, this); |
44 g_routing_id_frame_map.Get().insert(std::make_pair( | 49 g_routing_id_frame_map.Get().insert(std::make_pair( |
45 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 50 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
46 this)); | 51 this)); |
47 } | 52 } |
48 | 53 |
49 RenderFrameHostImpl::~RenderFrameHostImpl() { | 54 RenderFrameHostImpl::~RenderFrameHostImpl() { |
50 GetProcess()->RemoveRoute(routing_id_); | 55 GetProcess()->RemoveRoute(routing_id_); |
(...skipping 21 matching lines...) Expand all Loading... |
72 void RenderFrameHostImpl::Init() { | 77 void RenderFrameHostImpl::Init() { |
73 GetProcess()->ResumeRequestsForView(routing_id()); | 78 GetProcess()->ResumeRequestsForView(routing_id()); |
74 } | 79 } |
75 | 80 |
76 RenderProcessHost* RenderFrameHostImpl::GetProcess() const { | 81 RenderProcessHost* RenderFrameHostImpl::GetProcess() const { |
77 // TODO(nasko): This should return its own process, once we have working | 82 // TODO(nasko): This should return its own process, once we have working |
78 // cross-process navigation for subframes. | 83 // cross-process navigation for subframes. |
79 return render_view_host_->GetProcess(); | 84 return render_view_host_->GetProcess(); |
80 } | 85 } |
81 | 86 |
| 87 SiteInstance* RenderFrameHostImpl::GetSiteInstance() const { |
| 88 return render_view_host_->GetSiteInstance(); |
| 89 } |
| 90 |
82 void RenderFrameHostImpl::OnCreateChildFrame(int new_frame_routing_id, | 91 void RenderFrameHostImpl::OnCreateChildFrame(int new_frame_routing_id, |
83 int64 parent_frame_id, | 92 int64 parent_frame_id, |
84 int64 frame_id, | 93 int64 frame_id, |
85 const std::string& frame_name) { | 94 const std::string& frame_name) { |
86 frame_tree_->AddFrame(new_frame_routing_id, parent_frame_id, frame_id, | 95 frame_tree_->AddFrame(new_frame_routing_id, parent_frame_id, frame_id, |
87 frame_name); | 96 frame_name); |
88 } | 97 } |
89 | 98 |
90 void RenderFrameHostImpl::OnDetach(int64 parent_frame_id, int64 frame_id) { | 99 void RenderFrameHostImpl::OnDetach(int64 parent_frame_id, int64 frame_id) { |
91 frame_tree_->RemoveFrame(parent_frame_id, frame_id); | 100 frame_tree_->RemoveFrame(parent_frame_id, frame_id); |
92 } | 101 } |
93 | 102 |
94 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame( | 103 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame( |
95 int64 frame_id, | 104 int64 frame_id, |
96 int64 parent_frame_id, | 105 int64 parent_frame_id, |
97 bool is_main_frame, | 106 bool is_main_frame, |
98 const GURL& url) { | 107 const GURL& url) { |
99 render_view_host_->OnDidStartProvisionalLoadForFrame( | 108 frame_tree_node_->navigator()->DidStartProvisionalLoad( |
100 frame_id, parent_frame_id, is_main_frame, url); | 109 this, frame_id, parent_frame_id, is_main_frame, url); |
101 } | 110 } |
102 | 111 |
103 } // namespace content | 112 } // namespace content |
OLD | NEW |