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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void ChannelProxy::Context::CreateChannel( | 60 void ChannelProxy::Context::CreateChannel( |
61 std::unique_ptr<ChannelFactory> factory) { | 61 std::unique_ptr<ChannelFactory> factory) { |
62 base::AutoLock l(channel_lifetime_lock_); | 62 base::AutoLock l(channel_lifetime_lock_); |
63 DCHECK(!channel_); | 63 DCHECK(!channel_); |
64 DCHECK_EQ(factory->GetIPCTaskRunner(), ipc_task_runner_); | 64 DCHECK_EQ(factory->GetIPCTaskRunner(), ipc_task_runner_); |
65 channel_ = factory->BuildChannel(this); | 65 channel_ = factory->BuildChannel(this); |
66 | 66 |
67 Channel::AssociatedInterfaceSupport* support = | 67 Channel::AssociatedInterfaceSupport* support = |
68 channel_->GetAssociatedInterfaceSupport(); | 68 channel_->GetAssociatedInterfaceSupport(); |
69 if (support) { | 69 if (support) { |
70 associated_group_ = *support->GetAssociatedGroup(); | |
71 thread_safe_channel_ = support->CreateThreadSafeChannel(); | 70 thread_safe_channel_ = support->CreateThreadSafeChannel(); |
72 | 71 |
73 base::AutoLock l(pending_filters_lock_); | 72 base::AutoLock l(pending_filters_lock_); |
74 for (auto& entry : pending_io_thread_interfaces_) | 73 for (auto& entry : pending_io_thread_interfaces_) |
75 support->AddGenericAssociatedInterface(entry.first, entry.second); | 74 support->AddGenericAssociatedInterface(entry.first, entry.second); |
76 pending_io_thread_interfaces_.clear(); | 75 pending_io_thread_interfaces_.clear(); |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 bool ChannelProxy::Context::TryFilters(const Message& message) { | 79 bool ChannelProxy::Context::TryFilters(const Message& message) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 void ChannelProxy::Context::OnDispatchAssociatedInterfaceRequest( | 367 void ChannelProxy::Context::OnDispatchAssociatedInterfaceRequest( |
369 const std::string& interface_name, | 368 const std::string& interface_name, |
370 mojo::ScopedInterfaceEndpointHandle handle) { | 369 mojo::ScopedInterfaceEndpointHandle handle) { |
371 if (listener_) | 370 if (listener_) |
372 listener_->OnAssociatedInterfaceRequest(interface_name, std::move(handle)); | 371 listener_->OnAssociatedInterfaceRequest(interface_name, std::move(handle)); |
373 } | 372 } |
374 | 373 |
375 void ChannelProxy::Context::ClearChannel() { | 374 void ChannelProxy::Context::ClearChannel() { |
376 base::AutoLock l(channel_lifetime_lock_); | 375 base::AutoLock l(channel_lifetime_lock_); |
377 channel_.reset(); | 376 channel_.reset(); |
378 associated_group_ = mojo::AssociatedGroup(); | |
379 } | 377 } |
380 | 378 |
381 void ChannelProxy::Context::AddGenericAssociatedInterfaceForIOThread( | 379 void ChannelProxy::Context::AddGenericAssociatedInterfaceForIOThread( |
382 const std::string& name, | 380 const std::string& name, |
383 const GenericAssociatedInterfaceFactory& factory) { | 381 const GenericAssociatedInterfaceFactory& factory) { |
384 base::AutoLock l(channel_lifetime_lock_); | 382 base::AutoLock l(channel_lifetime_lock_); |
385 if (!channel_) { | 383 if (!channel_) { |
386 base::AutoLock l(pending_filters_lock_); | 384 base::AutoLock l(pending_filters_lock_); |
387 pending_io_thread_interfaces_.emplace_back(name, factory); | 385 pending_io_thread_interfaces_.emplace_back(name, factory); |
388 return; | 386 return; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_, | 551 FROM_HERE, base::Bind(&Context::OnRemoveFilter, context_, |
554 base::RetainedRef(filter))); | 552 base::RetainedRef(filter))); |
555 } | 553 } |
556 | 554 |
557 void ChannelProxy::AddGenericAssociatedInterfaceForIOThread( | 555 void ChannelProxy::AddGenericAssociatedInterfaceForIOThread( |
558 const std::string& name, | 556 const std::string& name, |
559 const GenericAssociatedInterfaceFactory& factory) { | 557 const GenericAssociatedInterfaceFactory& factory) { |
560 context()->AddGenericAssociatedInterfaceForIOThread(name, factory); | 558 context()->AddGenericAssociatedInterfaceForIOThread(name, factory); |
561 } | 559 } |
562 | 560 |
563 mojo::AssociatedGroup* ChannelProxy::GetAssociatedGroup() { | |
564 return context()->associated_group(); | |
565 } | |
566 | |
567 void ChannelProxy::GetGenericRemoteAssociatedInterface( | 561 void ChannelProxy::GetGenericRemoteAssociatedInterface( |
568 const std::string& name, | 562 const std::string& name, |
569 mojo::ScopedInterfaceEndpointHandle handle) { | 563 mojo::ScopedInterfaceEndpointHandle handle) { |
570 DCHECK(did_init_); | 564 DCHECK(did_init_); |
571 mojom::GenericInterfaceAssociatedRequest request; | 565 mojom::GenericInterfaceAssociatedRequest request; |
572 request.Bind(std::move(handle)); | 566 request.Bind(std::move(handle)); |
573 context()->thread_safe_channel().GetAssociatedInterface(name, | 567 context()->thread_safe_channel().GetAssociatedInterface(name, |
574 std::move(request)); | 568 std::move(request)); |
575 } | 569 } |
576 | 570 |
577 void ChannelProxy::ClearIPCTaskRunner() { | 571 void ChannelProxy::ClearIPCTaskRunner() { |
578 DCHECK(CalledOnValidThread()); | 572 DCHECK(CalledOnValidThread()); |
579 context()->ClearIPCTaskRunner(); | 573 context()->ClearIPCTaskRunner(); |
580 } | 574 } |
581 | 575 |
582 void ChannelProxy::OnChannelInit() { | 576 void ChannelProxy::OnChannelInit() { |
583 } | 577 } |
584 | 578 |
585 //----------------------------------------------------------------------------- | 579 //----------------------------------------------------------------------------- |
586 | 580 |
587 } // namespace IPC | 581 } // namespace IPC |
OLD | NEW |