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

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

Issue 1255573005: Create FrameNavigationEntries for the initial blank page in subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 5 years, 5 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
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/navigation_entry_impl.h" 5 #include "content/browser/frame_host/navigation_entry_impl.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 const GURL& url, 534 const GURL& url,
535 const Referrer& referrer, 535 const Referrer& referrer,
536 const PageState& page_state) { 536 const PageState& page_state) {
537 // We should already have a TreeNode for the parent node by the time this node 537 // We should already have a TreeNode for the parent node by the time this node
538 // commits. Find it first. 538 // commits. Find it first.
539 DCHECK(frame_tree_node->parent()); 539 DCHECK(frame_tree_node->parent());
540 NavigationEntryImpl::TreeNode* parent_node = 540 NavigationEntryImpl::TreeNode* parent_node =
541 FindFrameEntry(frame_tree_node->parent()); 541 FindFrameEntry(frame_tree_node->parent());
542 if (!parent_node) { 542 if (!parent_node) {
543 // The renderer should not send a commit for a subframe before its parent. 543 // The renderer should not send a commit for a subframe before its parent.
544 // However, we may see commits of subframes when their parent or ancestor is 544 // TODO(creis): Kill the renderer if we get here.
545 // still the initial about:blank page, and we don't currently keep a 545 NOTREACHED() << "Shouldn't see a commit for a subframe before parent.";
546 // FrameNavigationEntry for that. We ignore such commits, similar to how we
547 // handle them at the top level.
548 // TODO(creis): Consider creating FNEs for initial about:blank commits.
549 return; 546 return;
550 } 547 }
551 548
552 // Now check whether we have a TreeNode for the node itself. 549 // Now check whether we have a TreeNode for the node itself.
553 int frame_tree_node_id = frame_tree_node->frame_tree_node_id(); 550 int frame_tree_node_id = frame_tree_node->frame_tree_node_id();
554 for (TreeNode* child : parent_node->children) { 551 for (TreeNode* child : parent_node->children) {
555 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) { 552 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) {
556 // Update the existing FrameNavigationEntry (e.g., for replaceState). 553 // Update the existing FrameNavigationEntry (e.g., for replaceState).
557 child->frame_entry->UpdateEntry(item_sequence_number, 554 child->frame_entry->UpdateEntry(item_sequence_number,
558 document_sequence_number, site_instance, 555 document_sequence_number, site_instance,
559 url, referrer, page_state); 556 url, referrer, page_state);
560 return; 557 return;
561 } 558 }
562 } 559 }
563 560
564 // No entry exists yet, so create a new one unless it's for about:blank. 561 // No entry exists yet, so create a new one.
565 // Unordered list, since we expect to look up entries by frame sequence number 562 // Unordered list, since we expect to look up entries by frame sequence number
566 // or unique name. 563 // or unique name.
567 if (url == GURL(url::kAboutBlankURL))
568 return;
569 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 564 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
570 frame_tree_node_id, item_sequence_number, document_sequence_number, 565 frame_tree_node_id, item_sequence_number, document_sequence_number,
571 site_instance, url, referrer); 566 site_instance, url, referrer);
572 frame_entry->set_page_state(page_state); 567 frame_entry->set_page_state(page_state);
573 parent_node->children.push_back( 568 parent_node->children.push_back(
574 new NavigationEntryImpl::TreeNode(frame_entry)); 569 new NavigationEntryImpl::TreeNode(frame_entry));
575 } 570 }
576 571
577 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 572 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
578 FrameTreeNode* frame_tree_node) const { 573 FrameTreeNode* frame_tree_node) const {
(...skipping 27 matching lines...) Expand all
606 return node; 601 return node;
607 } 602 }
608 // Enqueue any children and keep looking. 603 // Enqueue any children and keep looking.
609 for (auto& child : node->children) 604 for (auto& child : node->children)
610 work_queue.push(child); 605 work_queue.push(child);
611 } 606 }
612 return nullptr; 607 return nullptr;
613 } 608 }
614 609
615 } // namespace content 610 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_browsertest.cc ('k') | content/browser/frame_host/navigation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698