Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sessions / session_command.cc
blobe5ca2f52e42b88fe442d6f7ce9b919a8d0e39ac7
1 // Copyright (c) 2006-2008 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 "chrome/browser/sessions/session_command.h"
9 #include "base/pickle.h"
11 SessionCommand::SessionCommand(id_type id, size_type size)
12 : id_(id),
13 contents_(size, 0) {
16 SessionCommand::SessionCommand(id_type id, const Pickle& pickle)
17 : id_(id),
18 contents_(pickle.size(), 0) {
19 DCHECK(pickle.size() < std::numeric_limits<size_type>::max());
20 memcpy(contents(), pickle.data(), pickle.size());
23 bool SessionCommand::GetPayload(void* dest, size_t count) const {
24 if (size() != count)
25 return false;
26 memcpy(dest, &(contents_[0]), count);
27 return true;
30 Pickle* SessionCommand::PayloadAsPickle() const {
31 return new Pickle(contents(), static_cast<int>(size()));