Chromium Code Reviews| Index: remoting/host/native_messaging/pipe_messaging_channel.h |
| diff --git a/remoting/host/native_messaging/pipe_messaging_channel.h b/remoting/host/native_messaging/pipe_messaging_channel.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..80d54d1e74c9ca6291d618c1c9a647bae16debba |
| --- /dev/null |
| +++ b/remoting/host/native_messaging/pipe_messaging_channel.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
|
Sergey Ulanov
2014/09/17 02:32:23
year
kelvinp
2014/09/17 23:06:17
Done.
|
| +// 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_PIPE_MESSAGING_CHANNEL_H_ |
| +#define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/files/file.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "extensions/browser/api/messaging/native_messaging_channel.h" |
| +#include "remoting/host/native_messaging/native_messaging_reader.h" |
| +#include "remoting/host/native_messaging/native_messaging_writer.h" |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +class Value; |
| +} // namespace base |
| + |
| +namespace remoting { |
| + |
| +// An implementation of |extensions::NativeMessagingChannel| using a pipe. It |
|
Sergey Ulanov
2014/09/17 02:32:23
don't need | around type names
kelvinp
2014/09/17 23:06:16
Done.
|
| +// is used by the |It2MeNativeMessagingHost| and |Me2MeNativeMessagingHost| to |
| +// communicate with the chrome process. |
| +// TODO(kelvinp): Move this class to the extensions/browser/api/messaging |
| +// directory. |
| +class PipeMessagingChannel : public extensions::NativeMessagingChannel, |
| + public base::NonThreadSafe { |
| + public: |
| + typedef extensions::NativeMessagingChannel::EventHandler EventHandler; |
| + |
| + // Constructs an object taking the ownership of |input| and |output|. Closes |
| + // |input| and |output| to prevent the caller from using them. |
| + PipeMessagingChannel(base::File input, base::File output); |
| + virtual ~PipeMessagingChannel(); |
| + |
| + // extensions::NativeMessagingChannel implementation. |
| + virtual void Start(EventHandler* event_handler) OVERRIDE; |
| + virtual void SendMessage(scoped_ptr<base::Value> message) OVERRIDE; |
| + |
| + private: |
| + // Processes a message received from the client app. |
| + void ProcessMessage(scoped_ptr<base::Value> message); |
| + |
| + // Initiates shutdown and runs |quit_closure| if there are no pending requests |
|
Sergey Ulanov
2014/09/17 02:32:23
there is no |quit_closure| anymore
kelvinp
2014/09/17 23:06:16
Done.
|
| + // left. |
| + void Shutdown(); |
| + |
| + NativeMessagingReader native_messaging_reader_; |
| + scoped_ptr<NativeMessagingWriter> native_messaging_writer_; |
| + |
| + EventHandler* event_handler_; |
| + base::WeakPtr<PipeMessagingChannel> weak_ptr_; |
| + base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ |