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