OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 9 #include "ipc/mojo/ipc_channel_mojo.h" |
| 10 |
| 11 namespace IPC { |
| 12 |
| 13 ChannelMojoHost::ChannelMojoHost(scoped_refptr<base::TaskRunner> task_runner) |
| 14 : weak_factory_(this), task_runner_(task_runner), channel_(NULL) { |
| 15 } |
| 16 |
| 17 ChannelMojoHost::~ChannelMojoHost() { |
| 18 } |
| 19 |
| 20 void ChannelMojoHost::OnClientLaunched(base::ProcessHandle process) { |
| 21 if (task_runner_ == base::MessageLoop::current()->message_loop_proxy()) { |
| 22 InvokeOnClientLaunched(process); |
| 23 } else { |
| 24 task_runner_->PostTask(FROM_HERE, |
| 25 base::Bind(&ChannelMojoHost::InvokeOnClientLaunched, |
| 26 weak_factory_.GetWeakPtr(), |
| 27 process)); |
| 28 } |
| 29 } |
| 30 |
| 31 void ChannelMojoHost::InvokeOnClientLaunched(base::ProcessHandle process) { |
| 32 if (!channel_) |
| 33 return; |
| 34 channel_->OnClientLaunched(process); |
| 35 } |
| 36 |
| 37 void ChannelMojoHost::OnChannelCreated(ChannelMojo* channel) { |
| 38 DCHECK(channel_ == NULL); |
| 39 channel_ = channel; |
| 40 } |
| 41 |
| 42 void ChannelMojoHost::OnChannelDestroyed() { |
| 43 DCHECK(channel_ != NULL); |
| 44 channel_ = NULL; |
| 45 } |
| 46 |
| 47 } // namespace IPC |
OLD | NEW |