| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |