OLD | NEW |
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 #ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ | 5 #ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |
6 #define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ | 6 #define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "extensions/browser/api/messaging/native_message_host.h" | 12 #include "extensions/browser/api/messaging/native_message_host.h" |
12 #include "extensions/browser/api/messaging/native_messaging_channel.h" | 13 #include "extensions/browser/api/messaging/native_messaging_channel.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class Value; | 16 class Value; |
16 } | 17 } |
17 | 18 |
18 namespace remoting { | 19 namespace remoting { |
19 | 20 |
20 // Connects a extensions::NativeMessageHost to a PipeMessagingChannel. | 21 // Connects a extensions::NativeMessageHost to a PipeMessagingChannel. |
21 class NativeMessagingPipe | 22 class NativeMessagingPipe |
22 : public extensions::NativeMessagingChannel::EventHandler, | 23 : public extensions::NativeMessagingChannel::EventHandler, |
23 public extensions::NativeMessageHost::Client { | 24 public extensions::NativeMessageHost::Client { |
24 public: | 25 public: |
25 NativeMessagingPipe(); | 26 NativeMessagingPipe(); |
26 ~NativeMessagingPipe() override; | 27 ~NativeMessagingPipe() override; |
27 | 28 |
28 // Starts processing messages from the pipe. | 29 // Starts processing messages from the pipe. |
29 void Start(scoped_ptr<extensions::NativeMessageHost> host, | 30 void Start(std::unique_ptr<extensions::NativeMessageHost> host, |
30 scoped_ptr<extensions::NativeMessagingChannel> channel); | 31 std::unique_ptr<extensions::NativeMessagingChannel> channel); |
31 | 32 |
32 // extensions::NativeMessageHost::Client implementation. | 33 // extensions::NativeMessageHost::Client implementation. |
33 void PostMessageFromNativeHost(const std::string& message) override; | 34 void PostMessageFromNativeHost(const std::string& message) override; |
34 void CloseChannel(const std::string& error_message) override; | 35 void CloseChannel(const std::string& error_message) override; |
35 | 36 |
36 // extensions::NativeMessagingChannel::EventHandler implementation. | 37 // extensions::NativeMessagingChannel::EventHandler implementation. |
37 void OnMessage(scoped_ptr<base::Value> message) override; | 38 void OnMessage(std::unique_ptr<base::Value> message) override; |
38 void OnDisconnect() override; | 39 void OnDisconnect() override; |
39 | 40 |
40 private: | 41 private: |
41 scoped_ptr<extensions::NativeMessagingChannel> channel_; | 42 std::unique_ptr<extensions::NativeMessagingChannel> channel_; |
42 scoped_ptr<extensions::NativeMessageHost> host_; | 43 std::unique_ptr<extensions::NativeMessageHost> host_; |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(NativeMessagingPipe); | 45 DISALLOW_COPY_AND_ASSIGN(NativeMessagingPipe); |
45 }; | 46 }; |
46 | 47 |
47 } // namespace remoting | 48 } // namespace remoting |
48 | 49 |
49 #endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ | 50 #endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |
OLD | NEW |