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

Unified Diff: components/sessions/core/session_service_commands.cc

Issue 2600583002: Remove ScopedVector from components/sessions. (Closed)
Patch Set: include Created 3 years, 12 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/session_service_commands.cc
diff --git a/components/sessions/core/session_service_commands.cc b/components/sessions/core/session_service_commands.cc
index 9e506ee11237fb507fe759792a8c165f847a87b5..ecedfe642e78b818905e43dd1e083fe4ecc05d64 100644
--- a/components/sessions/core/session_service_commands.cc
+++ b/components/sessions/core/session_service_commands.cc
@@ -323,17 +323,18 @@ void AddTabsToWindows(IdToSessionTab* tabs, IdToSessionWindow* windows) {
//
// This does NOT add any created SessionTabs to SessionWindow.tabs, that is
// done by AddTabsToWindows.
-bool CreateTabsAndWindows(const ScopedVector<SessionCommand>& data,
- IdToSessionTab* tabs,
- IdToSessionWindow* windows,
- SessionID::id_type* active_window_id) {
+bool CreateTabsAndWindows(
+ const std::vector<std::unique_ptr<SessionCommand>>& data,
+ IdToSessionTab* tabs,
+ IdToSessionWindow* windows,
+ SessionID::id_type* active_window_id) {
// If the file is corrupt (command with wrong size, or unknown command), we
// still return true and attempt to restore what we we can.
DVLOG(1) << "CreateTabsAndWindows";
- for (auto i = data.begin(); i != data.end(); ++i) {
+ for (const auto& command_ptr : data) {
const SessionCommand::id_type kCommandSetWindowBounds2 = 10;
- const SessionCommand* command = *i;
+ const SessionCommand* command = command_ptr.get();
DVLOG(1) << "Read command " << (int) command->id();
switch (command->id()) {
@@ -825,10 +826,9 @@ bool ReplacePendingCommand(BaseSessionService* base_session_service,
(*command)->id() != kCommandSetActiveWindow) {
return false;
}
- for (ScopedVector<SessionCommand>::const_reverse_iterator i =
- base_session_service->pending_commands().rbegin();
+ for (auto i = base_session_service->pending_commands().rbegin();
i != base_session_service->pending_commands().rend(); ++i) {
- SessionCommand* existing_command = *i;
+ SessionCommand* existing_command = i->get();
if ((*command)->id() == kCommandUpdateTabNavigation &&
existing_command->id() == kCommandUpdateTabNavigation) {
std::unique_ptr<base::Pickle> command_pickle(
@@ -859,8 +859,8 @@ bool ReplacePendingCommand(BaseSessionService* base_session_service,
// existing_command is an update for the same tab/index pair. Replace
// it with the new one. We need to add to the end of the list just in
// case there is a prune command after the update command.
- base_session_service->EraseCommand(*(i.base() - 1));
- base_session_service->AppendRebuildCommand((std::move(*command)));
+ base_session_service->EraseCommand((i.base() - 1)->get());
+ base_session_service->AppendRebuildCommand(std::move(*command));
return true;
}
return false;
@@ -881,7 +881,7 @@ bool IsClosingCommand(SessionCommand* command) {
}
void RestoreSessionFromCommands(
- const ScopedVector<SessionCommand>& commands,
+ const std::vector<std::unique_ptr<SessionCommand>>& commands,
std::vector<std::unique_ptr<SessionWindow>>* valid_windows,
SessionID::id_type* active_window_id) {
IdToSessionTab tabs;
« no previous file with comments | « components/sessions/core/session_service_commands.h ('k') | components/sessions/core/tab_restore_service_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698