OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #include "content/public/common/message_port_types.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 MessagePortMessage::MessagePortMessage() { |
| 12 } |
| 13 |
| 14 MessagePortMessage::MessagePortMessage(const base::string16& message) |
| 15 : message_as_string(message) { |
| 16 } |
| 17 |
| 18 MessagePortMessage::MessagePortMessage(scoped_ptr<base::Value> message) { |
| 19 message_as_value.Append(message.release()); |
| 20 } |
| 21 |
| 22 MessagePortMessage::MessagePortMessage(const MessagePortMessage& other) { |
| 23 *this = other; |
| 24 } |
| 25 |
| 26 MessagePortMessage& MessagePortMessage::operator=( |
| 27 const MessagePortMessage& other) { |
| 28 message_as_string = other.message_as_string; |
| 29 message_as_value.Clear(); |
| 30 const base::Value* value; |
| 31 if (other.message_as_value.Get(0, &value)) |
| 32 message_as_value.Append(value->DeepCopy()); |
| 33 return *this; |
| 34 } |
| 35 |
| 36 MessagePortMessage::~MessagePortMessage() { |
| 37 } |
| 38 |
| 39 const base::Value* MessagePortMessage::as_value() const { |
| 40 const base::Value* value = nullptr; |
| 41 bool result = message_as_value.Get(0, &value); |
| 42 DCHECK(result); |
| 43 return value; |
| 44 } |
| 45 |
| 46 } // namespace content |
OLD | NEW |