Commit 4c5156d3 authored by skuhne's avatar skuhne Committed by Commit bot

Removing Migraction code from M17 in session restore

BUG=424679
TEST=-

Review URL: https://codereview.chromium.org/665033003

Cr-Commit-Position: refs/heads/master@{#300503}
parent 3a09fd48
......@@ -60,10 +60,9 @@ static const SessionCommand::id_type kCommandSetTabWindow = 0;
// OBSOLETE Superseded by kCommandSetWindowBounds3.
// static const SessionCommand::id_type kCommandSetWindowBounds = 1;
static const SessionCommand::id_type kCommandSetTabIndexInWindow = 2;
// Original kCommandTabClosed/kCommandWindowClosed. See comment in
// MigrateClosedPayload for details on why they were replaced.
static const SessionCommand::id_type kCommandTabClosedObsolete = 3;
static const SessionCommand::id_type kCommandWindowClosedObsolete = 4;
// OBSOLETE Superseded kCommandTabClosed/kCommandWindowClosed commands.
// static const SessionCommand::id_type kCommandTabClosedObsolete = 3;
// static const SessionCommand::id_type kCommandWindowClosedObsolete = 4;
static const SessionCommand::id_type
kCommandTabNavigationPathPrunedFromBack = 5;
static const SessionCommand::id_type kCommandUpdateTabNavigation = 6;
......@@ -198,31 +197,6 @@ ui::WindowShowState PersistedShowStateToShowState(int state) {
return ui::SHOW_STATE_NORMAL;
}
// Migrates a |ClosedPayload|, returning true on success (migration was
// necessary and happened), or false (migration was not necessary or was not
// successful).
bool MigrateClosedPayload(const SessionCommand& command,
ClosedPayload* payload) {
#if defined(OS_CHROMEOS)
// Pre M17 versions of chromeos were 32bit. Post M17 is 64 bit. Apparently the
// 32 bit versions of chrome on pre M17 resulted in a sizeof 12 for the
// ClosedPayload, where as post M17 64-bit gives a sizeof 16 (presumably the
// struct is padded).
if ((command.id() == kCommandWindowClosedObsolete ||
command.id() == kCommandTabClosedObsolete) &&
command.size() == 12 && sizeof(payload->id) == 4 &&
sizeof(payload->close_time) == 8) {
memcpy(&payload->id, command.contents(), 4);
memcpy(&payload->close_time, command.contents() + 4, 8);
return true;
} else {
return false;
}
#else
return false;
#endif
}
} // namespace
// SessionService -------------------------------------------------------------
......@@ -1143,18 +1117,14 @@ bool SessionService::CreateTabsAndWindows(
break;
}
case kCommandTabClosedObsolete:
case kCommandWindowClosedObsolete:
case kCommandTabClosed:
case kCommandWindowClosed: {
ClosedPayload payload;
if (!command->GetPayload(&payload, sizeof(payload)) &&
!MigrateClosedPayload(*command, &payload)) {
if (!command->GetPayload(&payload, sizeof(payload))) {
VLOG(1) << "Failed reading command " << command->id();
return true;
}
if (command->id() == kCommandTabClosed ||
command->id() == kCommandTabClosedObsolete) {
if (command->id() == kCommandTabClosed) {
delete GetTab(payload.id, tabs);
tabs->erase(payload.id);
} else {
......
......@@ -826,35 +826,6 @@ TEST_F(SessionServiceTest, RemovePostDataWithPasswords) {
windows[0]->tabs[0]->navigations[0].encoded_page_state());
}
// This test is only applicable to chromeos.
#if defined(OS_CHROMEOS)
// Verifies migration of tab/window closed works.
TEST_F(SessionServiceTest, CanOpenV1TabClosed) {
base::FilePath v1_file_path;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &v1_file_path));
// v1_session_file contains a tab closed command with the original id. The
// file was generated from ClosingTabStaysClosed. If we successfully processed
// the file we'll have one tab.
v1_file_path =
v1_file_path.AppendASCII("sessions").AppendASCII("v1_session_file");
base::FilePath dest_file_path(path_);
dest_file_path = dest_file_path.AppendASCII("Current Session");
// Forces closing the file.
helper_.SetService(NULL);
ASSERT_TRUE(base::CopyFile(v1_file_path, dest_file_path));
SessionService* session_service = new SessionService(path_);
helper_.SetService(session_service);
ScopedVector<SessionWindow> windows;
SessionID::id_type active_window_id = 0;
helper_.ReadWindows(&(windows.get()), &active_window_id);
ASSERT_EQ(1u, windows.size());
EXPECT_EQ(1u, windows[0]->tabs.size());
}
#endif // defined(OS_CHROMEOS)
TEST_F(SessionServiceTest, ReplacePendingNavigation) {
const std::string base_url("http://google.com/");
SessionID tab_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment