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 11 matching lines...) Expand all Loading... |
22 #include "mojo/public/cpp/bindings/sync_event_watcher.h" | 22 #include "mojo/public/cpp/bindings/sync_event_watcher.h" |
23 | 23 |
24 namespace mojo { | 24 namespace mojo { |
25 namespace internal { | 25 namespace internal { |
26 | 26 |
27 // InterfaceEndpoint stores the information of an interface endpoint registered | 27 // InterfaceEndpoint stores the information of an interface endpoint registered |
28 // with the router. | 28 // with the router. |
29 // No one other than the router's |endpoints_| and |tasks_| should hold refs to | 29 // No one other than the router's |endpoints_| and |tasks_| should hold refs to |
30 // this object. | 30 // this object. |
31 class MultiplexRouter::InterfaceEndpoint | 31 class MultiplexRouter::InterfaceEndpoint |
32 : public base::RefCounted<InterfaceEndpoint>, | 32 : public base::RefCountedThreadSafe<InterfaceEndpoint>, |
33 public InterfaceEndpointController { | 33 public InterfaceEndpointController { |
34 public: | 34 public: |
35 InterfaceEndpoint(MultiplexRouter* router, InterfaceId id) | 35 InterfaceEndpoint(MultiplexRouter* router, InterfaceId id) |
36 : router_(router), | 36 : router_(router), |
37 id_(id), | 37 id_(id), |
38 closed_(false), | 38 closed_(false), |
39 peer_closed_(false), | 39 peer_closed_(false), |
40 handle_created_(false), | 40 handle_created_(false), |
41 client_(nullptr) {} | 41 client_(nullptr) {} |
42 | 42 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 bool SyncWatch(const bool* should_stop) override { | 145 bool SyncWatch(const bool* should_stop) override { |
146 DCHECK(task_runner_->BelongsToCurrentThread()); | 146 DCHECK(task_runner_->BelongsToCurrentThread()); |
147 | 147 |
148 EnsureSyncWatcherExists(); | 148 EnsureSyncWatcherExists(); |
149 return sync_watcher_->SyncWatch(should_stop); | 149 return sync_watcher_->SyncWatch(should_stop); |
150 } | 150 } |
151 | 151 |
152 private: | 152 private: |
153 friend class base::RefCounted<InterfaceEndpoint>; | 153 friend class base::RefCountedThreadSafe<InterfaceEndpoint>; |
154 | 154 |
155 ~InterfaceEndpoint() override { | 155 ~InterfaceEndpoint() override { |
156 router_->AssertLockAcquired(); | 156 router_->AssertLockAcquired(); |
157 | 157 |
158 DCHECK(!client_); | 158 DCHECK(!client_); |
159 DCHECK(closed_); | 159 DCHECK(closed_); |
160 DCHECK(peer_closed_); | 160 DCHECK(peer_closed_); |
161 DCHECK(!sync_watcher_); | 161 DCHECK(!sync_watcher_); |
162 } | 162 } |
163 | 163 |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 | 951 |
952 void MultiplexRouter::AssertLockAcquired() { | 952 void MultiplexRouter::AssertLockAcquired() { |
953 #if DCHECK_IS_ON() | 953 #if DCHECK_IS_ON() |
954 if (lock_) | 954 if (lock_) |
955 lock_->AssertAcquired(); | 955 lock_->AssertAcquired(); |
956 #endif | 956 #endif |
957 } | 957 } |
958 | 958 |
959 } // namespace internal | 959 } // namespace internal |
960 } // namespace mojo | 960 } // namespace mojo |
OLD | NEW |