Don't preload rarely seen large images
[chromium-blink-merge.git] / components / sessions / session_command.cc
bloba7cd59df24fe120d610d30c2f6aef5a7067966ea
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 base::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 base::Pickle* SessionCommand::PayloadAsPickle() const {
32 return new base::Pickle(contents(), static_cast<int>(size()));
35 } // namespace sessions