Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | |
| 6 #define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/files/file.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/threading/non_thread_safe.h" | |
| 14 #include "extensions/browser/api/messaging/native_messaging_channel.h" | |
| 15 #include "remoting/host/native_messaging/native_messaging_reader.h" | |
| 16 #include "remoting/host/native_messaging/native_messaging_writer.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class DictionaryValue; | |
| 20 class Value; | |
| 21 } // namespace base | |
| 22 | |
| 23 namespace remoting { | |
| 24 | |
| 25 // 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.
| |
| 26 // is used by the |It2MeNativeMessagingHost| and |Me2MeNativeMessagingHost| to | |
| 27 // communicate with the chrome process. | |
| 28 // TODO(kelvinp): Move this class to the extensions/browser/api/messaging | |
| 29 // directory. | |
| 30 class PipeMessagingChannel : public extensions::NativeMessagingChannel, | |
| 31 public base::NonThreadSafe { | |
| 32 public: | |
| 33 typedef extensions::NativeMessagingChannel::EventHandler EventHandler; | |
| 34 | |
| 35 // Constructs an object taking the ownership of |input| and |output|. Closes | |
| 36 // |input| and |output| to prevent the caller from using them. | |
| 37 PipeMessagingChannel(base::File input, base::File output); | |
| 38 virtual ~PipeMessagingChannel(); | |
| 39 | |
| 40 // extensions::NativeMessagingChannel implementation. | |
| 41 virtual void Start(EventHandler* event_handler) OVERRIDE; | |
| 42 virtual void SendMessage(scoped_ptr<base::Value> message) OVERRIDE; | |
| 43 | |
| 44 private: | |
| 45 // Processes a message received from the client app. | |
| 46 void ProcessMessage(scoped_ptr<base::Value> message); | |
| 47 | |
| 48 // 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.
| |
| 49 // left. | |
| 50 void Shutdown(); | |
| 51 | |
| 52 NativeMessagingReader native_messaging_reader_; | |
| 53 scoped_ptr<NativeMessagingWriter> native_messaging_writer_; | |
| 54 | |
| 55 EventHandler* event_handler_; | |
| 56 base::WeakPtr<PipeMessagingChannel> weak_ptr_; | |
| 57 base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); | |
| 60 }; | |
| 61 | |
| 62 } // namespace remoting | |
| 63 | |
| 64 #endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | |
| OLD | NEW |