| 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 <memory> | 
|  | 9 | 
| 8 #include "base/callback.h" | 10 #include "base/callback.h" | 
| 9 #include "base/files/file.h" | 11 #include "base/files/file.h" | 
| 10 #include "base/macros.h" | 12 #include "base/macros.h" | 
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" | 
| 12 #include "base/memory/scoped_ptr.h" |  | 
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" | 
| 14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" | 
| 15 #include "extensions/browser/api/messaging/native_messaging_channel.h" | 16 #include "extensions/browser/api/messaging/native_messaging_channel.h" | 
| 16 #include "remoting/host/native_messaging/native_messaging_reader.h" | 17 #include "remoting/host/native_messaging/native_messaging_reader.h" | 
| 17 #include "remoting/host/native_messaging/native_messaging_writer.h" | 18 #include "remoting/host/native_messaging/native_messaging_writer.h" | 
| 18 | 19 | 
| 19 namespace base { | 20 namespace base { | 
| 20 class DictionaryValue; | 21 class DictionaryValue; | 
| 21 class Value; | 22 class Value; | 
| 22 }  // namespace base | 23 }  // namespace base | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 33  public: | 34  public: | 
| 34   typedef extensions::NativeMessagingChannel::EventHandler EventHandler; | 35   typedef extensions::NativeMessagingChannel::EventHandler EventHandler; | 
| 35 | 36 | 
| 36   // Constructs an object taking the ownership of |input| and |output|. Closes | 37   // Constructs an object taking the ownership of |input| and |output|. Closes | 
| 37   // |input| and |output| to prevent the caller from using them. | 38   // |input| and |output| to prevent the caller from using them. | 
| 38   PipeMessagingChannel(base::File input, base::File output); | 39   PipeMessagingChannel(base::File input, base::File output); | 
| 39   ~PipeMessagingChannel() override; | 40   ~PipeMessagingChannel() override; | 
| 40 | 41 | 
| 41   // extensions::NativeMessagingChannel implementation. | 42   // extensions::NativeMessagingChannel implementation. | 
| 42   void Start(EventHandler* event_handler) override; | 43   void Start(EventHandler* event_handler) override; | 
| 43   void SendMessage(scoped_ptr<base::Value> message) override; | 44   void SendMessage(std::unique_ptr<base::Value> message) override; | 
| 44 | 45 | 
| 45  private: | 46  private: | 
| 46   // Processes a message received from the client app. | 47   // Processes a message received from the client app. | 
| 47   void ProcessMessage(scoped_ptr<base::Value> message); | 48   void ProcessMessage(std::unique_ptr<base::Value> message); | 
| 48 | 49 | 
| 49   // Initiates shutdown. | 50   // Initiates shutdown. | 
| 50   void Shutdown(); | 51   void Shutdown(); | 
| 51 | 52 | 
| 52   NativeMessagingReader native_messaging_reader_; | 53   NativeMessagingReader native_messaging_reader_; | 
| 53   scoped_ptr<NativeMessagingWriter> native_messaging_writer_; | 54   std::unique_ptr<NativeMessagingWriter> native_messaging_writer_; | 
| 54 | 55 | 
| 55   EventHandler* event_handler_; | 56   EventHandler* event_handler_; | 
| 56   base::WeakPtr<PipeMessagingChannel> weak_ptr_; | 57   base::WeakPtr<PipeMessagingChannel> weak_ptr_; | 
| 57   base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; | 58   base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; | 
| 58 | 59 | 
| 59   DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); | 60   DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); | 
| 60 }; | 61 }; | 
| 61 | 62 | 
| 62 }  // namespace remoting | 63 }  // namespace remoting | 
| 63 | 64 | 
| 64 #endif  // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | 65 #endif  // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ | 
| OLD | NEW | 
|---|