| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/optional.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 16 #include "mojo/public/cpp/bindings/bindings_export.h" | 17 #include "mojo/public/cpp/bindings/bindings_export.h" |
| 17 #include "mojo/public/cpp/bindings/message.h" | 18 #include "mojo/public/cpp/bindings/message.h" |
| 18 #include "mojo/public/cpp/bindings/sync_handle_watcher.h" | 19 #include "mojo/public/cpp/bindings/sync_handle_watcher.h" |
| 19 #include "mojo/public/cpp/system/core.h" | 20 #include "mojo/public/cpp/system/core.h" |
| 20 #include "mojo/public/cpp/system/watcher.h" | 21 #include "mojo/public/cpp/system/watcher.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class Lock; | 24 class Lock; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 std::unique_ptr<Watcher> handle_watcher_; | 191 std::unique_ptr<Watcher> handle_watcher_; |
| 191 | 192 |
| 192 bool error_ = false; | 193 bool error_ = false; |
| 193 bool drop_writes_ = false; | 194 bool drop_writes_ = false; |
| 194 bool enforce_errors_from_incoming_receiver_ = true; | 195 bool enforce_errors_from_incoming_receiver_ = true; |
| 195 | 196 |
| 196 bool paused_ = false; | 197 bool paused_ = false; |
| 197 | 198 |
| 198 // If sending messages is allowed from multiple threads, |lock_| is used to | 199 // If sending messages is allowed from multiple threads, |lock_| is used to |
| 199 // protect modifications to |message_pipe_| and |drop_writes_|. | 200 // protect modifications to |message_pipe_| and |drop_writes_|. |
| 200 std::unique_ptr<base::Lock> lock_; | 201 base::Optional<base::Lock> lock_; |
| 201 | 202 |
| 202 std::unique_ptr<SyncHandleWatcher> sync_watcher_; | 203 std::unique_ptr<SyncHandleWatcher> sync_watcher_; |
| 203 bool allow_woken_up_by_others_ = false; | 204 bool allow_woken_up_by_others_ = false; |
| 204 // If non-zero, currently the control flow is inside the sync handle watcher | 205 // If non-zero, currently the control flow is inside the sync handle watcher |
| 205 // callback. | 206 // callback. |
| 206 size_t sync_handle_watcher_callback_count_ = 0; | 207 size_t sync_handle_watcher_callback_count_ = 0; |
| 207 | 208 |
| 208 base::ThreadChecker thread_checker_; | 209 base::ThreadChecker thread_checker_; |
| 209 | 210 |
| 210 base::Lock connected_lock_; | 211 base::Lock connected_lock_; |
| 211 bool connected_ = true; | 212 bool connected_ = true; |
| 212 | 213 |
| 213 // The tag used to track heap allocations that originated from a Watcher | 214 // The tag used to track heap allocations that originated from a Watcher |
| 214 // notification. | 215 // notification. |
| 215 const char* heap_profiler_tag_ = nullptr; | 216 const char* heap_profiler_tag_ = nullptr; |
| 216 | 217 |
| 217 // Create a single weak ptr and use it everywhere, to avoid the malloc/free | 218 // Create a single weak ptr and use it everywhere, to avoid the malloc/free |
| 218 // cost of creating a new weak ptr whenever it is needed. | 219 // cost of creating a new weak ptr whenever it is needed. |
| 219 // NOTE: This weak pointer is invalidated when the message pipe is closed or | 220 // NOTE: This weak pointer is invalidated when the message pipe is closed or |
| 220 // transferred (i.e., when |connected_| is set to false). | 221 // transferred (i.e., when |connected_| is set to false). |
| 221 base::WeakPtr<Connector> weak_self_; | 222 base::WeakPtr<Connector> weak_self_; |
| 222 base::WeakPtrFactory<Connector> weak_factory_; | 223 base::WeakPtrFactory<Connector> weak_factory_; |
| 223 | 224 |
| 224 DISALLOW_COPY_AND_ASSIGN(Connector); | 225 DISALLOW_COPY_AND_ASSIGN(Connector); |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 } // namespace mojo | 228 } // namespace mojo |
| 228 | 229 |
| 229 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ | 230 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
| OLD | NEW |