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

Side by Side Diff: mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.cc

Issue 2958703002: Rename TaskRunner::RunsTasksOnCurrentThread() in //ipc, //mojo (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 5 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/sequenced_task_runner_handle.h" 10 #include "base/threading/sequenced_task_runner_handle.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // still gets OnAssociated() call from its peer. 185 // still gets OnAssociated() call from its peer.
186 if (!pending_association_) 186 if (!pending_association_)
187 return; 187 return;
188 188
189 pending_association_ = false; 189 pending_association_ = false;
190 peer_state_ = nullptr; 190 peer_state_ = nullptr;
191 id_ = id; 191 id_ = id;
192 group_controller_ = std::move(group_controller); 192 group_controller_ = std::move(group_controller);
193 193
194 if (!association_event_handler_.is_null()) { 194 if (!association_event_handler_.is_null()) {
195 if (runner_->RunsTasksOnCurrentThread()) { 195 if (runner_->RunsTasksInCurrentSequence()) {
196 handler = std::move(association_event_handler_); 196 handler = std::move(association_event_handler_);
197 runner_ = nullptr; 197 runner_ = nullptr;
198 } else { 198 } else {
199 runner_->PostTask(FROM_HERE, 199 runner_->PostTask(FROM_HERE,
200 base::Bind(&ScopedInterfaceEndpointHandle::State:: 200 base::Bind(&ScopedInterfaceEndpointHandle::State::
201 RunAssociationEventHandler, 201 RunAssociationEventHandler,
202 this, runner_, ASSOCIATED)); 202 this, runner_, ASSOCIATED));
203 } 203 }
204 } 204 }
205 } 205 }
(...skipping 15 matching lines...) Expand all
221 // state but still gets OnPeerClosedBeforeAssociation() call from its 221 // state but still gets OnPeerClosedBeforeAssociation() call from its
222 // peer. 222 // peer.
223 if (!pending_association_) 223 if (!pending_association_)
224 return; 224 return;
225 225
226 disconnect_reason_ = reason; 226 disconnect_reason_ = reason;
227 // NOTE: This handle itself is still pending. 227 // NOTE: This handle itself is still pending.
228 peer_state_ = nullptr; 228 peer_state_ = nullptr;
229 229
230 if (!association_event_handler_.is_null()) { 230 if (!association_event_handler_.is_null()) {
231 if (runner_->RunsTasksOnCurrentThread()) { 231 if (runner_->RunsTasksInCurrentSequence()) {
232 handler = std::move(association_event_handler_); 232 handler = std::move(association_event_handler_);
233 runner_ = nullptr; 233 runner_ = nullptr;
234 } else { 234 } else {
235 runner_->PostTask( 235 runner_->PostTask(
236 FROM_HERE, 236 FROM_HERE,
237 base::Bind(&ScopedInterfaceEndpointHandle::State:: 237 base::Bind(&ScopedInterfaceEndpointHandle::State::
238 RunAssociationEventHandler, 238 RunAssociationEventHandler,
239 this, runner_, PEER_CLOSED_BEFORE_ASSOCIATION)); 239 this, runner_, PEER_CLOSED_BEFORE_ASSOCIATION));
240 } 240 }
241 } 241 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 base::Callback<AssociatedGroupController*()> 375 base::Callback<AssociatedGroupController*()>
376 ScopedInterfaceEndpointHandle::CreateGroupControllerGetter() const { 376 ScopedInterfaceEndpointHandle::CreateGroupControllerGetter() const {
377 // We allow this callback to be run on any thread. If this handle is created 377 // We allow this callback to be run on any thread. If this handle is created
378 // in non-pending state, we don't have a lock but it should still be safe 378 // in non-pending state, we don't have a lock but it should still be safe
379 // because the group controller never changes. 379 // because the group controller never changes.
380 return base::Bind(&State::group_controller, state_); 380 return base::Bind(&State::group_controller, state_);
381 } 381 }
382 382
383 } // namespace mojo 383 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/multiplex_router.cc ('k') | mojo/public/cpp/bindings/tests/associated_interface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698