Chromium Code Reviews| Index: remoting/host/native_messaging/native_messaging_pipe.h |
| diff --git a/remoting/host/native_messaging/native_messaging_pipe.h b/remoting/host/native_messaging/native_messaging_pipe.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a0e5bc040b80a02b91b54c218d8cf5a225c345f3 |
| --- /dev/null |
| +++ b/remoting/host/native_messaging/native_messaging_pipe.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |
| +#define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "extensions/browser/api/messaging/native_message_host.h" |
| +#include "extensions/browser/api/messaging/native_messaging_channel.h" |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +namespace remoting { |
| + |
| +// Connects a extensions::NativeMessageHost to a PipeMessagingChannel. |
| +class NativeMessagingPipe |
| + : public extensions::NativeMessagingChannel::EventHandler, |
| + public extensions::NativeMessageHost::Client, |
| + public base::SupportsWeakPtr<NativeMessagingPipe> { |
| + public: |
| + NativeMessagingPipe(); |
| + virtual ~NativeMessagingPipe(); |
| + |
| + void Init(scoped_ptr<extensions::NativeMessageHost> host, |
| + scoped_ptr<extensions::NativeMessagingChannel> channel); |
| + |
| + // Starts processing messages from the pipe. |
| + void Start(const base::Closure& quit_closure); |
|
Sergey Ulanov
2014/09/27 00:24:10
Do we need separate Init() and Start()? Merge them
kelvinp
2014/09/29 22:59:40
I think it is better to keep the construction of t
Sergey Ulanov
2014/09/30 20:33:39
I still think they shouldn't be separate unless yo
|
| + |
| + // extensions::NativeMessageHost::Client implementation. |
| + virtual void PostMessageFromNativeHost(const std::string& message) OVERRIDE; |
| + virtual void CloseChannel(const std::string& error_message) OVERRIDE; |
| + |
| + // extensions::NativeMessagingChannel::EventHandler implementation. |
| + virtual void OnMessage(scoped_ptr<base::Value> message) OVERRIDE; |
| + virtual void OnDisconnect() OVERRIDE; |
| + |
| + private: |
| + base::Closure quit_closure_; |
| + scoped_ptr<extensions::NativeMessagingChannel> channel_; |
| + scoped_ptr<extensions::NativeMessageHost> host_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NativeMessagingPipe); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_PIPE_H_ |