Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: remoting/host/native_messaging/native_messaging_channel.h

Issue 103693006: Me2me Native Messaging host on Windows: restructure NativeMessagingHost and NativeMessagingChannel.… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..472cc0613f9c289288eff331ee86b08650b349a1 100644
--- a/remoting/host/native_messaging/native_messaging_channel.h
+++ b/remoting/host/native_messaging/native_messaging_channel.h
@@ -22,48 +22,29 @@ 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,
- base::PlatformFile input,
- base::PlatformFile output);
+ NativeMessagingChannel(base::PlatformFile input, base::PlatformFile output);
~NativeMessagingChannel();
// Starts reading and processing messages.
- void Start(const base::Closure& quit_closure);
+ void Start(const SendMessageCallback& received_message,
+ 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 +54,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_;

Powered by Google App Engine
This is Rietveld 408576698