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/lib/multiplex_router.h" | 5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 router_->AssertLockAcquired(); | 167 router_->AssertLockAcquired(); |
168 | 168 |
169 DCHECK(!client_); | 169 DCHECK(!client_); |
170 DCHECK(closed_); | 170 DCHECK(closed_); |
171 DCHECK(peer_closed_); | 171 DCHECK(peer_closed_); |
172 DCHECK(!sync_watcher_); | 172 DCHECK(!sync_watcher_); |
173 } | 173 } |
174 | 174 |
175 void OnHandleReady(MojoResult result) { | 175 void OnHandleReady(MojoResult result) { |
176 DCHECK(task_runner_->BelongsToCurrentThread()); | 176 DCHECK(task_runner_->BelongsToCurrentThread()); |
177 scoped_refptr<InterfaceEndpoint> self_protector(this); | |
178 scoped_refptr<MultiplexRouter> router_protector(router_); | 177 scoped_refptr<MultiplexRouter> router_protector(router_); |
179 | 178 |
180 // Because we never close |sync_message_event_{sender,receiver}_| before | 179 // Because we never close |sync_message_event_{sender,receiver}_| before |
181 // destruction or set a deadline, |result| should always be MOJO_RESULT_OK. | 180 // destruction or set a deadline, |result| should always be MOJO_RESULT_OK. |
182 DCHECK_EQ(MOJO_RESULT_OK, result); | 181 DCHECK_EQ(MOJO_RESULT_OK, result); |
183 bool reset_sync_watcher = false; | |
184 { | |
185 MayAutoLock locker(router_->lock_.get()); | |
186 | 182 |
187 bool more_to_process = router_->ProcessFirstSyncMessageForEndpoint(id_); | 183 MayAutoLock locker(router_->lock_.get()); |
| 184 scoped_refptr<InterfaceEndpoint> self_protector(this); |
188 | 185 |
189 if (!more_to_process) | 186 bool more_to_process = router_->ProcessFirstSyncMessageForEndpoint(id_); |
190 ResetSyncMessageSignal(); | |
191 | 187 |
192 // Currently there are no queued sync messages and the peer has closed so | 188 if (!more_to_process) |
193 // there won't be incoming sync messages in the future. | 189 ResetSyncMessageSignal(); |
194 reset_sync_watcher = !more_to_process && peer_closed_; | 190 |
195 } | 191 // Currently there are no queued sync messages and the peer has closed so |
196 if (reset_sync_watcher) { | 192 // there won't be incoming sync messages in the future. |
| 193 if (!more_to_process && peer_closed_) { |
197 // If a SyncWatch() call (or multiple ones) of this interface endpoint is | 194 // If a SyncWatch() call (or multiple ones) of this interface endpoint is |
198 // on the call stack, resetting the sync watcher will allow it to exit | 195 // on the call stack, resetting the sync watcher will allow it to exit |
199 // when the call stack unwinds to that frame. | 196 // when the call stack unwinds to that frame. |
200 sync_watcher_.reset(); | 197 sync_watcher_.reset(); |
201 } | 198 } |
202 } | 199 } |
203 | 200 |
204 void EnsureSyncWatcherExists() { | 201 void EnsureSyncWatcherExists() { |
205 DCHECK(task_runner_->BelongsToCurrentThread()); | 202 DCHECK(task_runner_->BelongsToCurrentThread()); |
206 if (sync_watcher_) | 203 if (sync_watcher_) |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 989 |
993 void MultiplexRouter::AssertLockAcquired() { | 990 void MultiplexRouter::AssertLockAcquired() { |
994 #if DCHECK_IS_ON() | 991 #if DCHECK_IS_ON() |
995 if (lock_) | 992 if (lock_) |
996 lock_->AssertAcquired(); | 993 lock_->AssertAcquired(); |
997 #endif | 994 #endif |
998 } | 995 } |
999 | 996 |
1000 } // namespace internal | 997 } // namespace internal |
1001 } // namespace mojo | 998 } // namespace mojo |
OLD | NEW |