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

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

Issue 1944013003: Move ownership of source SiteInstance to the FrameNavigationEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 int32_t NavigationEntryImpl::GetPageID() const { 326 int32_t NavigationEntryImpl::GetPageID() const {
327 return page_id_; 327 return page_id_;
328 } 328 }
329 329
330 void NavigationEntryImpl::set_site_instance( 330 void NavigationEntryImpl::set_site_instance(
331 scoped_refptr<SiteInstanceImpl> site_instance) { 331 scoped_refptr<SiteInstanceImpl> site_instance) {
332 // TODO(creis): Update all callers and remove this method. 332 // TODO(creis): Update all callers and remove this method.
333 frame_tree_->frame_entry->set_site_instance(std::move(site_instance)); 333 frame_tree_->frame_entry->set_site_instance(std::move(site_instance));
334 } 334 }
335 335
336 void NavigationEntryImpl::set_source_site_instance(
337 SiteInstanceImpl* source_site_instance) {
338 source_site_instance_ = source_site_instance;
339 }
340
341 void NavigationEntryImpl::SetBindings(int bindings) { 336 void NavigationEntryImpl::SetBindings(int bindings) {
342 // Ensure this is set to a valid value, and that it stays the same once set. 337 // Ensure this is set to a valid value, and that it stays the same once set.
343 CHECK_NE(bindings, kInvalidBindings); 338 CHECK_NE(bindings, kInvalidBindings);
344 CHECK(bindings_ == kInvalidBindings || bindings_ == bindings); 339 CHECK(bindings_ == kInvalidBindings || bindings_ == bindings);
345 bindings_ = bindings; 340 bindings_ = bindings;
346 } 341 }
347 342
348 const base::string16& NavigationEntryImpl::GetTitleForDisplay() const { 343 const base::string16& NavigationEntryImpl::GetTitleForDisplay() const {
349 // Most pages have real titles. Don't even bother caching anything if this is 344 // Most pages have real titles. Don't even bother caching anything if this is
350 // the case. 345 // the case.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 GURL data_url(std::string( 651 GURL data_url(std::string(
657 GetDataURLAsString()->front_as<char>(), 652 GetDataURLAsString()->front_as<char>(),
658 std::min(GetDataURLAsString()->size(), kDataUriPrefixMaxLen))); 653 std::min(GetDataURLAsString()->size(), kDataUriPrefixMaxLen)));
659 if (data_url.is_valid() && data_url.SchemeIs(url::kDataScheme)) 654 if (data_url.is_valid() && data_url.SchemeIs(url::kDataScheme))
660 request_params.data_url_as_string = GetDataURLAsString()->data(); 655 request_params.data_url_as_string = GetDataURLAsString()->data();
661 } 656 }
662 #endif 657 #endif
663 return request_params; 658 return request_params;
664 } 659 }
665 660
666 void NavigationEntryImpl::ResetForCommit() { 661 void NavigationEntryImpl::ResetForCommit(FrameNavigationEntry* frame_entry) {
667 // Any state that only matters when a navigation entry is pending should be 662 // Any state that only matters when a navigation entry is pending should be
668 // cleared here. 663 // cleared here.
669 // TODO(creis): This state should be moved to NavigationRequest once 664 // TODO(creis): This state should be moved to NavigationRequest once
670 // PlzNavigate is enabled. 665 // PlzNavigate is enabled.
671 SetBrowserInitiatedPostData(nullptr); 666 SetBrowserInitiatedPostData(nullptr);
672 set_source_site_instance(nullptr);
673 set_is_renderer_initiated(false); 667 set_is_renderer_initiated(false);
674 set_transferred_global_request_id(GlobalRequestID()); 668 set_transferred_global_request_id(GlobalRequestID());
675 set_should_replace_entry(false); 669 set_should_replace_entry(false);
676 670
677 set_should_clear_history_list(false); 671 set_should_clear_history_list(false);
678 set_frame_tree_node_id(-1); 672 set_frame_tree_node_id(-1);
679 673
674 if (frame_entry)
675 frame_entry->set_source_site_instance(nullptr);
676
680 #if defined(OS_ANDROID) 677 #if defined(OS_ANDROID)
681 // Reset the time stamp so that the metrics are not reported if this entry is 678 // Reset the time stamp so that the metrics are not reported if this entry is
682 // loaded again in the future. 679 // loaded again in the future.
683 set_intent_received_timestamp(base::TimeTicks()); 680 set_intent_received_timestamp(base::TimeTicks());
684 #endif 681 #endif
685 } 682 }
686 683
687 void NavigationEntryImpl::AddOrUpdateFrameEntry( 684 void NavigationEntryImpl::AddOrUpdateFrameEntry(
688 FrameTreeNode* frame_tree_node, 685 FrameTreeNode* frame_tree_node,
689 int64_t item_sequence_number, 686 int64_t item_sequence_number,
690 int64_t document_sequence_number, 687 int64_t document_sequence_number,
688 SiteInstanceImpl* source_site_instance,
691 SiteInstanceImpl* site_instance, 689 SiteInstanceImpl* site_instance,
692 const GURL& url, 690 const GURL& url,
693 const Referrer& referrer, 691 const Referrer& referrer,
694 const PageState& page_state, 692 const PageState& page_state,
695 const std::string& method, 693 const std::string& method,
696 int64_t post_id) { 694 int64_t post_id) {
697 // We should already have a TreeNode for the parent node by the time this node 695 // We should already have a TreeNode for the parent node by the time this node
698 // commits. Find it first. 696 // commits. Find it first.
699 DCHECK(frame_tree_node->parent()); 697 DCHECK(frame_tree_node->parent());
700 NavigationEntryImpl::TreeNode* parent_node = 698 NavigationEntryImpl::TreeNode* parent_node =
701 FindFrameEntry(frame_tree_node->parent()); 699 FindFrameEntry(frame_tree_node->parent());
702 if (!parent_node) { 700 if (!parent_node) {
703 // The renderer should not send a commit for a subframe before its parent. 701 // The renderer should not send a commit for a subframe before its parent.
704 // TODO(creis): Kill the renderer if we get here. 702 // TODO(creis): Kill the renderer if we get here.
705 return; 703 return;
706 } 704 }
707 705
708 // Now check whether we have a TreeNode for the node itself. 706 // Now check whether we have a TreeNode for the node itself.
709 const std::string& unique_name = frame_tree_node->unique_name(); 707 const std::string& unique_name = frame_tree_node->unique_name();
710 for (TreeNode* child : parent_node->children) { 708 for (TreeNode* child : parent_node->children) {
711 if (child->frame_entry->frame_unique_name() == unique_name) { 709 if (child->frame_entry->frame_unique_name() == unique_name) {
712 // Update the existing FrameNavigationEntry (e.g., for replaceState). 710 // Update the existing FrameNavigationEntry (e.g., for replaceState).
713 child->frame_entry->UpdateEntry( 711 child->frame_entry->UpdateEntry(unique_name, item_sequence_number,
714 unique_name, item_sequence_number, document_sequence_number, 712 document_sequence_number,
715 site_instance, url, referrer, page_state, method, post_id); 713 source_site_instance, site_instance, url,
714 referrer, page_state, method, post_id);
716 return; 715 return;
717 } 716 }
718 } 717 }
719 718
720 // No entry exists yet, so create a new one. 719 // No entry exists yet, so create a new one.
721 // Unordered list, since we expect to look up entries by frame sequence number 720 // Unordered list, since we expect to look up entries by frame sequence number
722 // or unique name. 721 // or unique name.
723 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 722 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
724 unique_name, item_sequence_number, document_sequence_number, 723 unique_name, item_sequence_number, document_sequence_number,
725 site_instance, url, referrer, method, post_id); 724 site_instance, url, referrer, method, post_id);
726 frame_entry->set_page_state(page_state); 725 frame_entry->set_page_state(page_state);
726 frame_entry->set_source_site_instance(source_site_instance);
Charlie Reis 2016/05/04 23:03:01 I think we probably want to put this in the FrameN
nasko 2016/05/05 17:51:33 Done.
727 parent_node->children.push_back( 727 parent_node->children.push_back(
728 new NavigationEntryImpl::TreeNode(frame_entry)); 728 new NavigationEntryImpl::TreeNode(frame_entry));
729 } 729 }
730 730
731 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 731 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
732 FrameTreeNode* frame_tree_node) const { 732 FrameTreeNode* frame_tree_node) const {
733 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 733 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
734 return tree_node ? tree_node->frame_entry.get() : nullptr; 734 return tree_node ? tree_node->frame_entry.get() : nullptr;
735 } 735 }
736 736
(...skipping 20 matching lines...) Expand all
757 return node; 757 return node;
758 758
759 // Enqueue any children and keep looking. 759 // Enqueue any children and keep looking.
760 for (auto& child : node->children) 760 for (auto& child : node->children)
761 work_queue.push(child); 761 work_queue.push(child);
762 } 762 }
763 return nullptr; 763 return nullptr;
764 } 764 }
765 765
766 } // namespace content 766 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698