[email protected] | 0a6fc4b | 2012-04-05 02:38:34 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 7412204 | 2014-04-25 00:07:30 | [diff] [blame] | 5 | #include "ipc/ipc_channel_proxy.h" |
| 6 | |
avi | 246998d8 | 2015-12-22 02:39:04 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | #include <stdint.h> |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 9 | |
dcheng | e4860045 | 2015-12-28 02:24:50 | [diff] [blame] | 10 | #include <utility> |
avi | 246998d8 | 2015-12-22 02:39:04 | [diff] [blame] | 11 | |
[email protected] | 72b6f8e2 | 2011-11-12 21:16:41 | [diff] [blame] | 12 | #include "base/bind.h" |
[email protected] | b5322508 | 2011-11-29 02:24:28 | [diff] [blame] | 13 | #include "base/compiler_specific.h" |
[email protected] | c62dd9d | 2011-09-21 18:05:41 | [diff] [blame] | 14 | #include "base/location.h" |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 15 | #include "base/memory/ptr_util.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 16 | #include "base/memory/ref_counted.h" |
pkasting | 2053ce2 | 2015-04-15 06:10:09 | [diff] [blame] | 17 | #include "base/profiler/scoped_tracker.h" |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 18 | #include "base/single_thread_task_runner.h" |
gab | f08ccc0 | 2016-05-11 18:51:11 | [diff] [blame] | 19 | #include "base/threading/thread_task_runner_handle.h" |
avi | 246998d8 | 2015-12-22 02:39:04 | [diff] [blame] | 20 | #include "build/build_config.h" |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 21 | #include "ipc/ipc_channel_factory.h" |
[email protected] | 57319ce | 2012-06-11 22:35:26 | [diff] [blame] | 22 | #include "ipc/ipc_listener.h" |
[email protected] | 946d1b2 | 2009-07-22 23:57:21 | [diff] [blame] | 23 | #include "ipc/ipc_logging.h" |
[email protected] | 9ec1685 | 2012-05-11 23:24:37 | [diff] [blame] | 24 | #include "ipc/ipc_message_macros.h" |
[email protected] | 7412204 | 2014-04-25 00:07:30 | [diff] [blame] | 25 | #include "ipc/message_filter.h" |
| 26 | #include "ipc/message_filter_router.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | |
| 28 | namespace IPC { |
| 29 | |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 30 | namespace { |
| 31 | |
| 32 | void BindAssociatedInterfaceOnTaskRunner( |
| 33 | scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 34 | const ChannelProxy::GenericAssociatedInterfaceFactory& factory, |
| 35 | mojo::ScopedInterfaceEndpointHandle handle) { |
| 36 | task_runner->PostTask(FROM_HERE, base::Bind(factory, base::Passed(&handle))); |
| 37 | } |
| 38 | |
| 39 | } // namespace |
| 40 | |
[email protected] | 16395142 | 2009-07-28 22:09:45 | [diff] [blame] | 41 | //------------------------------------------------------------------------------ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 42 | |
dcheng | fd03370 | 2014-08-28 16:59:29 | [diff] [blame] | 43 | ChannelProxy::Context::Context( |
| 44 | Listener* listener, |
| 45 | const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 46 | : listener_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | listener_(listener), |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 48 | ipc_task_runner_(ipc_task_runner), |
[email protected] | 0a6fc4b | 2012-04-05 02:38:34 | [diff] [blame] | 49 | channel_connected_called_(false), |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 50 | message_filter_router_(new MessageFilterRouter()), |
sammc | f810f07f | 2016-11-10 22:34:07 | [diff] [blame] | 51 | peer_pid_(base::kNullProcessId) { |
[email protected] | 1757164 | 2013-06-01 04:11:27 | [diff] [blame] | 52 | DCHECK(ipc_task_runner_.get()); |
[email protected] | 1f9cf47 | 2014-04-17 05:07:18 | [diff] [blame] | 53 | // The Listener thread where Messages are handled must be a separate thread |
| 54 | // to avoid oversubscribing the IO thread. If you trigger this error, you |
| 55 | // need to either: |
| 56 | // 1) Create the ChannelProxy on a different thread, or |
| 57 | // 2) Just use Channel |
| 58 | // Note, we currently make an exception for a NULL listener. That usage |
| 59 | // basically works, but is outside the intent of ChannelProxy. This support |
| 60 | // will disappear, so please don't rely on it. See crbug.com/364241 |
| 61 | DCHECK(!listener || (ipc_task_runner_.get() != listener_task_runner_.get())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | } |
| 63 | |
[email protected] | 92bf906 | 2011-05-02 18:00:49 | [diff] [blame] | 64 | ChannelProxy::Context::~Context() { |
| 65 | } |
| 66 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 67 | void ChannelProxy::Context::ClearIPCTaskRunner() { |
| 68 | ipc_task_runner_ = NULL; |
| 69 | } |
| 70 | |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 71 | void ChannelProxy::Context::CreateChannel( |
| 72 | std::unique_ptr<ChannelFactory> factory) { |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 73 | base::AutoLock l(channel_lifetime_lock_); |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 74 | DCHECK(!channel_); |
rockot | a34707ca | 2016-07-20 04:28:32 | [diff] [blame] | 75 | DCHECK_EQ(factory->GetIPCTaskRunner(), ipc_task_runner_); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 76 | channel_ = factory->BuildChannel(this); |
rockot | 0e4de5f | 2016-07-22 21:18:07 | [diff] [blame] | 77 | |
| 78 | Channel::AssociatedInterfaceSupport* support = |
| 79 | channel_->GetAssociatedInterfaceSupport(); |
| 80 | if (support) { |
| 81 | associated_group_ = *support->GetAssociatedGroup(); |
| 82 | |
| 83 | base::AutoLock l(pending_filters_lock_); |
| 84 | for (auto& entry : pending_interfaces_) |
| 85 | support->AddGenericAssociatedInterface(entry.first, entry.second); |
| 86 | pending_interfaces_.clear(); |
| 87 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 88 | } |
| 89 | |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 90 | bool ChannelProxy::Context::TryFilters(const Message& message) { |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 91 | DCHECK(message_filter_router_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 92 | #ifdef IPC_MESSAGE_LOG_ENABLED |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 93 | Logging* logger = Logging::GetInstance(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 94 | if (logger->Enabled()) |
| 95 | logger->OnPreDispatchMessage(message); |
| 96 | #endif |
| 97 | |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 98 | if (message_filter_router_->TryFilters(message)) { |
[email protected] | ef2f6ba | 2014-05-15 23:06:07 | [diff] [blame] | 99 | if (message.dispatch_error()) { |
| 100 | listener_task_runner_->PostTask( |
| 101 | FROM_HERE, base::Bind(&Context::OnDispatchBadMessage, this, message)); |
| 102 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 103 | #ifdef IPC_MESSAGE_LOG_ENABLED |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 104 | if (logger->Enabled()) |
sammc | a1b3b4d | 2016-11-15 00:34:36 | [diff] [blame] | 105 | logger->OnPostDispatchMessage(message); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 106 | #endif |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 107 | return true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 108 | } |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 109 | return false; |
| 110 | } |
| 111 | |
| 112 | // Called on the IPC::Channel thread |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 113 | void ChannelProxy::Context::PauseChannel() { |
| 114 | DCHECK(channel_); |
| 115 | channel_->Pause(); |
| 116 | } |
| 117 | |
| 118 | // Called on the IPC::Channel thread |
rockot | 401fb2c | 2016-09-06 18:35:57 | [diff] [blame] | 119 | void ChannelProxy::Context::UnpauseChannel(bool flush) { |
| 120 | DCHECK(channel_); |
| 121 | channel_->Unpause(flush); |
| 122 | } |
| 123 | |
| 124 | // Called on the IPC::Channel thread |
| 125 | void ChannelProxy::Context::FlushChannel() { |
| 126 | DCHECK(channel_); |
| 127 | channel_->Flush(); |
| 128 | } |
| 129 | |
| 130 | // Called on the IPC::Channel thread |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 131 | bool ChannelProxy::Context::OnMessageReceived(const Message& message) { |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 132 | // First give a chance to the filters to process this message. |
[email protected] | 3cdb7af81 | 2008-10-24 19:21:13 | [diff] [blame] | 133 | if (!TryFilters(message)) |
| 134 | OnMessageReceivedNoFilter(message); |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 135 | return true; |
[email protected] | 3cdb7af81 | 2008-10-24 19:21:13 | [diff] [blame] | 136 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 137 | |
[email protected] | 3cdb7af81 | 2008-10-24 19:21:13 | [diff] [blame] | 138 | // Called on the IPC::Channel thread |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 139 | bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 140 | listener_task_runner_->PostTask( |
[email protected] | 72b6f8e2 | 2011-11-12 21:16:41 | [diff] [blame] | 141 | FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message)); |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 142 | return true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // Called on the IPC::Channel thread |
tfarina | 10a5c06 | 2015-09-04 18:47:57 | [diff] [blame] | 146 | void ChannelProxy::Context::OnChannelConnected(int32_t peer_pid) { |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 147 | // We cache off the peer_pid so it can be safely accessed from both threads. |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 148 | { |
| 149 | base::AutoLock l(peer_pid_lock_); |
sammc | f810f07f | 2016-11-10 22:34:07 | [diff] [blame] | 150 | peer_pid_ = peer_pid; |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 151 | } |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 152 | |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 153 | // Add any pending filters. This avoids a race condition where someone |
| 154 | // creates a ChannelProxy, calls AddFilter, and then right after starts the |
| 155 | // peer process. The IO thread could receive a message before the task to add |
| 156 | // the filter is run on the IO thread. |
| 157 | OnAddFilter(); |
| 158 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 159 | // See above comment about using listener_task_runner_ here. |
| 160 | listener_task_runner_->PostTask( |
[email protected] | 72b6f8e2 | 2011-11-12 21:16:41 | [diff] [blame] | 161 | FROM_HERE, base::Bind(&Context::OnDispatchConnected, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | // Called on the IPC::Channel thread |
| 165 | void ChannelProxy::Context::OnChannelError() { |
[email protected] | 5fa1c54 | 2009-05-05 20:36:07 | [diff] [blame] | 166 | for (size_t i = 0; i < filters_.size(); ++i) |
| 167 | filters_[i]->OnChannelError(); |
| 168 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 169 | // See above comment about using listener_task_runner_ here. |
| 170 | listener_task_runner_->PostTask( |
[email protected] | 72b6f8e2 | 2011-11-12 21:16:41 | [diff] [blame] | 171 | FROM_HERE, base::Bind(&Context::OnDispatchError, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | // Called on the IPC::Channel thread |
rockot | f62002a | 2016-09-15 00:08:59 | [diff] [blame] | 175 | void ChannelProxy::Context::OnAssociatedInterfaceRequest( |
| 176 | const std::string& interface_name, |
| 177 | mojo::ScopedInterfaceEndpointHandle handle) { |
| 178 | listener_task_runner_->PostTask( |
| 179 | FROM_HERE, base::Bind(&Context::OnDispatchAssociatedInterfaceRequest, |
| 180 | this, interface_name, base::Passed(&handle))); |
| 181 | } |
| 182 | |
| 183 | // Called on the IPC::Channel thread |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 184 | void ChannelProxy::Context::OnChannelOpened() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 185 | DCHECK(channel_ != NULL); |
| 186 | |
| 187 | // Assume a reference to ourselves on behalf of this thread. This reference |
| 188 | // will be released when we are closed. |
| 189 | AddRef(); |
| 190 | |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 191 | if (!channel_->Connect()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 192 | OnChannelError(); |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | for (size_t i = 0; i < filters_.size(); ++i) |
[email protected] | 42ce94e | 2010-12-08 19:28:09 | [diff] [blame] | 197 | filters_[i]->OnFilterAdded(channel_.get()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | // Called on the IPC::Channel thread |
[email protected] | 3cdb7af81 | 2008-10-24 19:21:13 | [diff] [blame] | 201 | void ChannelProxy::Context::OnChannelClosed() { |
pkasting | 2053ce2 | 2015-04-15 06:10:09 | [diff] [blame] | 202 | // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
| 203 | tracked_objects::ScopedTracker tracking_profile( |
| 204 | FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 205 | "477117 ChannelProxy::Context::OnChannelClosed")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 206 | // It's okay for IPC::ChannelProxy::Close to be called more than once, which |
| 207 | // would result in this branch being taken. |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 208 | if (!channel_) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 209 | return; |
| 210 | |
tzik | 0e85f1d | 2016-11-05 09:26:44 | [diff] [blame] | 211 | for (auto& filter : pending_filters_) { |
| 212 | filter->OnChannelClosing(); |
| 213 | filter->OnFilterRemoved(); |
| 214 | } |
| 215 | for (auto& filter : filters_) { |
| 216 | filter->OnChannelClosing(); |
| 217 | filter->OnFilterRemoved(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | // We don't need the filters anymore. |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 221 | message_filter_router_->Clear(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 222 | filters_.clear(); |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 223 | // We don't need the lock, because at this point, the listener thread can't |
| 224 | // access it any more. |
| 225 | pending_filters_.clear(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 226 | |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 227 | ClearChannel(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 228 | |
| 229 | // Balance with the reference taken during startup. This may result in |
| 230 | // self-destruction. |
| 231 | Release(); |
| 232 | } |
| 233 | |
[email protected] | 772a5b2 | 2012-08-09 20:39:12 | [diff] [blame] | 234 | void ChannelProxy::Context::Clear() { |
| 235 | listener_ = NULL; |
| 236 | } |
| 237 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 238 | // Called on the IPC::Channel thread |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 239 | void ChannelProxy::Context::OnSendMessage(std::unique_ptr<Message> message) { |
pkasting | 2053ce2 | 2015-04-15 06:10:09 | [diff] [blame] | 240 | // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
| 241 | tracked_objects::ScopedTracker tracking_profile( |
| 242 | FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 243 | "477117 ChannelProxy::Context::OnSendMessage")); |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 244 | if (!channel_) { |
[email protected] | 87339f0 | 2010-09-02 21:45:50 | [diff] [blame] | 245 | OnChannelClosed(); |
| 246 | return; |
| 247 | } |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 248 | |
[email protected] | f729d15a | 2012-04-28 02:12:00 | [diff] [blame] | 249 | if (!channel_->Send(message.release())) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 250 | OnChannelError(); |
| 251 | } |
| 252 | |
| 253 | // Called on the IPC::Channel thread |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 254 | void ChannelProxy::Context::OnAddFilter() { |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 255 | // Our OnChannelConnected method has not yet been called, so we can't be |
| 256 | // sure that channel_ is valid yet. When OnChannelConnected *is* called, |
| 257 | // it invokes OnAddFilter, so any pending filter(s) will be added at that |
| 258 | // time. |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 259 | // No lock necessary for |peer_pid_| because it is only modified on this |
| 260 | // thread. |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 261 | if (peer_pid_ == base::kNullProcessId) |
| 262 | return; |
| 263 | |
[email protected] | 41388930 | 2011-08-16 22:12:39 | [diff] [blame] | 264 | std::vector<scoped_refptr<MessageFilter> > new_filters; |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 265 | { |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 266 | base::AutoLock auto_lock(pending_filters_lock_); |
[email protected] | 41388930 | 2011-08-16 22:12:39 | [diff] [blame] | 267 | new_filters.swap(pending_filters_); |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 268 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 269 | |
[email protected] | 41388930 | 2011-08-16 22:12:39 | [diff] [blame] | 270 | for (size_t i = 0; i < new_filters.size(); ++i) { |
| 271 | filters_.push_back(new_filters[i]); |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 272 | |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 273 | message_filter_router_->AddFilter(new_filters[i].get()); |
| 274 | |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 275 | // The channel has already been created and connected, so we need to |
| 276 | // inform the filters right now. |
| 277 | new_filters[i]->OnFilterAdded(channel_.get()); |
| 278 | new_filters[i]->OnChannelConnected(peer_pid_); |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 279 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | // Called on the IPC::Channel thread |
| 283 | void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 284 | // No lock necessary for |peer_pid_| because it is only modified on this |
| 285 | // thread. |
[email protected] | 7e3d752 | 2014-03-20 21:00:50 | [diff] [blame] | 286 | if (peer_pid_ == base::kNullProcessId) { |
| 287 | // The channel is not yet connected, so any filters are still pending. |
| 288 | base::AutoLock auto_lock(pending_filters_lock_); |
| 289 | for (size_t i = 0; i < pending_filters_.size(); ++i) { |
| 290 | if (pending_filters_[i].get() == filter) { |
| 291 | filter->OnFilterRemoved(); |
| 292 | pending_filters_.erase(pending_filters_.begin() + i); |
| 293 | return; |
| 294 | } |
| 295 | } |
| 296 | return; |
| 297 | } |
| 298 | if (!channel_) |
[email protected] | 6d057a0c | 2013-07-09 21:12:07 | [diff] [blame] | 299 | return; // The filters have already been deleted. |
| 300 | |
[email protected] | b51352a | 2014-02-26 05:18:04 | [diff] [blame] | 301 | message_filter_router_->RemoveFilter(filter); |
| 302 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 303 | for (size_t i = 0; i < filters_.size(); ++i) { |
| 304 | if (filters_[i].get() == filter) { |
| 305 | filter->OnFilterRemoved(); |
| 306 | filters_.erase(filters_.begin() + i); |
| 307 | return; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | NOTREACHED() << "filter to be removed not found"; |
| 312 | } |
| 313 | |
| 314 | // Called on the listener's thread |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 315 | void ChannelProxy::Context::AddFilter(MessageFilter* filter) { |
[email protected] | 20305ec | 2011-01-21 04:55:52 | [diff] [blame] | 316 | base::AutoLock auto_lock(pending_filters_lock_); |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 317 | pending_filters_.push_back(make_scoped_refptr(filter)); |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 318 | ipc_task_runner_->PostTask( |
[email protected] | 72b6f8e2 | 2011-11-12 21:16:41 | [diff] [blame] | 319 | FROM_HERE, base::Bind(&Context::OnAddFilter, this)); |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | // Called on the listener's thread |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 323 | void ChannelProxy::Context::OnDispatchMessage(const Message& message) { |
| 324 | if (!listener_) |
| 325 | return; |
| 326 | |
[email protected] | 827ab81 | 2009-03-12 07:17:17 | [diff] [blame] | 327 | OnDispatchConnected(); |
| 328 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 329 | #ifdef IPC_MESSAGE_LOG_ENABLED |
ssid | 6c1dc89 | 2016-03-28 19:56:49 | [diff] [blame] | 330 | Logging* logger = Logging::GetInstance(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 331 | if (message.type() == IPC_LOGGING_ID) { |
| 332 | logger->OnReceivedLoggingMessage(message); |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | if (logger->Enabled()) |
| 337 | logger->OnPreDispatchMessage(message); |
| 338 | #endif |
| 339 | |
| 340 | listener_->OnMessageReceived(message); |
[email protected] | ef2f6ba | 2014-05-15 23:06:07 | [diff] [blame] | 341 | if (message.dispatch_error()) |
| 342 | listener_->OnBadMessageReceived(message); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 343 | |
| 344 | #ifdef IPC_MESSAGE_LOG_ENABLED |
| 345 | if (logger->Enabled()) |
sammc | a1b3b4d | 2016-11-15 00:34:36 | [diff] [blame] | 346 | logger->OnPostDispatchMessage(message); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 347 | #endif |
| 348 | } |
| 349 | |
| 350 | // Called on the listener's thread |
[email protected] | 827ab81 | 2009-03-12 07:17:17 | [diff] [blame] | 351 | void ChannelProxy::Context::OnDispatchConnected() { |
| 352 | if (channel_connected_called_) |
| 353 | return; |
| 354 | |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 355 | base::ProcessId peer_pid; |
| 356 | { |
| 357 | base::AutoLock l(peer_pid_lock_); |
| 358 | peer_pid = peer_pid_; |
| 359 | } |
[email protected] | 827ab81 | 2009-03-12 07:17:17 | [diff] [blame] | 360 | channel_connected_called_ = true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 361 | if (listener_) |
amistry | 78ef5f1b | 2016-07-19 02:52:31 | [diff] [blame] | 362 | listener_->OnChannelConnected(peer_pid); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | // Called on the listener's thread |
| 366 | void ChannelProxy::Context::OnDispatchError() { |
| 367 | if (listener_) |
| 368 | listener_->OnChannelError(); |
| 369 | } |
| 370 | |
[email protected] | ef2f6ba | 2014-05-15 23:06:07 | [diff] [blame] | 371 | // Called on the listener's thread |
| 372 | void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { |
| 373 | if (listener_) |
| 374 | listener_->OnBadMessageReceived(message); |
| 375 | } |
| 376 | |
rockot | f62002a | 2016-09-15 00:08:59 | [diff] [blame] | 377 | // Called on the listener's thread |
| 378 | void ChannelProxy::Context::OnDispatchAssociatedInterfaceRequest( |
| 379 | const std::string& interface_name, |
| 380 | mojo::ScopedInterfaceEndpointHandle handle) { |
| 381 | if (listener_) |
| 382 | listener_->OnAssociatedInterfaceRequest(interface_name, std::move(handle)); |
| 383 | } |
| 384 | |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 385 | void ChannelProxy::Context::ClearChannel() { |
| 386 | base::AutoLock l(channel_lifetime_lock_); |
| 387 | channel_.reset(); |
rockot | 0e4de5f | 2016-07-22 21:18:07 | [diff] [blame] | 388 | associated_group_ = mojo::AssociatedGroup(); |
| 389 | } |
| 390 | |
| 391 | void ChannelProxy::Context::AddGenericAssociatedInterface( |
| 392 | const std::string& name, |
| 393 | const GenericAssociatedInterfaceFactory& factory) { |
| 394 | AddGenericAssociatedInterfaceForIOThread( |
| 395 | name, base::Bind(&BindAssociatedInterfaceOnTaskRunner, |
| 396 | listener_task_runner_, factory)); |
| 397 | } |
| 398 | |
| 399 | void ChannelProxy::Context::AddGenericAssociatedInterfaceForIOThread( |
| 400 | const std::string& name, |
| 401 | const GenericAssociatedInterfaceFactory& factory) { |
| 402 | base::AutoLock l(channel_lifetime_lock_); |
| 403 | if (!channel_) { |
| 404 | base::AutoLock l(pending_filters_lock_); |
| 405 | pending_interfaces_.emplace_back(name, factory); |
| 406 | return; |
| 407 | } |
| 408 | Channel::AssociatedInterfaceSupport* support = |
| 409 | channel_->GetAssociatedInterfaceSupport(); |
rockot | fd3d9084 | 2016-09-15 23:57:29 | [diff] [blame] | 410 | if (support) |
| 411 | support->AddGenericAssociatedInterface(name, factory); |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 412 | } |
| 413 | |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 414 | void ChannelProxy::Context::Send(Message* message) { |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 415 | ipc_task_runner()->PostTask( |
| 416 | FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this, |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 417 | base::Passed(base::WrapUnique(message)))); |
morrita | b447214 | 2015-04-20 21:20:12 | [diff] [blame] | 418 | } |
| 419 | |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 420 | // Called on the IPC::Channel thread |
| 421 | void ChannelProxy::Context::GetRemoteAssociatedInterface( |
| 422 | const std::string& name, |
| 423 | mojo::ScopedInterfaceEndpointHandle handle) { |
| 424 | if (!channel_) |
| 425 | return; |
| 426 | Channel::AssociatedInterfaceSupport* associated_interface_support = |
| 427 | channel_->GetAssociatedInterfaceSupport(); |
| 428 | DCHECK(associated_interface_support); |
| 429 | associated_interface_support->GetGenericRemoteAssociatedInterface( |
| 430 | name, std::move(handle)); |
| 431 | } |
| 432 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 433 | //----------------------------------------------------------------------------- |
| 434 | |
[email protected] | fca876a1 | 2014-06-05 16:15:38 | [diff] [blame] | 435 | // static |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 436 | std::unique_ptr<ChannelProxy> ChannelProxy::Create( |
[email protected] | fca876a1 | 2014-06-05 16:15:38 | [diff] [blame] | 437 | const IPC::ChannelHandle& channel_handle, |
| 438 | Channel::Mode mode, |
| 439 | Listener* listener, |
erikchen | 30dc281 | 2015-09-24 03:26:38 | [diff] [blame] | 440 | const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 441 | std::unique_ptr<ChannelProxy> channel( |
| 442 | new ChannelProxy(listener, ipc_task_runner)); |
erikchen | 30dc281 | 2015-09-24 03:26:38 | [diff] [blame] | 443 | channel->Init(channel_handle, mode, true); |
dcheng | e4860045 | 2015-12-28 02:24:50 | [diff] [blame] | 444 | return channel; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 445 | } |
| 446 | |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 447 | // static |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 448 | std::unique_ptr<ChannelProxy> ChannelProxy::Create( |
| 449 | std::unique_ptr<ChannelFactory> factory, |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 450 | Listener* listener, |
dcheng | fd03370 | 2014-08-28 16:59:29 | [diff] [blame] | 451 | const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 452 | std::unique_ptr<ChannelProxy> channel( |
| 453 | new ChannelProxy(listener, ipc_task_runner)); |
dcheng | e4860045 | 2015-12-28 02:24:50 | [diff] [blame] | 454 | channel->Init(std::move(factory), true); |
| 455 | return channel; |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 456 | } |
| 457 | |
[email protected] | 952394af | 2011-11-16 01:06:46 | [diff] [blame] | 458 | ChannelProxy::ChannelProxy(Context* context) |
rockot | a34707ca | 2016-07-20 04:28:32 | [diff] [blame] | 459 | : context_(context), did_init_(false) { |
mbarbella | e97877bc | 2015-03-06 21:51:14 | [diff] [blame] | 460 | #if defined(ENABLE_IPC_FUZZER) |
| 461 | outgoing_message_filter_ = NULL; |
| 462 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 463 | } |
| 464 | |
dcheng | fd03370 | 2014-08-28 16:59:29 | [diff] [blame] | 465 | ChannelProxy::ChannelProxy( |
| 466 | Listener* listener, |
| 467 | const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 468 | : context_(new Context(listener, ipc_task_runner)), did_init_(false) { |
| 469 | #if defined(ENABLE_IPC_FUZZER) |
| 470 | outgoing_message_filter_ = NULL; |
| 471 | #endif |
| 472 | } |
[email protected] | fca876a1 | 2014-06-05 16:15:38 | [diff] [blame] | 473 | |
[email protected] | dec76e80 | 2010-09-23 22:43:53 | [diff] [blame] | 474 | ChannelProxy::~ChannelProxy() { |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 475 | DCHECK(CalledOnValidThread()); |
| 476 | |
[email protected] | dec76e80 | 2010-09-23 22:43:53 | [diff] [blame] | 477 | Close(); |
| 478 | } |
| 479 | |
[email protected] | 3b0e466 | 2014-06-02 20:29:30 | [diff] [blame] | 480 | void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
| 481 | Channel::Mode mode, |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 482 | bool create_pipe_now) { |
[email protected] | 42ce94e | 2010-12-08 19:28:09 | [diff] [blame] | 483 | #if defined(OS_POSIX) |
| 484 | // When we are creating a server on POSIX, we need its file descriptor |
| 485 | // to be created immediately so that it can be accessed and passed |
| 486 | // to other processes. Forcing it to be created immediately avoids |
| 487 | // race conditions that may otherwise arise. |
[email protected] | 1707726c | 2011-02-03 20:35:09 | [diff] [blame] | 488 | if (mode & Channel::MODE_SERVER_FLAG) { |
[email protected] | 42ce94e | 2010-12-08 19:28:09 | [diff] [blame] | 489 | create_pipe_now = true; |
| 490 | } |
| 491 | #endif // defined(OS_POSIX) |
rockot | a34707ca | 2016-07-20 04:28:32 | [diff] [blame] | 492 | Init( |
| 493 | ChannelFactory::Create(channel_handle, mode, context_->ipc_task_runner()), |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 494 | create_pipe_now); |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 495 | } |
| 496 | |
danakj | 03de39b2 | 2016-04-23 04:21:09 | [diff] [blame] | 497 | void ChannelProxy::Init(std::unique_ptr<ChannelFactory> factory, |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 498 | bool create_pipe_now) { |
[email protected] | 6486088 | 2014-08-04 23:44:17 | [diff] [blame] | 499 | DCHECK(CalledOnValidThread()); |
| 500 | DCHECK(!did_init_); |
[email protected] | 42ce94e | 2010-12-08 19:28:09 | [diff] [blame] | 501 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 502 | if (create_pipe_now) { |
| 503 | // Create the channel immediately. This effectively sets up the |
| 504 | // low-level pipe so that the client can connect. Without creating |
| 505 | // the pipe immediately, it is possible for a listener to attempt |
| 506 | // to connect and get an error since the pipe doesn't exist yet. |
dcheng | e4860045 | 2015-12-28 02:24:50 | [diff] [blame] | 507 | context_->CreateChannel(std::move(factory)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 508 | } else { |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 509 | context_->ipc_task_runner()->PostTask( |
tzik | 07cace4 | 2016-09-01 04:21:25 | [diff] [blame] | 510 | FROM_HERE, base::Bind(&Context::CreateChannel, context_, |
dcheng | 0917ec4 | 2015-11-19 07:00:20 | [diff] [blame] | 511 | base::Passed(&factory))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | // complete initialization on the background thread |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 515 | context_->ipc_task_runner()->PostTask( |
rockot | 401fb2c | 2016-09-06 18:35:57 | [diff] [blame] | 516 | FROM_HERE, |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 517 | base::Bind(&Context::OnChannelOpened, context_)); |
[email protected] | 952394af | 2011-11-16 01:06:46 | [diff] [blame] | 518 | |
| 519 | did_init_ = true; |
rockot | 29ade1b | 2015-08-07 06:23:59 | [diff] [blame] | 520 | OnChannelInit(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 521 | } |
| 522 | |
rockot | 1018875 | 2016-09-08 18:24:56 | [diff] [blame] | 523 | void ChannelProxy::Pause() { |
| 524 | context_->ipc_task_runner()->PostTask( |
| 525 | FROM_HERE, base::Bind(&Context::PauseChannel, context_)); |
| 526 | } |
| 527 | |
rockot | 401fb2c | 2016-09-06 18:35:57 | [diff] [blame] | 528 | void ChannelProxy::Unpause(bool flush) { |
| 529 | context_->ipc_task_runner()->PostTask( |
| 530 | FROM_HERE, base::Bind(&Context::UnpauseChannel, context_, flush)); |
| 531 | } |
| 532 | |
| 533 | void ChannelProxy::Flush() { |
| 534 | context_->ipc_task_runner()->PostTask( |
| 535 | FROM_HERE, base::Bind(&Context::FlushChannel, context_)); |
| 536 | } |
| 537 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 538 | void ChannelProxy::Close() { |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 539 | DCHECK(CalledOnValidThread()); |
| 540 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 541 | // Clear the backpointer to the listener so that any pending calls to |
| 542 | // Context::OnDispatchMessage or OnDispatchError will be ignored. It is |
| 543 | // possible that the channel could be closed while it is receiving messages! |
[email protected] | 3cdb7af81 | 2008-10-24 19:21:13 | [diff] [blame] | 544 | context_->Clear(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 545 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 546 | if (context_->ipc_task_runner()) { |
| 547 | context_->ipc_task_runner()->PostTask( |
tzik | 07cace4 | 2016-09-01 04:21:25 | [diff] [blame] | 548 | FROM_HERE, base::Bind(&Context::OnChannelClosed, context_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | |
| 552 | bool ChannelProxy::Send(Message* message) { |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 553 | DCHECK(did_init_); |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 554 | |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 555 | // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are |
| 556 | // tests that call Send() from a wrong thread. See http://crbug.com/163523. |
[email protected] | 8948031 | 2011-05-04 17:14:16 | [diff] [blame] | 557 | |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 558 | #ifdef ENABLE_IPC_FUZZER |
| 559 | // In IPC fuzzing builds, it is possible to define a filter to apply to |
| 560 | // outgoing messages. It will either rewrite the message and return a new |
| 561 | // one, freeing the original, or return the message unchanged. |
| 562 | if (outgoing_message_filter()) |
| 563 | message = outgoing_message_filter()->Rewrite(message); |
| 564 | #endif |
| 565 | |
| 566 | #ifdef IPC_MESSAGE_LOG_ENABLED |
sammc | a1b3b4d | 2016-11-15 00:34:36 | [diff] [blame] | 567 | Logging::GetInstance()->OnSendMessage(message); |
rockot | f14a8ae | 2016-06-16 19:28:41 | [diff] [blame] | 568 | #endif |
| 569 | |
| 570 | context_->Send(message); |
| 571 | return true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | void ChannelProxy::AddFilter(MessageFilter* filter) { |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 575 | DCHECK(CalledOnValidThread()); |
| 576 | |
[email protected] | 4b580bf | 2010-12-02 19:16:07 | [diff] [blame] | 577 | context_->AddFilter(filter); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | void ChannelProxy::RemoveFilter(MessageFilter* filter) { |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 581 | DCHECK(CalledOnValidThread()); |
| 582 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 583 | context_->ipc_task_runner()->PostTask( |
tzik | 07cace4 | 2016-09-01 04:21:25 | [diff] [blame] | 584 | FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_, |
vmpstr | a34d1132 | 2016-03-21 20:28:47 | [diff] [blame] | 585 | base::RetainedRef(filter))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 586 | } |
| 587 | |
msramek | 5507fee | 2016-07-22 10:06:21 | [diff] [blame] | 588 | void ChannelProxy::AddGenericAssociatedInterface( |
| 589 | const std::string& name, |
| 590 | const GenericAssociatedInterfaceFactory& factory) { |
rockot | 0e4de5f | 2016-07-22 21:18:07 | [diff] [blame] | 591 | context()->AddGenericAssociatedInterface(name, factory); |
| 592 | } |
| 593 | |
| 594 | void ChannelProxy::AddGenericAssociatedInterfaceForIOThread( |
| 595 | const std::string& name, |
| 596 | const GenericAssociatedInterfaceFactory& factory) { |
| 597 | context()->AddGenericAssociatedInterfaceForIOThread(name, factory); |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | mojo::AssociatedGroup* ChannelProxy::GetAssociatedGroup() { |
rockot | 0e4de5f | 2016-07-22 21:18:07 | [diff] [blame] | 601 | return context()->associated_group(); |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | void ChannelProxy::GetGenericRemoteAssociatedInterface( |
| 605 | const std::string& name, |
| 606 | mojo::ScopedInterfaceEndpointHandle handle) { |
rockot | 5a90895 | 2016-07-28 20:08:17 | [diff] [blame] | 607 | DCHECK(did_init_); |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 608 | context_->ipc_task_runner()->PostTask( |
| 609 | FROM_HERE, base::Bind(&Context::GetRemoteAssociatedInterface, |
tzik | 07cace4 | 2016-09-01 04:21:25 | [diff] [blame] | 610 | context_, name, base::Passed(&handle))); |
rockot | 8d890f6 | 2016-07-14 16:37:14 | [diff] [blame] | 611 | } |
| 612 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 613 | void ChannelProxy::ClearIPCTaskRunner() { |
[email protected] | f775d10 | 2012-12-05 01:00:36 | [diff] [blame] | 614 | DCHECK(CalledOnValidThread()); |
| 615 | |
[email protected] | b243230 | 2012-07-02 21:15:52 | [diff] [blame] | 616 | context()->ClearIPCTaskRunner(); |
[email protected] | 42f1d782 | 2009-07-23 18:17:55 | [diff] [blame] | 617 | } |
| 618 | |
rockot | 29ade1b | 2015-08-07 06:23:59 | [diff] [blame] | 619 | void ChannelProxy::OnChannelInit() { |
| 620 | } |
| 621 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 622 | //----------------------------------------------------------------------------- |
| 623 | |
| 624 | } // namespace IPC |