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 "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // is called, but other threads may have temporarily "dangling" references). | 47 // is called, but other threads may have temporarily "dangling" references). |
48 // | 48 // |
49 // Note the lock order (in order of allowable acquisition): | 49 // Note the lock order (in order of allowable acquisition): |
50 // |ChannelEndpointClient| (e.g., |MessagePipe|), |ChannelEndpoint|, |Channel|. | 50 // |ChannelEndpointClient| (e.g., |MessagePipe|), |ChannelEndpoint|, |Channel|. |
51 // Thus |Channel| may not call into |ChannelEndpoint| with |Channel|'s lock | 51 // Thus |Channel| may not call into |ChannelEndpoint| with |Channel|'s lock |
52 // held. | 52 // held. |
53 class MOJO_SYSTEM_IMPL_EXPORT Channel | 53 class MOJO_SYSTEM_IMPL_EXPORT Channel |
54 : public base::RefCountedThreadSafe<Channel>, | 54 : public base::RefCountedThreadSafe<Channel>, |
55 public RawChannel::Delegate { | 55 public RawChannel::Delegate { |
56 public: | 56 public: |
57 // |platform_support| (typically owned by |Core|) must remain alive until | 57 // |platform_support| must remain alive until after |Shutdown()| is called. |
58 // after |Shutdown()| is called. | |
59 explicit Channel(embedder::PlatformSupport* platform_support); | 58 explicit Channel(embedder::PlatformSupport* platform_support); |
60 | 59 |
61 // This must be called on the creation thread before any other methods are | 60 // This must be called on the creation thread before any other methods are |
62 // called, and before references to this object are given to any other | 61 // called, and before references to this object are given to any other |
63 // threads. |raw_channel| should be uninitialized. | 62 // threads. |raw_channel| should be uninitialized. |
64 void Init(scoped_ptr<RawChannel> raw_channel); | 63 void Init(scoped_ptr<RawChannel> raw_channel); |
65 | 64 |
66 // Sets the channel manager associated with this channel. This should be set | 65 // Sets the channel manager associated with this channel. This should be set |
67 // at most once and only called before |WillShutdownSoon()| (and | 66 // at most once and only called before |WillShutdownSoon()| (and |
68 // |Shutdown()|). | 67 // |Shutdown()|). (This is called by the channel manager when adding a |
| 68 // channel; this should not be called before the channel is managed by the |
| 69 // channel manager.) |
69 void SetChannelManager(ChannelManager* channel_manager); | 70 void SetChannelManager(ChannelManager* channel_manager); |
70 | 71 |
71 // This must be called on the creation thread before destruction (which can | 72 // This must be called on the creation thread before destruction (which can |
72 // happen on any thread). | 73 // happen on any thread). |
73 void Shutdown(); | 74 void Shutdown(); |
74 | 75 |
75 // Signals that |Shutdown()| will be called soon (this may be called from any | 76 // Signals that |Shutdown()| will be called soon (this may be called from any |
76 // thread, unlike |Shutdown()|). Warnings will be issued if, e.g., messages | 77 // thread, unlike |Shutdown()|). Warnings will be issued if, e.g., messages |
77 // are written after this is called; other warnings may be suppressed. (This | 78 // are written after this is called; other warnings may be suppressed. (This |
78 // may be called multiple times, or not at all.) | 79 // may be called multiple times, or not at all.) |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // if/when we wrap). | 252 // if/when we wrap). |
252 RemoteChannelEndpointIdGenerator remote_id_generator_; | 253 RemoteChannelEndpointIdGenerator remote_id_generator_; |
253 | 254 |
254 DISALLOW_COPY_AND_ASSIGN(Channel); | 255 DISALLOW_COPY_AND_ASSIGN(Channel); |
255 }; | 256 }; |
256 | 257 |
257 } // namespace system | 258 } // namespace system |
258 } // namespace mojo | 259 } // namespace mojo |
259 | 260 |
260 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ | 261 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ |
OLD | NEW |