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

Unified Diff: content/browser/frame_host/frame_tree.cc

Issue 63523004: Give FrameTreeNodes a browser-global ID for use in navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update parameter name Created 7 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 | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/frame_tree.cc
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc
index 0cb9d5ecfa11e6089ed6fe332c1c47e51d13f23d..440b095ab8501c5cfc82a4dd81cc1eab2f281e4d 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -15,9 +15,22 @@ namespace content {
namespace {
// Used with FrameTree::ForEach() to search for the FrameTreeNode
-// corresponding to |frame_id|.
-bool FrameTreeNodeForId(int64 frame_id, FrameTreeNode** out_node,
+// corresponding to |frame_tree_node_id|.
+bool FrameTreeNodeForId(int64 frame_tree_node_id,
+ FrameTreeNode** out_node,
FrameTreeNode* node) {
+ if (node->frame_tree_node_id() == frame_tree_node_id) {
+ *out_node = node;
+ // Terminate iteration once the node has been found.
+ return false;
+ }
+ return true;
+}
+
+// TODO(creis): Remove this version along with FrameTreeNode::frame_id().
+bool FrameTreeNodeForFrameId(int64 frame_id,
+ FrameTreeNode** out_node,
+ FrameTreeNode* node) {
if (node->frame_id() == frame_id) {
*out_node = node;
// Terminate iteration once the node has been found.
@@ -36,9 +49,9 @@ FrameTree::FrameTree()
FrameTree::~FrameTree() {
}
-FrameTreeNode* FrameTree::FindByID(int64 frame_id) {
+FrameTreeNode* FrameTree::FindByID(int64 frame_tree_node_id) {
FrameTreeNode* node = NULL;
- ForEach(base::Bind(&FrameTreeNodeForId, frame_id, &node));
+ ForEach(base::Bind(&FrameTreeNodeForId, frame_tree_node_id, &node));
return node;
}
@@ -66,9 +79,11 @@ void FrameTree::OnFirstNavigationAfterSwap(int main_frame_id) {
root_->set_frame_id(main_frame_id);
}
-void FrameTree::AddFrame(int render_frame_host_id, int64 parent_frame_id,
- int64 frame_id, const std::string& frame_name) {
- FrameTreeNode* parent = FindByID(parent_frame_id);
+void FrameTree::AddFrame(int render_frame_host_id,
+ int64 parent_frame_id,
+ int64 frame_id,
+ const std::string& frame_name) {
+ FrameTreeNode* parent = FindByFrameID(parent_frame_id);
// TODO(ajwong): Should the renderer be killed here? Would there be a race on
// shutdown that might make this case possible?
if (!parent)
@@ -86,7 +101,8 @@ void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) {
// TODO(ajwong): Move this below the |parent| check after the FrameTree is
// guaranteed to be correctly populated even without the
// switches::kSitePerProcess flag.
- FrameTreeNode* parent = FindByID(parent_frame_id);
+ FrameTreeNode* parent = FindByFrameID(parent_frame_id);
+ FrameTreeNode* child = FindByFrameID(frame_id);
if (!on_frame_removed_.is_null()) {
on_frame_removed_.Run(
root_->render_frame_host()->render_view_host(), frame_id);
@@ -94,14 +110,14 @@ void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) {
// TODO(ajwong): Should the renderer be killed here? Would there be a race on
// shutdown that might make this case possible?
- if (!parent)
+ if (!parent || !child)
return;
- parent->RemoveChild(frame_id);
+ parent->RemoveChild(child);
}
void FrameTree::SetFrameUrl(int64 frame_id, const GURL& url) {
- FrameTreeNode* node = FindByID(frame_id);
+ FrameTreeNode* node = FindByFrameID(frame_id);
// TODO(ajwong): Should the renderer be killed here? Would there be a race on
// shutdown that might make this case possible?
if (!node)
@@ -124,8 +140,16 @@ void FrameTree::SetFrameRemoveListener(
on_frame_removed_ = on_frame_removed;
}
+FrameTreeNode* FrameTree::FindByFrameID(int64 frame_id) {
+ FrameTreeNode* node = NULL;
+ ForEach(base::Bind(&FrameTreeNodeForFrameId, frame_id, &node));
+ return node;
+}
+
scoped_ptr<FrameTreeNode> FrameTree::CreateNode(
- int64 frame_id, const std::string& frame_name, int render_frame_host_id,
+ int64 frame_id,
+ const std::string& frame_name,
+ int render_frame_host_id,
RenderProcessHost* render_process_host) {
scoped_ptr<RenderFrameHostImpl> render_frame_host(
new RenderFrameHostImpl(root_->render_frame_host()->render_view_host(),
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698