| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 base::SingleThreadTaskRunner* task_runner() const { | 150 base::SingleThreadTaskRunner* task_runner() const { |
| 151 return task_runner_.get(); | 151 return task_runner_.get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Sets the tag used by the heap profiler. | 154 // Sets the tag used by the heap profiler. |
| 155 // |tag| must be a const string literal. | 155 // |tag| must be a const string literal. |
| 156 void SetWatcherHeapProfilerTag(const char* tag); | 156 void SetWatcherHeapProfilerTag(const char* tag); |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 class ActiveDispatchTracker; | 159 class ActiveDispatchTracker; |
| 160 class MessageLoopNestingObserver; | 160 class RunLoopNestingObserver; |
| 161 | 161 |
| 162 // Callback of mojo::SimpleWatcher. | 162 // Callback of mojo::SimpleWatcher. |
| 163 void OnWatcherHandleReady(MojoResult result); | 163 void OnWatcherHandleReady(MojoResult result); |
| 164 // Callback of SyncHandleWatcher. | 164 // Callback of SyncHandleWatcher. |
| 165 void OnSyncHandleWatcherHandleReady(MojoResult result); | 165 void OnSyncHandleWatcherHandleReady(MojoResult result); |
| 166 void OnHandleReadyInternal(MojoResult result); | 166 void OnHandleReadyInternal(MojoResult result); |
| 167 | 167 |
| 168 void WaitToReadMore(); | 168 void WaitToReadMore(); |
| 169 | 169 |
| 170 // Returns false if it is impossible to receive more messages in the future. | 170 // Returns false if it is impossible to receive more messages in the future. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 base::ThreadChecker thread_checker_; | 212 base::ThreadChecker thread_checker_; |
| 213 | 213 |
| 214 base::Lock connected_lock_; | 214 base::Lock connected_lock_; |
| 215 bool connected_ = true; | 215 bool connected_ = true; |
| 216 | 216 |
| 217 // The tag used to track heap allocations that originated from a Watcher | 217 // The tag used to track heap allocations that originated from a Watcher |
| 218 // notification. | 218 // notification. |
| 219 const char* heap_profiler_tag_ = nullptr; | 219 const char* heap_profiler_tag_ = nullptr; |
| 220 | 220 |
| 221 // A cached pointer to the MessageLoopNestingObserver for the MessageLoop on | 221 // A cached pointer to the RunLoopNestingObserver for the thread on which this |
| 222 // which this Connector was created. | 222 // Connector was created. |
| 223 MessageLoopNestingObserver* const nesting_observer_; | 223 RunLoopNestingObserver* const nesting_observer_; |
| 224 | 224 |
| 225 // |true| iff the Connector is currently dispatching a message. Used to detect | 225 // |true| iff the Connector is currently dispatching a message. Used to detect |
| 226 // nested dispatch operations. | 226 // nested dispatch operations. |
| 227 bool is_dispatching_ = false; | 227 bool is_dispatching_ = false; |
| 228 | 228 |
| 229 // Create a single weak ptr and use it everywhere, to avoid the malloc/free | 229 // Create a single weak ptr and use it everywhere, to avoid the malloc/free |
| 230 // cost of creating a new weak ptr whenever it is needed. | 230 // cost of creating a new weak ptr whenever it is needed. |
| 231 // NOTE: This weak pointer is invalidated when the message pipe is closed or | 231 // NOTE: This weak pointer is invalidated when the message pipe is closed or |
| 232 // transferred (i.e., when |connected_| is set to false). | 232 // transferred (i.e., when |connected_| is set to false). |
| 233 base::WeakPtr<Connector> weak_self_; | 233 base::WeakPtr<Connector> weak_self_; |
| 234 base::WeakPtrFactory<Connector> weak_factory_; | 234 base::WeakPtrFactory<Connector> weak_factory_; |
| 235 | 235 |
| 236 DISALLOW_COPY_AND_ASSIGN(Connector); | 236 DISALLOW_COPY_AND_ASSIGN(Connector); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 } // namespace mojo | 239 } // namespace mojo |
| 240 | 240 |
| 241 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ | 241 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
| OLD | NEW |