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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 NativeMessagingPipe::NativeMessagingPipe() {} 16 NativeMessagingPipe::NativeMessagingPipe() {}
17 NativeMessagingPipe::~NativeMessagingPipe() {} 17 NativeMessagingPipe::~NativeMessagingPipe() {}
18 18
19 void NativeMessagingPipe::Start( 19 void NativeMessagingPipe::Start(
20 scoped_ptr<extensions::NativeMessageHost> host, 20 std::unique_ptr<extensions::NativeMessageHost> host,
21 scoped_ptr<extensions::NativeMessagingChannel> channel) { 21 std::unique_ptr<extensions::NativeMessagingChannel> channel) {
22 host_ = std::move(host); 22 host_ = std::move(host);
23 channel_ = std::move(channel); 23 channel_ = std::move(channel);
24 channel_->Start(this); 24 channel_->Start(this);
25 } 25 }
26 26
27 void NativeMessagingPipe::OnMessage(scoped_ptr<base::Value> message) { 27 void NativeMessagingPipe::OnMessage(std::unique_ptr<base::Value> message) {
28 std::string message_json; 28 std::string message_json;
29 base::JSONWriter::Write(*message, &message_json); 29 base::JSONWriter::Write(*message, &message_json);
30 host_->OnMessage(message_json); 30 host_->OnMessage(message_json);
31 } 31 }
32 32
33 void NativeMessagingPipe::OnDisconnect() { 33 void NativeMessagingPipe::OnDisconnect() {
34 host_.reset(); 34 host_.reset();
35 channel_.reset(); 35 channel_.reset();
36 } 36 }
37 37
38 void NativeMessagingPipe::PostMessageFromNativeHost( 38 void NativeMessagingPipe::PostMessageFromNativeHost(
39 const std::string& message) { 39 const std::string& message) {
40 scoped_ptr<base::Value> json = base::JSONReader::Read(message); 40 std::unique_ptr<base::Value> json = base::JSONReader::Read(message);
41 channel_->SendMessage(std::move(json)); 41 channel_->SendMessage(std::move(json));
42 } 42 }
43 43
44 void NativeMessagingPipe::CloseChannel(const std::string& error_message) { 44 void NativeMessagingPipe::CloseChannel(const std::string& error_message) {
45 host_.reset(); 45 host_.reset();
46 channel_.reset(); 46 channel_.reset();
47 } 47 }
48 48
49 } // namespace remoting 49 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/native_messaging/native_messaging_pipe.h ('k') | remoting/host/native_messaging/native_messaging_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698