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

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

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.cc
diff --git a/remoting/host/native_messaging/native_messaging_channel.cc b/remoting/host/native_messaging/native_messaging_channel.cc
index b1d2c784e576d2dc1cf33fdd6307ed77c2bffeaa..186b33b41b3f0e5c2971022e58447be22a6a0d56 100644
--- a/remoting/host/native_messaging/native_messaging_channel.cc
+++ b/remoting/host/native_messaging/native_messaging_channel.cc
@@ -45,28 +45,27 @@ base::PlatformFile DuplicatePlatformFile(base::PlatformFile handle) {
namespace remoting {
NativeMessagingChannel::NativeMessagingChannel(
- scoped_ptr<Delegate> delegate,
base::PlatformFile input,
base::PlatformFile output)
: native_messaging_reader_(DuplicatePlatformFile(input)),
native_messaging_writer_(new NativeMessagingWriter(
DuplicatePlatformFile(output))),
- delegate_(delegate.Pass()),
weak_factory_(this) {
weak_ptr_ = weak_factory_.GetWeakPtr();
- delegate_->SetSendMessageCallback(
- base::Bind(&NativeMessagingChannel::SendMessage, weak_ptr_));
}
NativeMessagingChannel::~NativeMessagingChannel() {
}
-void NativeMessagingChannel::Start(const base::Closure& quit_closure) {
+void NativeMessagingChannel::Start(const SendMessageCallback& received_message,
+ const base::Closure& quit_closure) {
DCHECK(CalledOnValidThread());
+ DCHECK(received_message_.is_null());
DCHECK(quit_closure_.is_null());
- DCHECK(!quit_closure.is_null());
+ received_message_ = received_message;
quit_closure_ = quit_closure;
+
native_messaging_reader_.Start(
base::Bind(&NativeMessagingChannel::ProcessMessage, weak_ptr_),
base::Bind(&NativeMessagingChannel::Shutdown, weak_ptr_));
@@ -83,7 +82,7 @@ void NativeMessagingChannel::ProcessMessage(scoped_ptr<base::Value> message) {
scoped_ptr<base::DictionaryValue> message_dict(
static_cast<base::DictionaryValue*>(message.release()));
- delegate_->ProcessMessage(message_dict.Pass());
+ received_message_.Run(message_dict.Pass());
}
void NativeMessagingChannel::SendMessage(

Powered by Google App Engine
This is Rietveld 408576698