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

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

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: Update singly-included comment 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 #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
OLDNEW
« no previous file with comments | « content/public/common/message_port_types.h ('k') | content/renderer/service_worker/service_worker_script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698