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: ipc/mojo/ipc_channel_mojo_host.cc

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ChannelMojoHost Created 6 years, 3 months 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: ipc/mojo/ipc_channel_mojo_host.cc
diff --git a/ipc/mojo/ipc_channel_mojo_host.cc b/ipc/mojo/ipc_channel_mojo_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ef5afab53ad754f9f10e4ef0ddb780fb13856fc2
--- /dev/null
+++ b/ipc/mojo/ipc_channel_mojo_host.cc
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ipc/mojo/ipc_channel_mojo_host.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "ipc/mojo/ipc_channel_mojo.h"
+
+namespace IPC {
+
+ChannelMojoHost::ChannelMojoHost(scoped_refptr<base::TaskRunner> task_runner)
+ : weak_factory_(this), task_runner_(task_runner), channel_(NULL) {
+}
+
+ChannelMojoHost::~ChannelMojoHost() {
+}
+
+void ChannelMojoHost::OnClientLaunched(base::ProcessHandle process) {
+ if (task_runner_ == base::MessageLoop::current()->message_loop_proxy()) {
+ InvokeOnClientLaunched(process);
+ } else {
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&ChannelMojoHost::InvokeOnClientLaunched,
+ weak_factory_.GetWeakPtr(),
+ process));
+ }
+}
+
+void ChannelMojoHost::InvokeOnClientLaunched(base::ProcessHandle process) {
+ if (!channel_)
+ return;
+ channel_->OnClientLaunched(process);
+}
+
+void ChannelMojoHost::OnChannelCreated(ChannelMojo* channel) {
+ DCHECK(channel_ == NULL);
+ channel_ = channel;
+}
+
+void ChannelMojoHost::OnChannelDeleted() {
+ DCHECK(channel_ != NULL);
+ channel_ = NULL;
+}
+
+} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698