| 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_SYSTEM_CHANNEL_H_ | 5 #ifndef MOJO_SYSTEM_CHANNEL_H_ |
| 6 #define MOJO_SYSTEM_CHANNEL_H_ | 6 #define MOJO_SYSTEM_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "mojo/system/system_impl_export.h" | 24 #include "mojo/system/system_impl_export.h" |
| 25 | 25 |
| 26 namespace mojo { | 26 namespace mojo { |
| 27 | 27 |
| 28 namespace embedder { | 28 namespace embedder { |
| 29 class PlatformSupport; | 29 class PlatformSupport; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace system { | 32 namespace system { |
| 33 | 33 |
| 34 class ChannelEndpoint; |
| 35 |
| 34 // This class is mostly thread-safe. It must be created on an I/O thread. | 36 // This class is mostly thread-safe. It must be created on an I/O thread. |
| 35 // |Init()| must be called on that same thread before it becomes thread-safe (in | 37 // |Init()| must be called on that same thread before it becomes thread-safe (in |
| 36 // particular, before references are given to any other thread) and |Shutdown()| | 38 // particular, before references are given to any other thread) and |Shutdown()| |
| 37 // must be called on that same thread before destruction. Its public methods are | 39 // must be called on that same thread before destruction. Its public methods are |
| 38 // otherwise thread-safe. (Many private methods are restricted to the creation | 40 // otherwise thread-safe. (Many private methods are restricted to the creation |
| 39 // thread.) It may be destroyed on any thread, in the sense that the last | 41 // thread.) It may be destroyed on any thread, in the sense that the last |
| 40 // reference to it may be released on any thread, with the proviso that | 42 // reference to it may be released on any thread, with the proviso that |
| 41 // |Shutdown()| must have been called first (so the pattern is that a "main" | 43 // |Shutdown()| must have been called first (so the pattern is that a "main" |
| 42 // reference is kept on its creation thread and is released after |Shutdown()| | 44 // reference is kept on its creation thread and is released after |Shutdown()| |
| 43 // is called, but other threads may have temporarily "dangling" references). | 45 // is called, but other threads may have temporarily "dangling" references). |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // This must be called on the creation thread before destruction (which can | 77 // This must be called on the creation thread before destruction (which can |
| 76 // happen on any thread). | 78 // happen on any thread). |
| 77 void Shutdown(); | 79 void Shutdown(); |
| 78 | 80 |
| 79 // Signals that |Shutdown()| will be called soon (this may be called from any | 81 // Signals that |Shutdown()| will be called soon (this may be called from any |
| 80 // thread, unlike |Shutdown()|). Warnings will be issued if, e.g., messages | 82 // thread, unlike |Shutdown()|). Warnings will be issued if, e.g., messages |
| 81 // are written after this is called; other warnings may be suppressed. (This | 83 // are written after this is called; other warnings may be suppressed. (This |
| 82 // may be called multiple times, or not at all.) | 84 // may be called multiple times, or not at all.) |
| 83 void WillShutdownSoon(); | 85 void WillShutdownSoon(); |
| 84 | 86 |
| 87 // TODO(vtl): Write comment here. |
| 88 MessageInTransit::EndpointId AttachEndpoint( |
| 89 scoped_refptr<ChannelEndpoint> endpoint); |
| 90 |
| 91 // TODO(vtl): Remove this version. |
| 85 // Attaches the given message pipe/port's endpoint (which must be a | 92 // Attaches the given message pipe/port's endpoint (which must be a |
| 86 // |ProxyMessagePipeEndpoint|) to this channel. This assigns it a local ID, | 93 // |ProxyMessagePipeEndpoint|) to this channel. This assigns it a local ID, |
| 87 // which it returns. The first message pipe endpoint attached will always have | 94 // which it returns. The first message pipe endpoint attached will always have |
| 88 // |kBootstrapEndpointId| as its local ID. (For bootstrapping, this occurs on | 95 // |kBootstrapEndpointId| as its local ID. (For bootstrapping, this occurs on |
| 89 // both sides, so one should use |kBootstrapEndpointId| for the remote ID for | 96 // both sides, so one should use |kBootstrapEndpointId| for the remote ID for |
| 90 // the first message pipe across a channel.) Returns |kInvalidEndpointId| on | 97 // the first message pipe across a channel.) Returns |kInvalidEndpointId| on |
| 91 // failure. | 98 // failure. |
| 92 // TODO(vtl): This should be combined with "run", and it should take a | 99 // TODO(vtl): This should be combined with "run", and it should take a |
| 93 // |ChannelEndpoint| instead. | 100 // |ChannelEndpoint| instead. |
| 94 // TODO(vtl): Maybe limit the number of attached message pipes. | 101 // TODO(vtl): Maybe limit the number of attached message pipes. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // be checked for existence before use. | 202 // be checked for existence before use. |
| 196 MessageInTransit::EndpointId next_local_id_; | 203 MessageInTransit::EndpointId next_local_id_; |
| 197 | 204 |
| 198 DISALLOW_COPY_AND_ASSIGN(Channel); | 205 DISALLOW_COPY_AND_ASSIGN(Channel); |
| 199 }; | 206 }; |
| 200 | 207 |
| 201 } // namespace system | 208 } // namespace system |
| 202 } // namespace mojo | 209 } // namespace mojo |
| 203 | 210 |
| 204 #endif // MOJO_SYSTEM_CHANNEL_H_ | 211 #endif // MOJO_SYSTEM_CHANNEL_H_ |
| OLD | NEW |