Clarify and update GN build flags docs.
[chromium-blink-merge.git] / components / sessions / session_command.cc
blob59fc6fcd872e06ec5571df897feadf00ce8d1a51
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
3 // found in the LICENSE file.
5 #include <limits>
7 #include "base/pickle.h"
8 #include "components/sessions/session_command.h"
10 namespace sessions {
12 SessionCommand::SessionCommand(id_type id, size_type size)
13 : id_(id),
14 contents_(size, 0) {
17 SessionCommand::SessionCommand(id_type id, const Pickle& pickle)
18 : id_(id),
19 contents_(pickle.size(), 0) {
20 DCHECK(pickle.size() < std::numeric_limits<size_type>::max());
21 memcpy(contents(), pickle.data(), pickle.size());
24 bool SessionCommand::GetPayload(void* dest, size_t count) const {
25 if (size() != count)
26 return false;
27 memcpy(dest, &(contents_[0]), count);
28 return true;
31 Pickle* SessionCommand::PayloadAsPickle() const {
32 return new Pickle(contents(), static_cast<int>(size()));
35 } // namespace sessions