| 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_EDK_SYSTEM_CHANNEL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_H_ |
| 6 #define MOJO_EDK_SYSTEM_CHANNEL_H_ | 6 #define MOJO_EDK_SYSTEM_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 | 12 |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "mojo/edk/embedder/scoped_platform_handle.h" | 14 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #include "mojo/edk/system/channel_endpoint.h" | 15 #include "mojo/edk/system/channel_endpoint.h" |
| 16 #include "mojo/edk/system/channel_endpoint_id.h" | 16 #include "mojo/edk/system/channel_endpoint_id.h" |
| 17 #include "mojo/edk/system/incoming_endpoint.h" | 17 #include "mojo/edk/system/incoming_endpoint.h" |
| 18 #include "mojo/edk/system/message_in_transit.h" | 18 #include "mojo/edk/system/message_in_transit.h" |
| 19 #include "mojo/edk/system/mutex.h" | |
| 20 #include "mojo/edk/system/raw_channel.h" | 19 #include "mojo/edk/system/raw_channel.h" |
| 20 #include "mojo/edk/util/mutex.h" |
| 21 #include "mojo/edk/util/ref_counted.h" | 21 #include "mojo/edk/util/ref_counted.h" |
| 22 #include "mojo/edk/util/ref_ptr.h" | 22 #include "mojo/edk/util/ref_ptr.h" |
| 23 #include "mojo/edk/util/thread_annotations.h" |
| 23 #include "mojo/public/c/system/types.h" | 24 #include "mojo/public/c/system/types.h" |
| 24 #include "mojo/public/cpp/system/macros.h" | 25 #include "mojo/public/cpp/system/macros.h" |
| 25 | 26 |
| 26 namespace mojo { | 27 namespace mojo { |
| 27 | 28 |
| 28 namespace embedder { | 29 namespace embedder { |
| 29 class PlatformSupport; | 30 class PlatformSupport; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace system { | 33 namespace system { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 embedder::PlatformSupport* const platform_support_; | 242 embedder::PlatformSupport* const platform_support_; |
| 242 | 243 |
| 243 // Note: |ChannelEndpointClient|s (in particular, |MessagePipe|s) MUST NOT be | 244 // Note: |ChannelEndpointClient|s (in particular, |MessagePipe|s) MUST NOT be |
| 244 // used under |mutex_|. E.g., |mutex_| can only be acquired after | 245 // used under |mutex_|. E.g., |mutex_| can only be acquired after |
| 245 // |MessagePipe::lock_|, never before. Thus to call into a | 246 // |MessagePipe::lock_|, never before. Thus to call into a |
| 246 // |ChannelEndpointClient|, a reference should be acquired from | 247 // |ChannelEndpointClient|, a reference should be acquired from |
| 247 // |local_id_to_endpoint_map_| under |mutex_| and then the lock released. | 248 // |local_id_to_endpoint_map_| under |mutex_| and then the lock released. |
| 248 // TODO(vtl): Annotate the above rule using |MOJO_ACQUIRED_{BEFORE,AFTER}()|, | 249 // TODO(vtl): Annotate the above rule using |MOJO_ACQUIRED_{BEFORE,AFTER}()|, |
| 249 // once clang actually checks such annotations. | 250 // once clang actually checks such annotations. |
| 250 // https://github.com/domokit/mojo/issues/313 | 251 // https://github.com/domokit/mojo/issues/313 |
| 251 mutable Mutex mutex_; | 252 mutable util::Mutex mutex_; |
| 252 | 253 |
| 253 std::unique_ptr<RawChannel> raw_channel_ MOJO_GUARDED_BY(mutex_); | 254 std::unique_ptr<RawChannel> raw_channel_ MOJO_GUARDED_BY(mutex_); |
| 254 bool is_running_ MOJO_GUARDED_BY(mutex_); | 255 bool is_running_ MOJO_GUARDED_BY(mutex_); |
| 255 // Set when |WillShutdownSoon()| is called. | 256 // Set when |WillShutdownSoon()| is called. |
| 256 bool is_shutting_down_ MOJO_GUARDED_BY(mutex_); | 257 bool is_shutting_down_ MOJO_GUARDED_BY(mutex_); |
| 257 | 258 |
| 258 // Has a reference to us. | 259 // Has a reference to us. |
| 259 ChannelManager* channel_manager_ MOJO_GUARDED_BY(mutex_); | 260 ChannelManager* channel_manager_ MOJO_GUARDED_BY(mutex_); |
| 260 | 261 |
| 261 using IdToEndpointMap = | 262 using IdToEndpointMap = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 275 // if/when we wrap). | 276 // if/when we wrap). |
| 276 RemoteChannelEndpointIdGenerator remote_id_generator_ MOJO_GUARDED_BY(mutex_); | 277 RemoteChannelEndpointIdGenerator remote_id_generator_ MOJO_GUARDED_BY(mutex_); |
| 277 | 278 |
| 278 MOJO_DISALLOW_COPY_AND_ASSIGN(Channel); | 279 MOJO_DISALLOW_COPY_AND_ASSIGN(Channel); |
| 279 }; | 280 }; |
| 280 | 281 |
| 281 } // namespace system | 282 } // namespace system |
| 282 } // namespace mojo | 283 } // namespace mojo |
| 283 | 284 |
| 284 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ | 285 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ |
| OLD | NEW |