From 4717933ac94bf62a680bc8e77d66e43b35b70dec Mon Sep 17 00:00:00 2001 From: avi Date: Wed, 20 May 2015 14:01:11 -0700 Subject: Eliminate redundancy in the parameters to NotifyEntryChanged. BUG=369661 TEST=none Review URL: https://codereview.chromium.org/1143333003 Cr-Commit-Position: refs/heads/master@{#330800} --- chrome/browser/ui/browser.cc | 3 +-- content/browser/frame_host/navigation_controller_impl.cc | 7 ++++--- content/browser/frame_host/navigation_controller_impl.h | 2 +- content/browser/frame_host/navigation_entry_impl.cc | 5 +++++ content/browser/frame_host/navigation_entry_impl.h | 2 ++ content/browser/web_contents/web_contents_impl.cc | 9 ++++----- content/public/browser/navigation_controller.h | 5 ++--- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index c1556d9..1133a6f 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1114,8 +1114,7 @@ void Browser::TabReplacedAt(TabStripModel* tab_strip_model, if (entry_count > 0) { // Send out notification so that observers are updated appropriately. new_contents->GetController().NotifyEntryChanged( - new_contents->GetController().GetEntryAtIndex(entry_count - 1), - entry_count - 1); + new_contents->GetController().GetEntryAtIndex(entry_count - 1)); } if (session_service) { diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc index b9d6955..6ac3a10 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc @@ -1910,11 +1910,12 @@ void NavigationControllerImpl::LoadIfNecessary() { NavigateToPendingEntry(NO_RELOAD); } -void NavigationControllerImpl::NotifyEntryChanged(const NavigationEntry* entry, - int index) { +void NavigationControllerImpl::NotifyEntryChanged( + const NavigationEntry* entry) { EntryChangedDetails det; det.changed_entry = entry; - det.index = index; + det.index = GetIndexOfEntry( + NavigationEntryImpl::FromNavigationEntry(entry)); NotificationService::current()->Notify( NOTIFICATION_NAV_ENTRY_CHANGED, Source(this), diff --git a/content/browser/frame_host/navigation_controller_impl.h b/content/browser/frame_host/navigation_controller_impl.h index 85469401..ee00ca4 100644 --- a/content/browser/frame_host/navigation_controller_impl.h +++ b/content/browser/frame_host/navigation_controller_impl.h @@ -81,7 +81,7 @@ class CONTENT_EXPORT NavigationControllerImpl void Reload(bool check_for_repost) override; void ReloadIgnoringCache(bool check_for_repost) override; void ReloadOriginalRequestURL(bool check_for_repost) override; - void NotifyEntryChanged(const NavigationEntry* entry, int index) override; + void NotifyEntryChanged(const NavigationEntry* entry) override; void CopyStateFrom(const NavigationController& source) override; void CopyStateFromAndPrune(NavigationController* source, bool replace_entry) override; diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc index c2b7675..f7196a0 100644 --- a/content/browser/frame_host/navigation_entry_impl.cc +++ b/content/browser/frame_host/navigation_entry_impl.cc @@ -51,6 +51,11 @@ NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( return static_cast(entry); } +const NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( + const NavigationEntry* entry) { + return static_cast(entry); +} + NavigationEntryImpl::NavigationEntryImpl() : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), ui::PAGE_TRANSITION_LINK, false) { diff --git a/content/browser/frame_host/navigation_entry_impl.h b/content/browser/frame_host/navigation_entry_impl.h index 8c3fbb5..d5f43ea 100644 --- a/content/browser/frame_host/navigation_entry_impl.h +++ b/content/browser/frame_host/navigation_entry_impl.h @@ -50,6 +50,8 @@ class CONTENT_EXPORT NavigationEntryImpl }; static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry); + static const NavigationEntryImpl* FromNavigationEntry( + const NavigationEntry* entry); // The value of bindings() before it is set during commit. static int kInvalidBindings; diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index ec4b97b..43d74a2 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -3634,17 +3634,16 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh, // leaving a page, in which case our state may have already been moved to // the next page. The navigation controller will look up the appropriate // NavigationEntry and update it when it is notified via the delegate. - - int entry_index = controller_.GetEntryIndexWithPageID( + NavigationEntryImpl* entry = controller_.GetEntryWithPageID( rvh->GetSiteInstance(), page_id); - if (entry_index < 0) + + if (!entry) return; - NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index); if (page_state == entry->GetPageState()) return; // Nothing to update. entry->SetPageState(page_state); - controller_.NotifyEntryChanged(entry, entry_index); + controller_.NotifyEntryChanged(entry); } void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, diff --git a/content/public/browser/navigation_controller.h b/content/public/browser/navigation_controller.h index 358e850..7d890d5 100644 --- a/content/public/browser/navigation_controller.h +++ b/content/public/browser/navigation_controller.h @@ -410,9 +410,8 @@ class NavigationController { virtual bool IsInitialNavigation() const = 0; // Broadcasts the NOTIFICATION_NAV_ENTRY_CHANGED notification for the given - // entry (which must be at the given index). This will keep things in sync - // like the saved session. - virtual void NotifyEntryChanged(const NavigationEntry* entry, int index) = 0; + // entry. This will keep things in sync like the saved session. + virtual void NotifyEntryChanged(const NavigationEntry* entry) = 0; // Copies the navigation state from the given controller to this one. This // one should be empty (just created). -- cgit v1.1