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

Side by Side Diff: content/browser/frame_host/frame_tree.cc

Issue 558943002: Revert of Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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/frame_host/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "content/browser/frame_host/frame_tree_node.h" 13 #include "content/browser/frame_host/frame_tree_node.h"
14 #include "content/browser/frame_host/navigator.h" 14 #include "content/browser/frame_host/navigator.h"
15 #include "content/browser/frame_host/render_frame_host_factory.h" 15 #include "content/browser/frame_host/render_frame_host_factory.h"
16 #include "content/browser/frame_host/render_frame_host_impl.h" 16 #include "content/browser/frame_host/render_frame_host_impl.h"
17 #include "content/browser/frame_host/render_frame_proxy_host.h"
18 #include "content/browser/renderer_host/render_view_host_factory.h" 17 #include "content/browser/renderer_host/render_view_host_factory.h"
19 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 20
22 namespace content { 21 namespace content {
23 22
24 namespace { 23 namespace {
25 24
26 // This is a global map between frame_tree_node_ids and pointer to 25 // This is a global map between frame_tree_node_ids and pointer to
27 // FrameTreeNodes. 26 // FrameTreeNodes.
28 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap; 27 typedef base::hash_map<int64, FrameTreeNode*> FrameTreeNodeIDMap;
29 28
30 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map = 29 base::LazyInstance<FrameTreeNodeIDMap> g_frame_tree_node_id_map =
31 LAZY_INSTANCE_INITIALIZER; 30 LAZY_INSTANCE_INITIALIZER;
32 31
33 // Used with FrameTree::ForEach() to search for the FrameTreeNode 32 // Used with FrameTree::ForEach() to search for the FrameTreeNode
34 // corresponding to |frame_tree_node_id| whithin a specific FrameTree. 33 // corresponding to |frame_tree_node_id| whithin a specific FrameTree.
35 bool FrameTreeNodeForId(int64 frame_tree_node_id, 34 bool FrameTreeNodeForId(int64 frame_tree_node_id,
36 FrameTreeNode** out_node, 35 FrameTreeNode** out_node,
37 FrameTreeNode* node) { 36 FrameTreeNode* node) {
38 if (node->frame_tree_node_id() == frame_tree_node_id) { 37 if (node->frame_tree_node_id() == frame_tree_node_id) {
39 *out_node = node; 38 *out_node = node;
40 // Terminate iteration once the node has been found. 39 // Terminate iteration once the node has been found.
41 return false; 40 return false;
41 }
42 return true;
43 }
44
45 bool FrameTreeNodeForRoutingId(int routing_id,
46 int process_id,
47 FrameTreeNode** out_node,
48 FrameTreeNode* node) {
49 // TODO(creis): Look through the swapped out RFHs as well.
50 if (node->current_frame_host()->GetProcess()->GetID() == process_id &&
51 node->current_frame_host()->GetRoutingID() == routing_id) {
52 *out_node = node;
53 // Terminate iteration once the node has been found.
54 return false;
42 } 55 }
43 return true; 56 return true;
44 } 57 }
45 58
46 // Iterate over the FrameTree to reset any node affected by the loss of the 59 // Iterate over the FrameTree to reset any node affected by the loss of the
47 // given RenderViewHost's process. 60 // given RenderViewHost's process.
48 bool ResetNodesForNewProcess(RenderViewHost* render_view_host, 61 bool ResetNodesForNewProcess(RenderViewHost* render_view_host,
49 FrameTreeNode* node) { 62 FrameTreeNode* node) {
50 if (render_view_host == node->current_frame_host()->render_view_host()) 63 if (render_view_host == node->current_frame_host()->render_view_host())
51 node->ResetForNewProcess(); 64 node->ResetForNewProcess();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return it == nodes->end() ? NULL : it->second; 113 return it == nodes->end() ? NULL : it->second;
101 } 114 }
102 115
103 FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) { 116 FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) {
104 FrameTreeNode* node = NULL; 117 FrameTreeNode* node = NULL;
105 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node)); 118 ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node));
106 return node; 119 return node;
107 } 120 }
108 121
109 FrameTreeNode* FrameTree::FindByRoutingID(int routing_id, int process_id) { 122 FrameTreeNode* FrameTree::FindByRoutingID(int routing_id, int process_id) {
110 RenderFrameHostImpl* render_frame_host = 123 FrameTreeNode* node = NULL;
111 RenderFrameHostImpl::FromID(process_id, routing_id); 124 ForEach(
112 if (render_frame_host) { 125 base::Bind(&FrameTreeNodeForRoutingId, routing_id, process_id, &node));
113 FrameTreeNode* result = render_frame_host->frame_tree_node(); 126 return node;
114 if (this == result->frame_tree())
115 return result;
116 }
117
118 RenderFrameProxyHost* render_frame_proxy_host =
119 RenderFrameProxyHost::FromID(process_id, routing_id);
120 if (render_frame_proxy_host) {
121 FrameTreeNode* result = render_frame_proxy_host->frame_tree_node();
122 if (this == result->frame_tree())
123 return result;
124 }
125
126 return NULL;
127 } 127 }
128 128
129 void FrameTree::ForEach( 129 void FrameTree::ForEach(
130 const base::Callback<bool(FrameTreeNode*)>& on_node) const { 130 const base::Callback<bool(FrameTreeNode*)>& on_node) const {
131 std::queue<FrameTreeNode*> queue; 131 std::queue<FrameTreeNode*> queue;
132 queue.push(root_.get()); 132 queue.push(root_.get());
133 133
134 while (!queue.empty()) { 134 while (!queue.empty()) {
135 FrameTreeNode* node = queue.front(); 135 FrameTreeNode* node = queue.front();
136 queue.pop(); 136 queue.pop();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 rvh->Shutdown(); 322 rvh->Shutdown();
323 render_view_host_pending_shutdown_map_.erase(multi_iter); 323 render_view_host_pending_shutdown_map_.erase(multi_iter);
324 } 324 }
325 break; 325 break;
326 } 326 }
327 CHECK(render_view_host_found); 327 CHECK(render_view_host_found);
328 } 328 }
329 } 329 }
330 330
331 } // namespace content 331 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698