| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ipc/mojo/ipc_channel_mojo_host.h" | 5 #include "ipc/mojo/ipc_channel_mojo_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 9 #include "ipc/mojo/ipc_channel_mojo.h" | 10 #include "ipc/mojo/ipc_channel_mojo.h" |
| 10 | 11 |
| 11 namespace IPC { | 12 namespace IPC { |
| 12 | 13 |
| 13 class ChannelMojoHost::ChannelDelegateTraits { | 14 class ChannelMojoHost::ChannelDelegateTraits { |
| 14 public: | 15 public: |
| 15 static void Destruct(const ChannelMojoHost::ChannelDelegate* ptr); | 16 static void Destruct(const ChannelMojoHost::ChannelDelegate* ptr); |
| 16 }; | 17 }; |
| 17 | 18 |
| 18 // The delete class lives on the IO thread to talk to ChannelMojo on | 19 // The delete class lives on the IO thread to talk to ChannelMojo on |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 scoped_refptr<base::SequencedTaskRunner> io_task_runner) | 91 scoped_refptr<base::SequencedTaskRunner> io_task_runner) |
| 91 : io_task_runner_(io_task_runner), | 92 : io_task_runner_(io_task_runner), |
| 92 channel_delegate_(new ChannelDelegate(io_task_runner)), | 93 channel_delegate_(new ChannelDelegate(io_task_runner)), |
| 93 weak_factory_(this) { | 94 weak_factory_(this) { |
| 94 } | 95 } |
| 95 | 96 |
| 96 ChannelMojoHost::~ChannelMojoHost() { | 97 ChannelMojoHost::~ChannelMojoHost() { |
| 97 } | 98 } |
| 98 | 99 |
| 99 void ChannelMojoHost::OnClientLaunched(base::ProcessHandle process) { | 100 void ChannelMojoHost::OnClientLaunched(base::ProcessHandle process) { |
| 100 if (io_task_runner_ == base::MessageLoop::current()->message_loop_proxy()) { | 101 if (io_task_runner_ == base::MessageLoop::current()->task_runner()) { |
| 101 channel_delegate_->OnClientLaunched(process); | 102 channel_delegate_->OnClientLaunched(process); |
| 102 } else { | 103 } else { |
| 103 io_task_runner_->PostTask(FROM_HERE, | 104 io_task_runner_->PostTask(FROM_HERE, |
| 104 base::Bind(&ChannelDelegate::OnClientLaunched, | 105 base::Bind(&ChannelDelegate::OnClientLaunched, |
| 105 channel_delegate_, process)); | 106 channel_delegate_, process)); |
| 106 } | 107 } |
| 107 } | 108 } |
| 108 | 109 |
| 109 ChannelMojo::Delegate* ChannelMojoHost::channel_delegate() const { | 110 ChannelMojo::Delegate* ChannelMojoHost::channel_delegate() const { |
| 110 return channel_delegate_.get(); | 111 return channel_delegate_.get(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 // static | 114 // static |
| 114 void ChannelMojoHost::ChannelDelegateTraits::Destruct( | 115 void ChannelMojoHost::ChannelDelegateTraits::Destruct( |
| 115 const ChannelMojoHost::ChannelDelegate* ptr) { | 116 const ChannelMojoHost::ChannelDelegate* ptr) { |
| 116 ptr->DeleteThisSoon(); | 117 ptr->DeleteThisSoon(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace IPC | 120 } // namespace IPC |
| OLD | NEW |