| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ipc_channel_proxy.h" | 5 #include "ipc/ipc_channel_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void ChannelProxy::Context::OnChannelError() { | 170 void ChannelProxy::Context::OnChannelError() { |
| 171 for (size_t i = 0; i < filters_.size(); ++i) | 171 for (size_t i = 0; i < filters_.size(); ++i) |
| 172 filters_[i]->OnChannelError(); | 172 filters_[i]->OnChannelError(); |
| 173 | 173 |
| 174 // See above comment about using listener_task_runner_ here. | 174 // See above comment about using listener_task_runner_ here. |
| 175 listener_task_runner_->PostTask( | 175 listener_task_runner_->PostTask( |
| 176 FROM_HERE, base::Bind(&Context::OnDispatchError, this)); | 176 FROM_HERE, base::Bind(&Context::OnDispatchError, this)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Called on the IPC::Channel thread | 179 // Called on the IPC::Channel thread |
| 180 void ChannelProxy::Context::OnAssociatedInterfaceRequest( |
| 181 const std::string& interface_name, |
| 182 mojo::ScopedInterfaceEndpointHandle handle) { |
| 183 listener_task_runner_->PostTask( |
| 184 FROM_HERE, base::Bind(&Context::OnDispatchAssociatedInterfaceRequest, |
| 185 this, interface_name, base::Passed(&handle))); |
| 186 } |
| 187 |
| 188 // Called on the IPC::Channel thread |
| 180 void ChannelProxy::Context::OnChannelOpened() { | 189 void ChannelProxy::Context::OnChannelOpened() { |
| 181 DCHECK(channel_ != NULL); | 190 DCHECK(channel_ != NULL); |
| 182 | 191 |
| 183 // Assume a reference to ourselves on behalf of this thread. This reference | 192 // Assume a reference to ourselves on behalf of this thread. This reference |
| 184 // will be released when we are closed. | 193 // will be released when we are closed. |
| 185 AddRef(); | 194 AddRef(); |
| 186 | 195 |
| 187 if (!channel_->Connect()) { | 196 if (!channel_->Connect()) { |
| 188 OnChannelError(); | 197 OnChannelError(); |
| 189 return; | 198 return; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 if (listener_) | 368 if (listener_) |
| 360 listener_->OnChannelError(); | 369 listener_->OnChannelError(); |
| 361 } | 370 } |
| 362 | 371 |
| 363 // Called on the listener's thread | 372 // Called on the listener's thread |
| 364 void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { | 373 void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { |
| 365 if (listener_) | 374 if (listener_) |
| 366 listener_->OnBadMessageReceived(message); | 375 listener_->OnBadMessageReceived(message); |
| 367 } | 376 } |
| 368 | 377 |
| 378 // Called on the listener's thread |
| 379 void ChannelProxy::Context::OnDispatchAssociatedInterfaceRequest( |
| 380 const std::string& interface_name, |
| 381 mojo::ScopedInterfaceEndpointHandle handle) { |
| 382 if (listener_) |
| 383 listener_->OnAssociatedInterfaceRequest(interface_name, std::move(handle)); |
| 384 } |
| 385 |
| 369 void ChannelProxy::Context::ClearChannel() { | 386 void ChannelProxy::Context::ClearChannel() { |
| 370 base::AutoLock l(channel_lifetime_lock_); | 387 base::AutoLock l(channel_lifetime_lock_); |
| 371 channel_.reset(); | 388 channel_.reset(); |
| 372 associated_group_ = mojo::AssociatedGroup(); | 389 associated_group_ = mojo::AssociatedGroup(); |
| 373 } | 390 } |
| 374 | 391 |
| 375 void ChannelProxy::Context::AddGenericAssociatedInterface( | 392 void ChannelProxy::Context::AddGenericAssociatedInterface( |
| 376 const std::string& name, | 393 const std::string& name, |
| 377 const GenericAssociatedInterfaceFactory& factory) { | 394 const GenericAssociatedInterfaceFactory& factory) { |
| 378 AddGenericAssociatedInterfaceForIOThread( | 395 AddGenericAssociatedInterfaceForIOThread( |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 return channel->TakeClientFileDescriptor(); | 665 return channel->TakeClientFileDescriptor(); |
| 649 } | 666 } |
| 650 #endif | 667 #endif |
| 651 | 668 |
| 652 void ChannelProxy::OnChannelInit() { | 669 void ChannelProxy::OnChannelInit() { |
| 653 } | 670 } |
| 654 | 671 |
| 655 //----------------------------------------------------------------------------- | 672 //----------------------------------------------------------------------------- |
| 656 | 673 |
| 657 } // namespace IPC | 674 } // namespace IPC |
| OLD | NEW |