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 #ifndef CONTENT_PUBLIC_COMMON_MESSAGE_PORT_TYPES_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_MESSAGE_PORT_TYPES_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/string16.h" |
| 12 #include "base/values.h" |
| 13 #include "content/common/content_export.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // Struct representing a message sent across a message port. This struct hides |
| 18 // the fact that messages can be serialized/encoded in multiple ways from code |
| 19 // that doesn't care about the message contents. |
| 20 struct CONTENT_EXPORT MessagePortMessage { |
| 21 MessagePortMessage(); |
| 22 explicit MessagePortMessage(const base::string16& message); |
| 23 explicit MessagePortMessage(scoped_ptr<base::Value> message); |
| 24 MessagePortMessage(const MessagePortMessage& other); |
| 25 MessagePortMessage& operator=(const MessagePortMessage& other); |
| 26 ~MessagePortMessage(); |
| 27 |
| 28 bool is_string() const { return !message_as_string.empty(); } |
| 29 bool is_value() const { return !message_as_value.empty(); } |
| 30 const base::Value* as_value() const; |
| 31 |
| 32 // Message serialized using blink::WebSerializedScriptValue. Only one of |
| 33 // |message_as_string| and |message_as_value| should be non-empty. |
| 34 base::string16 message_as_string; |
| 35 // Message as a base::Value. This is either an empty list or a list |
| 36 // containing exactly one item. |
| 37 base::ListValue message_as_value; |
| 38 }; |
| 39 |
| 40 } // namespace content |
| 41 |
| 42 #endif // CONTENT_PUBLIC_COMMON_MESSAGE_PORT_TYPES_H_ |
OLD | NEW |