OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ipc/ipc_channel_nacl.h" | 5 #include "ipc/ipc_channel_nacl.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 ChannelNacl::ChannelNacl(const IPC::ChannelHandle& channel_handle, | 123 ChannelNacl::ChannelNacl(const IPC::ChannelHandle& channel_handle, |
124 Mode mode, | 124 Mode mode, |
125 Listener* listener, | 125 Listener* listener, |
126 AttachmentBroker* broker) | 126 AttachmentBroker* broker) |
127 : ChannelReader(listener), | 127 : ChannelReader(listener), |
128 mode_(mode), | 128 mode_(mode), |
129 waiting_connect_(true), | 129 waiting_connect_(true), |
130 pipe_(-1), | 130 pipe_(-1), |
131 pipe_name_(channel_handle.name), | 131 pipe_name_(channel_handle.name), |
132 weak_ptr_factory_(this), | 132 weak_ptr_factory_(this) { |
133 broker_(broker) { | |
134 if (!CreatePipe(channel_handle)) { | 133 if (!CreatePipe(channel_handle)) { |
135 // The pipe may have been closed already. | 134 // The pipe may have been closed already. |
136 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; | 135 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; |
137 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name | 136 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name |
138 << "\" in " << modestr << " mode"; | 137 << "\" in " << modestr << " mode"; |
139 } | 138 } |
140 } | 139 } |
141 | 140 |
142 ChannelNacl::~ChannelNacl() { | 141 ChannelNacl::~ChannelNacl() { |
143 Close(); | 142 Close(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 message->header()->flags, | 215 message->header()->flags, |
217 TRACE_EVENT_FLAG_FLOW_OUT); | 216 TRACE_EVENT_FLAG_FLOW_OUT); |
218 output_queue_.push_back(linked_ptr<Message>(message_ptr.release())); | 217 output_queue_.push_back(linked_ptr<Message>(message_ptr.release())); |
219 if (!waiting_connect_) | 218 if (!waiting_connect_) |
220 return ProcessOutgoingMessages(); | 219 return ProcessOutgoingMessages(); |
221 | 220 |
222 return true; | 221 return true; |
223 } | 222 } |
224 | 223 |
225 AttachmentBroker* ChannelNacl::GetAttachmentBroker() { | 224 AttachmentBroker* ChannelNacl::GetAttachmentBroker() { |
226 return broker_; | 225 return nullptr; |
227 } | 226 } |
228 | 227 |
229 void ChannelNacl::DidRecvMsg(scoped_ptr<MessageContents> contents) { | 228 void ChannelNacl::DidRecvMsg(scoped_ptr<MessageContents> contents) { |
230 // Close sets the pipe to -1. It's possible we'll get a buffer sent to us from | 229 // Close sets the pipe to -1. It's possible we'll get a buffer sent to us from |
231 // the reader thread after Close is called. If so, we ignore it. | 230 // the reader thread after Close is called. If so, we ignore it. |
232 if (pipe_ == -1) | 231 if (pipe_ == -1) |
233 return; | 232 return; |
234 | 233 |
235 linked_ptr<std::vector<char> > data(new std::vector<char>); | 234 linked_ptr<std::vector<char> > data(new std::vector<char>); |
236 data->swap(contents->data); | 235 data->swap(contents->data); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // static | 396 // static |
398 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle, | 397 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle, |
399 Mode mode, | 398 Mode mode, |
400 Listener* listener, | 399 Listener* listener, |
401 AttachmentBroker* broker) { | 400 AttachmentBroker* broker) { |
402 return scoped_ptr<Channel>( | 401 return scoped_ptr<Channel>( |
403 new ChannelNacl(channel_handle, mode, listener, broker)); | 402 new ChannelNacl(channel_handle, mode, listener, broker)); |
404 } | 403 } |
405 | 404 |
406 } // namespace IPC | 405 } // namespace IPC |
OLD | NEW |