Chromium Code Reviews| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // callback. | 143 // callback. |
| 144 // It always returns false after CloseMessagePipe()/PassMessagePipe(). | 144 // It always returns false after CloseMessagePipe()/PassMessagePipe(). |
| 145 bool during_sync_handle_watcher_callback() const { | 145 bool during_sync_handle_watcher_callback() const { |
| 146 return sync_handle_watcher_callback_count_ > 0; | 146 return sync_handle_watcher_callback_count_ > 0; |
| 147 } | 147 } |
| 148 | 148 |
| 149 base::SingleThreadTaskRunner* task_runner() const { | 149 base::SingleThreadTaskRunner* task_runner() const { |
| 150 return task_runner_.get(); | 150 return task_runner_.get(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void SetWatcherHeapProfilerTag(const std::string& tag); | |
|
ssid
2017/01/12 21:52:54
const char* with a comment saying this must be a c
Jay Civelli
2017/01/13 01:09:27
Done.
| |
| 154 | |
| 153 private: | 155 private: |
| 154 // Callback of mojo::Watcher. | 156 // Callback of mojo::Watcher. |
| 155 void OnWatcherHandleReady(MojoResult result); | 157 void OnWatcherHandleReady(MojoResult result); |
| 156 // Callback of SyncHandleWatcher. | 158 // Callback of SyncHandleWatcher. |
| 157 void OnSyncHandleWatcherHandleReady(MojoResult result); | 159 void OnSyncHandleWatcherHandleReady(MojoResult result); |
| 158 void OnHandleReadyInternal(MojoResult result); | 160 void OnHandleReadyInternal(MojoResult result); |
| 159 | 161 |
| 160 void WaitToReadMore(); | 162 void WaitToReadMore(); |
| 161 | 163 |
| 162 // Returns false if it is impossible to receive more messages in the future. | 164 // Returns false if it is impossible to receive more messages in the future. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 bool allow_woken_up_by_others_ = false; | 201 bool allow_woken_up_by_others_ = false; |
| 200 // If non-zero, currently the control flow is inside the sync handle watcher | 202 // If non-zero, currently the control flow is inside the sync handle watcher |
| 201 // callback. | 203 // callback. |
| 202 size_t sync_handle_watcher_callback_count_ = 0; | 204 size_t sync_handle_watcher_callback_count_ = 0; |
| 203 | 205 |
| 204 base::ThreadChecker thread_checker_; | 206 base::ThreadChecker thread_checker_; |
| 205 | 207 |
| 206 base::Lock connected_lock_; | 208 base::Lock connected_lock_; |
| 207 bool connected_ = true; | 209 bool connected_ = true; |
| 208 | 210 |
| 211 // The tag to be used to track heap allocations performed by the watcher. | |
|
Ken Rockot(use gerrit already)
2017/01/12 21:05:22
nit: Not really allocations performed by the watch
Jay Civelli
2017/01/13 01:09:27
Clarified.
| |
| 212 std::string heap_profiler_tag_; | |
|
ssid
2017/01/12 21:52:54
Oh this should be const char*.
We do not store the
Jay Civelli
2017/01/13 01:09:27
Done.
| |
| 213 | |
| 209 // Create a single weak ptr and use it everywhere, to avoid the malloc/free | 214 // Create a single weak ptr and use it everywhere, to avoid the malloc/free |
| 210 // cost of creating a new weak ptr whenever it is needed. | 215 // cost of creating a new weak ptr whenever it is needed. |
| 211 // NOTE: This weak pointer is invalidated when the message pipe is closed or | 216 // NOTE: This weak pointer is invalidated when the message pipe is closed or |
| 212 // transferred (i.e., when |connected_| is set to false). | 217 // transferred (i.e., when |connected_| is set to false). |
| 213 base::WeakPtr<Connector> weak_self_; | 218 base::WeakPtr<Connector> weak_self_; |
| 214 base::WeakPtrFactory<Connector> weak_factory_; | 219 base::WeakPtrFactory<Connector> weak_factory_; |
| 215 | 220 |
| 216 DISALLOW_COPY_AND_ASSIGN(Connector); | 221 DISALLOW_COPY_AND_ASSIGN(Connector); |
| 217 }; | 222 }; |
| 218 | 223 |
| 219 } // namespace mojo | 224 } // namespace mojo |
| 220 | 225 |
| 221 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ | 226 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
| OLD | NEW |