Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 2668153003: Mojo C++ Bindings: Eliminate unbound ThreadSafeInterfacePtr (Closed)
Patch Set: format and rebase... Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_message_pipe_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 70 associated_group_ = *support->GetAssociatedGroup();
71 thread_safe_channel_ = support->CreateThreadSafeChannel();
71 72
72 base::AutoLock l(pending_filters_lock_); 73 base::AutoLock l(pending_filters_lock_);
73 for (auto& entry : pending_io_thread_interfaces_) 74 for (auto& entry : pending_io_thread_interfaces_)
74 support->AddGenericAssociatedInterface(entry.first, entry.second); 75 support->AddGenericAssociatedInterface(entry.first, entry.second);
75 pending_io_thread_interfaces_.clear(); 76 pending_io_thread_interfaces_.clear();
76 } 77 }
77 } 78 }
78 79
79 bool ChannelProxy::Context::TryFilters(const Message& message) { 80 bool ChannelProxy::Context::TryFilters(const Message& message) {
80 DCHECK(message_filter_router_); 81 DCHECK(message_filter_router_);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 if (support) 392 if (support)
392 support->AddGenericAssociatedInterface(name, factory); 393 support->AddGenericAssociatedInterface(name, factory);
393 } 394 }
394 395
395 void ChannelProxy::Context::Send(Message* message) { 396 void ChannelProxy::Context::Send(Message* message) {
396 ipc_task_runner()->PostTask( 397 ipc_task_runner()->PostTask(
397 FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this, 398 FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this,
398 base::Passed(base::WrapUnique(message)))); 399 base::Passed(base::WrapUnique(message))));
399 } 400 }
400 401
401 // Called on the IPC::Channel thread
402 void ChannelProxy::Context::GetRemoteAssociatedInterface(
403 const std::string& name,
404 mojo::ScopedInterfaceEndpointHandle handle) {
405 if (!channel_)
406 return;
407 Channel::AssociatedInterfaceSupport* associated_interface_support =
408 channel_->GetAssociatedInterfaceSupport();
409 DCHECK(associated_interface_support);
410 associated_interface_support->GetGenericRemoteAssociatedInterface(
411 name, std::move(handle));
412 }
413
414 //----------------------------------------------------------------------------- 402 //-----------------------------------------------------------------------------
415 403
416 // static 404 // static
417 std::unique_ptr<ChannelProxy> ChannelProxy::Create( 405 std::unique_ptr<ChannelProxy> ChannelProxy::Create(
418 const IPC::ChannelHandle& channel_handle, 406 const IPC::ChannelHandle& channel_handle,
419 Channel::Mode mode, 407 Channel::Mode mode,
420 Listener* listener, 408 Listener* listener,
421 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { 409 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
422 std::unique_ptr<ChannelProxy> channel( 410 std::unique_ptr<ChannelProxy> channel(
423 new ChannelProxy(listener, ipc_task_runner)); 411 new ChannelProxy(listener, ipc_task_runner));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 561 }
574 562
575 mojo::AssociatedGroup* ChannelProxy::GetAssociatedGroup() { 563 mojo::AssociatedGroup* ChannelProxy::GetAssociatedGroup() {
576 return context()->associated_group(); 564 return context()->associated_group();
577 } 565 }
578 566
579 void ChannelProxy::GetGenericRemoteAssociatedInterface( 567 void ChannelProxy::GetGenericRemoteAssociatedInterface(
580 const std::string& name, 568 const std::string& name,
581 mojo::ScopedInterfaceEndpointHandle handle) { 569 mojo::ScopedInterfaceEndpointHandle handle) {
582 DCHECK(did_init_); 570 DCHECK(did_init_);
583 context_->ipc_task_runner()->PostTask( 571 mojom::GenericInterfaceAssociatedRequest request;
584 FROM_HERE, base::Bind(&Context::GetRemoteAssociatedInterface, 572 request.Bind(std::move(handle));
585 context_, name, base::Passed(&handle))); 573 context()->thread_safe_channel().GetAssociatedInterface(name,
574 std::move(request));
586 } 575 }
587 576
588 void ChannelProxy::ClearIPCTaskRunner() { 577 void ChannelProxy::ClearIPCTaskRunner() {
589 DCHECK(CalledOnValidThread()); 578 DCHECK(CalledOnValidThread());
590
591 context()->ClearIPCTaskRunner(); 579 context()->ClearIPCTaskRunner();
592 } 580 }
593 581
594 void ChannelProxy::OnChannelInit() { 582 void ChannelProxy::OnChannelInit() {
595 } 583 }
596 584
597 //----------------------------------------------------------------------------- 585 //-----------------------------------------------------------------------------
598 586
599 } // namespace IPC 587 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_message_pipe_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698