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

Unified Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc

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: Get session ID from entries, take tabs' active status directly instead of an index 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: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
index c8e5fd264e797b70d45047ec0ee82caf2dcafdff..90b6687a3c3fc63842ee5c10954cf200980d9fb8 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc
@@ -440,27 +440,28 @@ void RecentTabsSubMenuModel::BuildLocalEntries() {
#endif
int added_count = 0;
- sessions::TabRestoreService::Entries entries = service->entries();
- for (sessions::TabRestoreService::Entries::const_iterator it =
- entries.begin();
- it != entries.end() && added_count < kMaxLocalEntries; ++it) {
- sessions::TabRestoreService::Entry* entry = *it;
- if (entry->type == sessions::TabRestoreService::TAB) {
- sessions::TabRestoreService::Tab* tab =
- static_cast<sessions::TabRestoreService::Tab*>(entry);
- const sessions::SerializedNavigationEntry& current_navigation =
- tab->navigations.at(tab->current_navigation_index);
- BuildLocalTabItem(
- entry->id,
- current_navigation.title(),
- current_navigation.virtual_url(),
- ++last_local_model_index_);
- } else {
- DCHECK_EQ(entry->type, sessions::TabRestoreService::WINDOW);
- BuildLocalWindowItem(
- entry->id, static_cast<sessions::TabRestoreService::Window*>(entry)
- ->tabs.size(),
- ++last_local_model_index_);
+ for (const auto& entry : service->entries()) {
+ if (added_count == kMaxLocalEntries)
+ break;
+ switch (entry->type) {
+ case sessions::TabRestoreService::TAB: {
+ auto& tab =
+ static_cast<const sessions::TabRestoreService::Tab&>(*entry);
+ const sessions::SerializedNavigationEntry& current_navigation =
+ tab.navigations.at(tab.current_navigation_index);
+ BuildLocalTabItem(entry->id, current_navigation.title(),
+ current_navigation.virtual_url(),
+ ++last_local_model_index_);
+ break;
+ }
+ case sessions::TabRestoreService::WINDOW: {
+ BuildLocalWindowItem(
+ entry->id,
+ static_cast<const sessions::TabRestoreService::Window&>(*entry)
+ .tabs.size(),
+ ++last_local_model_index_);
+ break;
+ }
}
++added_count;
}
« no previous file with comments | « chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm ('k') | chrome/browser/ui/views/frame/global_menu_bar_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698