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

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

Issue 1184423005: Add item and document sequence numbers to FrameNavigationEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add const; git cl format Created 5 years, 6 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
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ui::PAGE_TRANSITION_LINK, false) { 87 ui::PAGE_TRANSITION_LINK, false) {
88 } 88 }
89 89
90 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, 90 NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance,
91 int page_id, 91 int page_id,
92 const GURL& url, 92 const GURL& url,
93 const Referrer& referrer, 93 const Referrer& referrer,
94 const base::string16& title, 94 const base::string16& title,
95 ui::PageTransition transition_type, 95 ui::PageTransition transition_type,
96 bool is_renderer_initiated) 96 bool is_renderer_initiated)
97 : frame_tree_( 97 : frame_tree_(new TreeNode(
98 new TreeNode(new FrameNavigationEntry(-1, instance, url, referrer))), 98 new FrameNavigationEntry(-1, -1, -1, instance, url, referrer))),
99 unique_id_(GetUniqueIDInConstructor()), 99 unique_id_(GetUniqueIDInConstructor()),
100 bindings_(kInvalidBindings), 100 bindings_(kInvalidBindings),
101 page_type_(PAGE_TYPE_NORMAL), 101 page_type_(PAGE_TYPE_NORMAL),
102 update_virtual_url_with_url_(false), 102 update_virtual_url_with_url_(false),
103 title_(title), 103 title_(title),
104 page_id_(page_id), 104 page_id_(page_id),
105 transition_type_(transition_type), 105 transition_type_(transition_type),
106 has_post_data_(false), 106 has_post_data_(false),
107 post_id_(-1), 107 post_id_(-1),
108 restore_type_(RESTORE_NONE), 108 restore_type_(RESTORE_NONE),
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 set_frame_tree_node_id(-1); 497 set_frame_tree_node_id(-1);
498 498
499 #if defined(OS_ANDROID) 499 #if defined(OS_ANDROID)
500 // Reset the time stamp so that the metrics are not reported if this entry is 500 // Reset the time stamp so that the metrics are not reported if this entry is
501 // loaded again in the future. 501 // loaded again in the future.
502 set_intent_received_timestamp(base::TimeTicks()); 502 set_intent_received_timestamp(base::TimeTicks());
503 #endif 503 #endif
504 } 504 }
505 505
506 void NavigationEntryImpl::AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node, 506 void NavigationEntryImpl::AddOrUpdateFrameEntry(FrameTreeNode* frame_tree_node,
507 int64 item_sequence_number,
508 int64 document_sequence_number,
507 SiteInstanceImpl* site_instance, 509 SiteInstanceImpl* site_instance,
508 const GURL& url, 510 const GURL& url,
509 const Referrer& referrer, 511 const Referrer& referrer,
510 const PageState& page_state) { 512 const PageState& page_state) {
511 // We should already have a TreeNode for the parent node by the time this node 513 // We should already have a TreeNode for the parent node by the time this node
512 // commits. Find it first. 514 // commits. Find it first.
513 DCHECK(frame_tree_node->parent()); 515 DCHECK(frame_tree_node->parent());
514 NavigationEntryImpl::TreeNode* parent_node = 516 NavigationEntryImpl::TreeNode* parent_node =
515 FindFrameEntry(frame_tree_node->parent()); 517 FindFrameEntry(frame_tree_node->parent());
516 if (!parent_node) { 518 if (!parent_node) {
517 // The renderer should not send a commit for a subframe before its parent. 519 // The renderer should not send a commit for a subframe before its parent.
518 // However, we may see commits of subframes when their parent or ancestor is 520 // However, we may see commits of subframes when their parent or ancestor is
519 // still the initial about:blank page, and we don't currently keep a 521 // still the initial about:blank page, and we don't currently keep a
520 // FrameNavigationEntry for that. We ignore such commits, similar to how we 522 // FrameNavigationEntry for that. We ignore such commits, similar to how we
521 // handle them at the top level. 523 // handle them at the top level.
522 // TODO(creis): Consider creating FNEs for initial about:blank commits. 524 // TODO(creis): Consider creating FNEs for initial about:blank commits.
523 return; 525 return;
524 } 526 }
525 527
526 // Now check whether we have a TreeNode for the node itself. 528 // Now check whether we have a TreeNode for the node itself.
527 int frame_tree_node_id = frame_tree_node->frame_tree_node_id(); 529 int frame_tree_node_id = frame_tree_node->frame_tree_node_id();
528 for (TreeNode* child : parent_node->children) { 530 for (TreeNode* child : parent_node->children) {
529 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) { 531 if (child->frame_entry->frame_tree_node_id() == frame_tree_node_id) {
530 // Update the existing FrameNavigationEntry (e.g., for replaceState). 532 // Update the existing FrameNavigationEntry (e.g., for replaceState).
531 child->frame_entry->UpdateEntry(site_instance, url, referrer, page_state); 533 child->frame_entry->UpdateEntry(item_sequence_number,
534 document_sequence_number, site_instance,
535 url, referrer, page_state);
532 return; 536 return;
533 } 537 }
534 } 538 }
535 539
536 // No entry exists yet, so create a new one unless it's for about:blank. 540 // No entry exists yet, so create a new one unless it's for about:blank.
537 // Unordered list, since we expect to look up entries by frame sequence number 541 // Unordered list, since we expect to look up entries by frame sequence number
538 // or unique name. 542 // or unique name.
539 if (url == GURL(url::kAboutBlankURL)) 543 if (url == GURL(url::kAboutBlankURL))
540 return; 544 return;
541 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 545 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
542 frame_tree_node_id, site_instance, url, referrer); 546 frame_tree_node_id, item_sequence_number, document_sequence_number,
547 site_instance, url, referrer);
543 frame_entry->set_page_state(page_state); 548 frame_entry->set_page_state(page_state);
544 parent_node->children.push_back( 549 parent_node->children.push_back(
545 new NavigationEntryImpl::TreeNode(frame_entry)); 550 new NavigationEntryImpl::TreeNode(frame_entry));
546 } 551 }
547 552
548 bool NavigationEntryImpl::HasFrameEntry(FrameTreeNode* frame_tree_node) const { 553 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
549 return FindFrameEntry(frame_tree_node) != nullptr; 554 FrameTreeNode* frame_tree_node) const {
555 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
556 return tree_node ? tree_node->frame_entry.get() : nullptr;
550 } 557 }
551 558
552 void NavigationEntryImpl::SetScreenshotPNGData( 559 void NavigationEntryImpl::SetScreenshotPNGData(
553 scoped_refptr<base::RefCountedBytes> png_data) { 560 scoped_refptr<base::RefCountedBytes> png_data) {
554 screenshot_ = png_data; 561 screenshot_ = png_data;
555 if (screenshot_.get()) 562 if (screenshot_.get())
556 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); 563 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size());
557 } 564 }
558 565
559 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { 566 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const {
(...skipping 15 matching lines...) Expand all
575 return node; 582 return node;
576 } 583 }
577 // Enqueue any children and keep looking. 584 // Enqueue any children and keep looking.
578 for (auto& child : node->children) 585 for (auto& child : node->children)
579 work_queue.push(child); 586 work_queue.push(child);
580 } 587 }
581 return nullptr; 588 return nullptr;
582 } 589 }
583 590
584 } // namespace content 591 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698