| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 : public base::RefCountedThreadSafe<Channel>, | 52 : public base::RefCountedThreadSafe<Channel>, |
| 53 public RawChannel::Delegate { | 53 public RawChannel::Delegate { |
| 54 public: | 54 public: |
| 55 // The first message pipe endpoint attached will have this as its local ID. | 55 // The first message pipe endpoint attached will have this as its local ID. |
| 56 static const MessageInTransit::EndpointId kBootstrapEndpointId = 1; | 56 static const MessageInTransit::EndpointId kBootstrapEndpointId = 1; |
| 57 | 57 |
| 58 Channel(); | 58 Channel(); |
| 59 | 59 |
| 60 // 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 |
| 61 // 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 |
| 62 // threads. |handle| should be a handle to a (platform-appropriate) | 62 // threads. |raw_channel| should be uninitialized. Returns true on success. On |
| 63 // bidirectional communication channel (e.g., a socket on POSIX, a named pipe | 63 // failure, no other methods should be called (including |Shutdown()|). |
| 64 // on Windows). Returns true on success. On failure, no other methods should | 64 bool Init(scoped_ptr<RawChannel> raw_channel); |
| 65 // be called (including |Shutdown()|). | |
| 66 bool Init(embedder::ScopedPlatformHandle handle); | |
| 67 | 65 |
| 68 // This must be called on the creation thread before destruction (which can | 66 // This must be called on the creation thread before destruction (which can |
| 69 // happen on any thread). | 67 // happen on any thread). |
| 70 void Shutdown(); | 68 void Shutdown(); |
| 71 | 69 |
| 72 // Attaches the given message pipe/port's endpoint (which must be a | 70 // Attaches the given message pipe/port's endpoint (which must be a |
| 73 // |ProxyMessagePipeEndpoint|) to this channel. This assigns it a local ID, | 71 // |ProxyMessagePipeEndpoint|) to this channel. This assigns it a local ID, |
| 74 // which it returns. The first message pipe endpoint attached will always have | 72 // which it returns. The first message pipe endpoint attached will always have |
| 75 // |kBootstrapEndpointId| as its local ID. (For bootstrapping, this occurs on | 73 // |kBootstrapEndpointId| as its local ID. (For bootstrapping, this occurs on |
| 76 // both sides, so one should use |kBootstrapEndpointId| for the remote ID for | 74 // both sides, so one should use |kBootstrapEndpointId| for the remote ID for |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // be checked for existence before use. | 146 // be checked for existence before use. |
| 149 MessageInTransit::EndpointId next_local_id_; | 147 MessageInTransit::EndpointId next_local_id_; |
| 150 | 148 |
| 151 DISALLOW_COPY_AND_ASSIGN(Channel); | 149 DISALLOW_COPY_AND_ASSIGN(Channel); |
| 152 }; | 150 }; |
| 153 | 151 |
| 154 } // namespace system | 152 } // namespace system |
| 155 } // namespace mojo | 153 } // namespace mojo |
| 156 | 154 |
| 157 #endif // MOJO_SYSTEM_CHANNEL_H_ | 155 #endif // MOJO_SYSTEM_CHANNEL_H_ |
| OLD | NEW |