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

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 2522333002: Provide a Mojo equivalent of ThreadSafeSender. (Closed)
Patch Set: Addressed comments and synced Created 4 years 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
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (filters_[i].get() == filter) { 304 if (filters_[i].get() == filter) {
305 filter->OnFilterRemoved(); 305 filter->OnFilterRemoved();
306 filters_.erase(filters_.begin() + i); 306 filters_.erase(filters_.begin() + i);
307 return; 307 return;
308 } 308 }
309 } 309 }
310 310
311 NOTREACHED() << "filter to be removed not found"; 311 NOTREACHED() << "filter to be removed not found";
312 } 312 }
313 313
314 void ChannelProxy::Context::RunWithChannel(
315 const RunOnIOThreadCallback& callback) {
316 callback.Run(channel_.get());
317 }
318
314 // Called on the listener's thread 319 // Called on the listener's thread
315 void ChannelProxy::Context::AddFilter(MessageFilter* filter) { 320 void ChannelProxy::Context::AddFilter(MessageFilter* filter) {
316 base::AutoLock auto_lock(pending_filters_lock_); 321 base::AutoLock auto_lock(pending_filters_lock_);
317 pending_filters_.push_back(make_scoped_refptr(filter)); 322 pending_filters_.push_back(make_scoped_refptr(filter));
318 ipc_task_runner_->PostTask( 323 ipc_task_runner_->PostTask(
319 FROM_HERE, base::Bind(&Context::OnAddFilter, this)); 324 FROM_HERE, base::Bind(&Context::OnAddFilter, this));
320 } 325 }
321 326
322 // Called on the listener's thread 327 // Called on the listener's thread
323 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { 328 void ChannelProxy::Context::OnDispatchMessage(const Message& message) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 608
604 void ChannelProxy::GetGenericRemoteAssociatedInterface( 609 void ChannelProxy::GetGenericRemoteAssociatedInterface(
605 const std::string& name, 610 const std::string& name,
606 mojo::ScopedInterfaceEndpointHandle handle) { 611 mojo::ScopedInterfaceEndpointHandle handle) {
607 DCHECK(did_init_); 612 DCHECK(did_init_);
608 context_->ipc_task_runner()->PostTask( 613 context_->ipc_task_runner()->PostTask(
609 FROM_HERE, base::Bind(&Context::GetRemoteAssociatedInterface, 614 FROM_HERE, base::Bind(&Context::GetRemoteAssociatedInterface,
610 context_, name, base::Passed(&handle))); 615 context_, name, base::Passed(&handle)));
611 } 616 }
612 617
618 void ChannelProxy::RunOnIOThread(const RunOnIOThreadCallback& callback) {
619 DCHECK(did_init_);
620 context_->ipc_task_runner()->PostTask(
621 FROM_HERE, base::Bind(&Context::RunWithChannel, context_, callback));
622 }
623
613 void ChannelProxy::ClearIPCTaskRunner() { 624 void ChannelProxy::ClearIPCTaskRunner() {
614 DCHECK(CalledOnValidThread()); 625 DCHECK(CalledOnValidThread());
615 626
616 context()->ClearIPCTaskRunner(); 627 context()->ClearIPCTaskRunner();
617 } 628 }
618 629
619 void ChannelProxy::OnChannelInit() { 630 void ChannelProxy::OnChannelInit() {
620 } 631 }
621 632
622 //----------------------------------------------------------------------------- 633 //-----------------------------------------------------------------------------
623 634
624 } // namespace IPC 635 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698