Chromium Code Reviews| Index: remoting/host/native_messaging/native_messaging_channel.h |
| diff --git a/remoting/host/native_messaging/native_messaging_channel.h b/remoting/host/native_messaging/native_messaging_channel.h |
| index dbf144d310a0bb4fbe1d5d402f0962a5833ab811..08649df12880001f6f7290450dc0f72a533a5495 100644 |
| --- a/remoting/host/native_messaging/native_messaging_channel.h |
| +++ b/remoting/host/native_messaging/native_messaging_channel.h |
| @@ -22,34 +22,17 @@ class Value; |
| namespace remoting { |
| // Implements reading messages and sending responses across the native messaging |
| -// host pipe. Delegates processing of received messages to Delegate. |
| -// |
| -// TODO(alexeypa): Add ability to switch between different |delegate_| pointers |
| -// on the fly. This is useful for implementing UAC-style elevation on Windows - |
| -// an unprivileged delegate could be replaced with another delegate that |
| -// forwards messages to the elevated instance of the native messaging host. |
| +// host pipe. |
| class NativeMessagingChannel : public base::NonThreadSafe { |
| public: |
| // Used to send a message to the client app. |
| typedef base::Callback<void(scoped_ptr<base::DictionaryValue> message)> |
| SendMessageCallback; |
| - class Delegate { |
| - public: |
| - virtual ~Delegate() {} |
| - |
| - // Sets the callback the delegate can use to send a message to the client. |
| - virtual void SetSendMessageCallback( |
| - const SendMessageCallback& send_message) = 0; |
| - |
| - // Processes a message received from the client app. |
| - virtual void ProcessMessage(scoped_ptr<base::DictionaryValue> message) = 0; |
| - }; |
| - |
| // Constructs an object taking the ownership of |input| and |output|. Closes |
| // |input| and |output| to prevent the caller from using them. |
| NativeMessagingChannel( |
| - scoped_ptr<Delegate> delegate, |
| + SendMessageCallback received_message, |
|
Sergey Ulanov
2013/12/12 19:10:28
Would it be better to pass this to Start()?
weitao
2013/12/12 23:33:48
Done.
|
| base::PlatformFile input, |
| base::PlatformFile output); |
| ~NativeMessagingChannel(); |
| @@ -57,13 +40,13 @@ class NativeMessagingChannel : public base::NonThreadSafe { |
| // Starts reading and processing messages. |
| void Start(const base::Closure& quit_closure); |
| + // Sends a message to the client app. |
| + void SendMessage(scoped_ptr<base::DictionaryValue> message); |
| + |
| private: |
| // Processes a message received from the client app. |
| void ProcessMessage(scoped_ptr<base::Value> message); |
| - // Sends a message to the client app. |
| - void SendMessage(scoped_ptr<base::DictionaryValue> message); |
| - |
| // Initiates shutdown and runs |quit_closure| if there are no pending requests |
| // left. |
| void Shutdown(); |
| @@ -73,10 +56,8 @@ class NativeMessagingChannel : public base::NonThreadSafe { |
| NativeMessagingReader native_messaging_reader_; |
| scoped_ptr<NativeMessagingWriter> native_messaging_writer_; |
| - // |delegate_| may post tasks to this object during destruction (but not |
| - // afterwards), so it needs to be destroyed before other members of this class |
| - // (except for |weak_factory_|). |
| - scoped_ptr<Delegate> delegate_; |
| + // The callback to invoke when a message is received. |
| + SendMessageCallback received_message_; |
| base::WeakPtr<NativeMessagingChannel> weak_ptr_; |
| base::WeakPtrFactory<NativeMessagingChannel> weak_factory_; |