Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: content/public/common/message_port_types.h

Issue 921013002: Optionally have MessagePort pass data as base::Value, part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-move-v8-value-converter
Patch Set: fix android webview compile Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
sgurun-gerrit only 2015/02/27 03:17:37 can't base::listvalue carry a string? why introduc
Marijn Kruisselbrink 2015/02/27 05:00:57 Yes, base::ListValue could carry a string. It woul
sgurun-gerrit only 2015/02/27 18:06:50 are you sure this is right? base::value seems to a
Marijn Kruisselbrink 2015/02/27 18:17:51 If you look at the base::string16 methods of base:
sgurun-gerrit only 2015/02/27 18:33:25 huh, that is interesting. I guess something to add
38 };
39
40 } // namespace content
41
42 #endif // CONTENT_PUBLIC_COMMON_MESSAGE_PORT_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698