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

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

Issue 1961563002: Reduce some complexity in session_service_commands.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ca02f49e881f7e068ee42901490e71e9a14fd882..29b2f28a80279e1908f0cd2c7fa3960e8e3e1faf 100644
--- a/components/sessions/core/session_service_commands.cc
+++ b/components/sessions/core/session_service_commands.cc
@@ -42,7 +42,9 @@ static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18;
static const SessionCommand::id_type kCommandSessionStorageAssociated = 19;
static const SessionCommand::id_type kCommandSetActiveWindow = 20;
static const SessionCommand::id_type kCommandLastActiveTime = 21;
-static const SessionCommand::id_type kCommandSetWindowWorkspace = 22;
+// OBSOLETE Superseded by kCommandSetWindowWorkspace2.
+// static const SessionCommand::id_type kCommandSetWindowWorkspace = 22;
+static const SessionCommand::id_type kCommandSetWindowWorkspace2 = 23;
namespace {
@@ -581,18 +583,16 @@ bool CreateTabsAndWindows(const ScopedVector<SessionCommand>& data,
break;
}
- case kCommandSetWindowWorkspace: {
+ case kCommandSetWindowWorkspace2: {
std::unique_ptr<base::Pickle> pickle(command->PayloadAsPickle());
base::PickleIterator it(*pickle);
- const SessionID::id_type* window_id;
+ SessionID::id_type window_id;
std::string workspace;
- if (!it.ReadBytes(reinterpret_cast<const char**>(&window_id),
- sizeof(*window_id)) ||
- !it.ReadString(&workspace)) {
+ if (!it.ReadInt(&window_id) || !it.ReadString(&workspace)) {
DVLOG(1) << "Failed reading command " << command->id();
return true;
}
- GetWindow(*window_id, windows)->workspace = workspace;
+ GetWindow(window_id, windows)->workspace = workspace;
break;
}
@@ -759,11 +759,10 @@ std::unique_ptr<SessionCommand> CreateSetWindowWorkspaceCommand(
const SessionID& window_id,
const std::string& workspace) {
base::Pickle pickle;
- pickle.WriteBytes(static_cast<const void*>(&window_id), sizeof(window_id));
+ pickle.WriteInt(window_id.id());
pickle.WriteString(workspace);
std::unique_ptr<SessionCommand> command(
- new SessionCommand(kCommandSetWindowWorkspace, pickle.size()));
- memcpy(command->contents(), pickle.data(), pickle.size());
+ new SessionCommand(kCommandSetWindowWorkspace2, pickle));
return command;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698