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

Side by Side Diff: remoting/host/native_messaging/native_messaging_pipe.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/native_messaging/native_messaging_pipe.h" 5 #include "remoting/host/native_messaging/native_messaging_pipe.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 11
12 namespace remoting { 12 namespace remoting {
13 13
14 NativeMessagingPipe::NativeMessagingPipe() { 14 NativeMessagingPipe::NativeMessagingPipe() {
15 } 15 }
16 16
17 NativeMessagingPipe::~NativeMessagingPipe() { 17 NativeMessagingPipe::~NativeMessagingPipe() {
18 } 18 }
19 19
20 void NativeMessagingPipe::Start( 20 void NativeMessagingPipe::Start(
21 scoped_ptr<extensions::NativeMessageHost> host, 21 scoped_ptr<extensions::NativeMessageHost> host,
22 scoped_ptr<extensions::NativeMessagingChannel> channel) { 22 scoped_ptr<extensions::NativeMessagingChannel> channel) {
23 host_ = host.Pass(); 23 host_ = host.Pass();
24 channel_ = channel.Pass(); 24 channel_ = channel.Pass();
25 channel_->Start(this); 25 channel_->Start(this);
26 } 26 }
27 27
28 void NativeMessagingPipe::OnMessage(scoped_ptr<base::Value> message) { 28 void NativeMessagingPipe::OnMessage(scoped_ptr<base::Value> message) {
29 std::string message_json; 29 std::string message_json;
30 base::JSONWriter::Write(message.get(), &message_json); 30 base::JSONWriter::Write(*message, &message_json);
31 host_->OnMessage(message_json); 31 host_->OnMessage(message_json);
32 } 32 }
33 33
34 void NativeMessagingPipe::OnDisconnect() { 34 void NativeMessagingPipe::OnDisconnect() {
35 host_.reset(); 35 host_.reset();
36 channel_.reset(); 36 channel_.reset();
37 } 37 }
38 38
39 void NativeMessagingPipe::PostMessageFromNativeHost( 39 void NativeMessagingPipe::PostMessageFromNativeHost(
40 const std::string& message) { 40 const std::string& message) {
41 scoped_ptr<base::Value> json(base::JSONReader::Read(message)); 41 scoped_ptr<base::Value> json(base::JSONReader::Read(message));
42 channel_->SendMessage(json.Pass()); 42 channel_->SendMessage(json.Pass());
43 } 43 }
44 44
45 void NativeMessagingPipe::CloseChannel(const std::string& error_message) { 45 void NativeMessagingPipe::CloseChannel(const std::string& error_message) {
46 host_.reset(); 46 host_.reset();
47 channel_.reset(); 47 channel_.reset();
48 } 48 }
49 49
50 } // namespace remoting 50 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_native_messaging_host_unittest.cc ('k') | remoting/host/native_messaging/native_messaging_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698