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

Unified Diff: components/sessions/core/tab_restore_service_helper.h

Issue 2200993004: Make TabRestoreService::Entry noncopyable and fix up surrounding code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tab-test-cleanup
Patch Set: Eliminate a use-after-free, Windows build fix Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/sessions/core/tab_restore_service_helper.h
diff --git a/components/sessions/core/tab_restore_service_helper.h b/components/sessions/core/tab_restore_service_helper.h
index 8a9ed4840820534733f49219e5576f76bd5ea0b6..b6c3a47cb8412a78e14861e70f869ec381df149b 100644
--- a/components/sessions/core/tab_restore_service_helper.h
+++ b/components/sessions/core/tab_restore_service_helper.h
@@ -78,7 +78,7 @@ class SESSIONS_EXPORT TabRestoreServiceHelper {
void ClearEntries();
const Entries& entries() const;
std::vector<LiveTab*> RestoreMostRecentEntry(LiveTabContext* context);
- Tab* RemoveTabEntryById(SessionID::id_type id);
+ std::unique_ptr<Tab> RemoveTabEntryById(SessionID::id_type id);
std::vector<LiveTab*> RestoreEntryById(LiveTabContext* context,
SessionID::id_type id,
WindowOpenDisposition disposition);
@@ -89,11 +89,11 @@ class SESSIONS_EXPORT TabRestoreServiceHelper {
// Notifies observers the service has loaded.
void NotifyLoaded();
- // Adds |entry| to the list of entries and takes ownership. If |prune| is true
- // |PruneAndNotify| is invoked. If |to_front| is true the entry is added to
- // the front, otherwise the back. Normal closes go to the front, but
- // tab/window closes from the previous session are added to the back.
- void AddEntry(Entry* entry, bool prune, bool to_front);
+ // Adds |entry| to the list of entries. If |prune| is true |PruneAndNotify| is
+ // invoked. If |to_front| is true the entry is added to the front, otherwise
+ // the back. Normal closes go to the front, but tab/window closes from the
+ // previous session are added to the back.
+ void AddEntry(std::unique_ptr<Entry> entry, bool prune, bool to_front);
// Prunes |entries_| to contain only kMaxEntries, and removes uninteresting
// entries.
@@ -106,7 +106,7 @@ class SESSIONS_EXPORT TabRestoreServiceHelper {
Entries::iterator GetEntryIteratorById(SessionID::id_type id);
// Calls either ValidateTab or ValidateWindow as appropriate.
- static bool ValidateEntry(Entry* entry);
+ static bool ValidateEntry(const Entry& entry);
private:
friend class PersistentTabRestoreService;
@@ -130,23 +130,22 @@ class SESSIONS_EXPORT TabRestoreServiceHelper {
WindowOpenDisposition disposition,
LiveTab** live_tab);
- // Returns true if |tab| has more than one navigation. If |tab| has more
- // than one navigation |tab->current_navigation_index| is constrained based
- // on the number of navigations.
- static bool ValidateTab(Tab* tab);
+ // Returns true if |tab| has at least one navigation and
+ // |tab->current_navigation_index| is in bounds.
+ static bool ValidateTab(const Tab& tab);
// Validates all the tabs in a window, plus the window's active tab index.
- static bool ValidateWindow(Window* window);
+ static bool ValidateWindow(const Window& window);
// Returns true if |tab| is one we care about restoring.
- bool IsTabInteresting(const Tab* tab);
+ bool IsTabInteresting(const Tab& tab);
// Checks whether |window| is interesting --- if it only contains a single,
// uninteresting tab, it's not interesting.
- bool IsWindowInteresting(const Window* window);
+ bool IsWindowInteresting(const Window& window);
// Validates and checks |entry| for interesting.
- bool FilterEntry(Entry* entry);
+ bool FilterEntry(const Entry& entry);
// Finds tab entries with the old browser_id and sets it to the new one.
void UpdateTabBrowserIDs(SessionID::id_type old_id,

Powered by Google App Engine
This is Rietveld 408576698