| 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_PIPE_MESSAGING_CHANNEL_H_ | 5 #ifndef REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ |
| 6 #define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | 6 #define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // TODO(kelvinp): Move this class to the extensions/browser/api/messaging | 28 // TODO(kelvinp): Move this class to the extensions/browser/api/messaging |
| 29 // directory. | 29 // directory. |
| 30 class PipeMessagingChannel : public extensions::NativeMessagingChannel, | 30 class PipeMessagingChannel : public extensions::NativeMessagingChannel, |
| 31 public base::NonThreadSafe { | 31 public base::NonThreadSafe { |
| 32 public: | 32 public: |
| 33 typedef extensions::NativeMessagingChannel::EventHandler EventHandler; | 33 typedef extensions::NativeMessagingChannel::EventHandler EventHandler; |
| 34 | 34 |
| 35 // Constructs an object taking the ownership of |input| and |output|. Closes | 35 // Constructs an object taking the ownership of |input| and |output|. Closes |
| 36 // |input| and |output| to prevent the caller from using them. | 36 // |input| and |output| to prevent the caller from using them. |
| 37 PipeMessagingChannel(base::File input, base::File output); | 37 PipeMessagingChannel(base::File input, base::File output); |
| 38 virtual ~PipeMessagingChannel(); | 38 ~PipeMessagingChannel() override; |
| 39 | 39 |
| 40 // extensions::NativeMessagingChannel implementation. | 40 // extensions::NativeMessagingChannel implementation. |
| 41 virtual void Start(EventHandler* event_handler) override; | 41 void Start(EventHandler* event_handler) override; |
| 42 virtual void SendMessage(scoped_ptr<base::Value> message) override; | 42 void SendMessage(scoped_ptr<base::Value> message) override; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // Processes a message received from the client app. | 45 // Processes a message received from the client app. |
| 46 void ProcessMessage(scoped_ptr<base::Value> message); | 46 void ProcessMessage(scoped_ptr<base::Value> message); |
| 47 | 47 |
| 48 // Initiates shutdown. | 48 // Initiates shutdown. |
| 49 void Shutdown(); | 49 void Shutdown(); |
| 50 | 50 |
| 51 NativeMessagingReader native_messaging_reader_; | 51 NativeMessagingReader native_messaging_reader_; |
| 52 scoped_ptr<NativeMessagingWriter> native_messaging_writer_; | 52 scoped_ptr<NativeMessagingWriter> native_messaging_writer_; |
| 53 | 53 |
| 54 EventHandler* event_handler_; | 54 EventHandler* event_handler_; |
| 55 base::WeakPtr<PipeMessagingChannel> weak_ptr_; | 55 base::WeakPtr<PipeMessagingChannel> weak_ptr_; |
| 56 base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; | 56 base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); | 58 DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace remoting | 61 } // namespace remoting |
| 62 | 62 |
| 63 #endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | 63 #endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ |
| OLD | NEW |