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

Side by Side Diff: components/sessions/core/session_command.cc

Issue 1361613002: Move all core files in //components/sessions into core/ subdir (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2006 The Chromium Authors. All rights reserved. 1 // Copyright 2006 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits> 5 #include <limits>
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "components/sessions/session_command.h" 8 #include "components/sessions/core/session_command.h"
9 9
10 namespace sessions { 10 namespace sessions {
11 11
12 SessionCommand::SessionCommand(id_type id, size_type size) 12 SessionCommand::SessionCommand(id_type id, size_type size)
13 : id_(id), 13 : id_(id),
14 contents_(size, 0) { 14 contents_(size, 0) {
15 } 15 }
16 16
17 SessionCommand::SessionCommand(id_type id, const base::Pickle& pickle) 17 SessionCommand::SessionCommand(id_type id, const base::Pickle& pickle)
18 : id_(id), 18 : id_(id),
19 contents_(pickle.size(), 0) { 19 contents_(pickle.size(), 0) {
20 DCHECK(pickle.size() < std::numeric_limits<size_type>::max()); 20 DCHECK(pickle.size() < std::numeric_limits<size_type>::max());
21 memcpy(contents(), pickle.data(), pickle.size()); 21 memcpy(contents(), pickle.data(), pickle.size());
22 } 22 }
23 23
24 bool SessionCommand::GetPayload(void* dest, size_t count) const { 24 bool SessionCommand::GetPayload(void* dest, size_t count) const {
25 if (size() != count) 25 if (size() != count)
26 return false; 26 return false;
27 memcpy(dest, &(contents_[0]), count); 27 memcpy(dest, &(contents_[0]), count);
28 return true; 28 return true;
29 } 29 }
30 30
31 base::Pickle* SessionCommand::PayloadAsPickle() const { 31 base::Pickle* SessionCommand::PayloadAsPickle() const {
32 return new base::Pickle(contents(), static_cast<int>(size())); 32 return new base::Pickle(contents(), static_cast<int>(size()));
33 } 33 }
34 34
35 } // namespace sessions 35 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/core/session_command.h ('k') | components/sessions/core/session_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698