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

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: 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..59581015c80f488d9e5c9448c1711342e31651fe 100644
--- a/components/sessions/core/session_service_commands.cc
+++ b/components/sessions/core/session_service_commands.cc
@@ -584,15 +584,13 @@ bool CreateTabsAndWindows(const ScopedVector<SessionCommand>& data,
case kCommandSetWindowWorkspace: {
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,10 +757,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()));
+ new SessionCommand(kCommandSetWindowWorkspace, pickle));
memcpy(command->contents(), pickle.data(), pickle.size());
sky 2016/05/06 21:31:49 This line shouldn't be necessary anymore.
Tom (Use chromium acct) 2016/05/06 22:14:50 Done.
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