| 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 #include "mojo/system/message_pipe_dispatcher.h" | 5 #include "mojo/system/message_pipe_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
| 9 #include "mojo/system/channel_endpoint.h" | 9 #include "mojo/system/channel_endpoint.h" |
| 10 #include "mojo/system/constants.h" | 10 #include "mojo/system/constants.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 void MessagePipeDispatcher::CancelAllWaitersNoLock() { | 157 void MessagePipeDispatcher::CancelAllWaitersNoLock() { |
| 158 lock().AssertAcquired(); | 158 lock().AssertAcquired(); |
| 159 message_pipe_->CancelAllWaiters(port_); | 159 message_pipe_->CancelAllWaiters(port_); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void MessagePipeDispatcher::CloseImplNoLock() { | 162 void MessagePipeDispatcher::CloseImplNoLock() { |
| 163 lock().AssertAcquired(); | 163 lock().AssertAcquired(); |
| 164 message_pipe_->Close(port_); | 164 message_pipe_->Close(port_); |
| 165 message_pipe_ = NULL; | 165 message_pipe_ = nullptr; |
| 166 port_ = kInvalidPort; | 166 port_ = kInvalidPort; |
| 167 } | 167 } |
| 168 | 168 |
| 169 scoped_refptr<Dispatcher> | 169 scoped_refptr<Dispatcher> |
| 170 MessagePipeDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { | 170 MessagePipeDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
| 171 lock().AssertAcquired(); | 171 lock().AssertAcquired(); |
| 172 | 172 |
| 173 // TODO(vtl): Currently, there are no options, so we just use | 173 // TODO(vtl): Currently, there are no options, so we just use |
| 174 // |kDefaultCreateOptions|. Eventually, we'll have to duplicate the options | 174 // |kDefaultCreateOptions|. Eventually, we'll have to duplicate the options |
| 175 // too. | 175 // too. |
| 176 scoped_refptr<MessagePipeDispatcher> rv = | 176 scoped_refptr<MessagePipeDispatcher> rv = |
| 177 new MessagePipeDispatcher(kDefaultCreateOptions); | 177 new MessagePipeDispatcher(kDefaultCreateOptions); |
| 178 rv->Init(message_pipe_, port_); | 178 rv->Init(message_pipe_, port_); |
| 179 message_pipe_ = NULL; | 179 message_pipe_ = nullptr; |
| 180 port_ = kInvalidPort; | 180 port_ = kInvalidPort; |
| 181 return scoped_refptr<Dispatcher>(rv.get()); | 181 return scoped_refptr<Dispatcher>(rv.get()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( | 184 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( |
| 185 UserPointer<const void> bytes, | 185 UserPointer<const void> bytes, |
| 186 uint32_t num_bytes, | 186 uint32_t num_bytes, |
| 187 std::vector<DispatcherTransport>* transports, | 187 std::vector<DispatcherTransport>* transports, |
| 188 MojoWriteMessageFlags flags) { | 188 MojoWriteMessageFlags flags) { |
| 189 DCHECK(!transports || (transports->size() > 0 && | 189 DCHECK(!transports || (transports->size() > 0 && |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // "dead" message pipe dispatcher on the other end. (Note that this is | 258 // "dead" message pipe dispatcher on the other end. (Note that this is |
| 259 // different from just producing |MOJO_HANDLE_INVALID|.) | 259 // different from just producing |MOJO_HANDLE_INVALID|.) |
| 260 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id | 260 DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id |
| 261 << ")"; | 261 << ")"; |
| 262 | 262 |
| 263 // We now have a local ID. Before we can run the proxy endpoint, we need to | 263 // We now have a local ID. Before we can run the proxy endpoint, we need to |
| 264 // get an ack back from the other side with the remote ID. | 264 // get an ack back from the other side with the remote ID. |
| 265 static_cast<SerializedMessagePipeDispatcher*>(destination)->endpoint_id = | 265 static_cast<SerializedMessagePipeDispatcher*>(destination)->endpoint_id = |
| 266 endpoint_id; | 266 endpoint_id; |
| 267 | 267 |
| 268 message_pipe_ = NULL; | 268 message_pipe_ = nullptr; |
| 269 port_ = kInvalidPort; | 269 port_ = kInvalidPort; |
| 270 | 270 |
| 271 *actual_size = sizeof(SerializedMessagePipeDispatcher); | 271 *actual_size = sizeof(SerializedMessagePipeDispatcher); |
| 272 return true; | 272 return true; |
| 273 } | 273 } |
| 274 | 274 |
| 275 // MessagePipeDispatcherTransport ---------------------------------------------- | 275 // MessagePipeDispatcherTransport ---------------------------------------------- |
| 276 | 276 |
| 277 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 277 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
| 278 DispatcherTransport transport) | 278 DispatcherTransport transport) |
| 279 : DispatcherTransport(transport) { | 279 : DispatcherTransport(transport) { |
| 280 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 280 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace system | 283 } // namespace system |
| 284 } // namespace mojo | 284 } // namespace mojo |
| OLD | NEW |