OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SETUP_NATIVE_MESSAGING_CHANNEL_H_ | 5 #ifndef REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
6 #define REMOTING_HOST_SETUP_NATIVE_MESSAGING_CHANNEL_H_ | 6 #define REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "remoting/host/setup/native_messaging_reader.h" | 14 #include "remoting/host/native_messaging/native_messaging_reader.h" |
15 #include "remoting/host/setup/native_messaging_writer.h" | 15 #include "remoting/host/native_messaging/native_messaging_writer.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class DictionaryValue; | 18 class DictionaryValue; |
19 class Value; | 19 class Value; |
20 } // namespace base | 20 } // namespace base |
21 | 21 |
22 namespace remoting { | 22 namespace remoting { |
23 | 23 |
24 // Implements reading messages and sending responses across the native messaging | 24 // Implements reading messages and sending responses across the native messaging |
25 // host pipe. Delegates processing of received messages to Delegate. | 25 // host pipe. Delegates processing of received messages to Delegate. |
(...skipping 12 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 virtual ~Delegate() {} | 39 virtual ~Delegate() {} |
40 | 40 |
41 // Processes a message received from the client app. Invokes |done| to send | 41 // Processes a message received from the client app. Invokes |done| to send |
42 // a response back to the client app. | 42 // a response back to the client app. |
43 virtual void ProcessMessage(scoped_ptr<base::DictionaryValue> message, | 43 virtual void ProcessMessage(scoped_ptr<base::DictionaryValue> message, |
44 const SendResponseCallback& done) = 0; | 44 const SendResponseCallback& done) = 0; |
45 }; | 45 }; |
46 | 46 |
47 // Constructs an object taking the ownership of |input| and |output|. Closes | 47 // Constructs an object taking the ownership of |input| and |output|. Closes |
48 // |input| and |output| to prevent the caller frmo using them. | 48 // |input| and |output| to prevent the caller from using them. |
49 NativeMessagingChannel( | 49 NativeMessagingChannel( |
50 scoped_ptr<Delegate> delegate, | 50 scoped_ptr<Delegate> delegate, |
51 base::PlatformFile input, | 51 base::PlatformFile input, |
52 base::PlatformFile output); | 52 base::PlatformFile output); |
53 ~NativeMessagingChannel(); | 53 ~NativeMessagingChannel(); |
54 | 54 |
55 // Starts reading and processing messages. | 55 // Starts reading and processing messages. |
56 void Start(const base::Closure& quit_closure); | 56 void Start(const base::Closure& quit_closure); |
57 | 57 |
58 private: | 58 private: |
(...skipping 25 matching lines...) Expand all Loading... |
84 bool shutdown_; | 84 bool shutdown_; |
85 | 85 |
86 base::WeakPtr<NativeMessagingChannel> weak_ptr_; | 86 base::WeakPtr<NativeMessagingChannel> weak_ptr_; |
87 base::WeakPtrFactory<NativeMessagingChannel> weak_factory_; | 87 base::WeakPtrFactory<NativeMessagingChannel> weak_factory_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(NativeMessagingChannel); | 89 DISALLOW_COPY_AND_ASSIGN(NativeMessagingChannel); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace remoting | 92 } // namespace remoting |
93 | 93 |
94 #endif // REMOTING_HOST_SETUP_NATIVE_MESSAGING_CHANNEL_H_ | 94 #endif // REMOTING_HOST_NATIVE_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_ |
OLD | NEW |