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

Unified Diff: mojo/public/cpp/bindings/lib/multiplex_router.cc

Issue 2666423002: Assert sequence validity on non-thread-safe RefCount manipulations (2) (Closed)
Patch Set: rebase on ImageStorage fix 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/multiplex_router.cc
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.cc b/mojo/public/cpp/bindings/lib/multiplex_router.cc
index ef3ca35d2b6d7d15e701ab1bbb4ed15d466fcc0e..07aafc9f6313070a99c8c8ae1038abcbb42a353d 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc
@@ -427,6 +427,10 @@ InterfaceId MultiplexRouter::AssociateInterface(
uint32_t id = 0;
{
MayAutoLock locker(lock_.get());
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
do {
if (next_interface_id_value_ >= kInterfaceIdNamespaceMask)
next_interface_id_value_ = 1;
@@ -464,6 +468,10 @@ ScopedInterfaceEndpointHandle MultiplexRouter::CreateLocalEndpointHandle(
return ScopedInterfaceEndpointHandle();
MayAutoLock locker(lock_.get());
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
bool inserted = false;
InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, &inserted);
if (inserted) {
@@ -492,6 +500,10 @@ void MultiplexRouter::CloseEndpointHandle(
return;
MayAutoLock locker(lock_.get());
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
DCHECK(base::ContainsKey(endpoints_, id));
InterfaceEndpoint* endpoint = endpoints_[id].get();
DCHECK(!endpoint->client());
@@ -516,6 +528,10 @@ InterfaceEndpointController* MultiplexRouter::AttachEndpointClient(
DCHECK(client);
MayAutoLock locker(lock_.get());
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
DCHECK(base::ContainsKey(endpoints_, id));
InterfaceEndpoint* endpoint = endpoints_[id].get();
@@ -685,6 +701,10 @@ void MultiplexRouter::OnPipeConnectionError() {
scoped_refptr<MultiplexRouter> protector(this);
MayAutoLock locker(lock_.get());
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
encountered_error_ = true;
@@ -710,6 +730,10 @@ void MultiplexRouter::ProcessTasks(
ClientCallBehavior client_call_behavior,
base::SingleThreadTaskRunner* current_task_runner) {
AssertLockAcquired();
+ // Relax the cross-thread access restriction to non-thread-safe RefCount.
+ // The lock above protects |endpoint|.
+ base::ScopedAllowCrossThreadRefCountAccess
+ allow_cross_thread_ref_count_access;
if (posted_to_process_tasks_)
return;

Powered by Google App Engine
This is Rietveld 408576698