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 <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 ChannelNacl::ChannelNacl(const IPC::ChannelHandle& channel_handle, | 125 ChannelNacl::ChannelNacl(const IPC::ChannelHandle& channel_handle, |
126 Mode mode, | 126 Mode mode, |
127 Listener* listener) | 127 Listener* listener) |
128 : ChannelReader(listener), | 128 : ChannelReader(listener), |
129 mode_(mode), | 129 mode_(mode), |
130 waiting_connect_(true), | 130 waiting_connect_(true), |
131 pipe_(-1), | 131 pipe_(-1), |
132 pipe_name_(channel_handle.name), | |
133 weak_ptr_factory_(this) { | 132 weak_ptr_factory_(this) { |
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 in " << modestr << " mode"; |
138 << "\" in " << modestr << " mode"; | |
139 } | 137 } |
140 } | 138 } |
141 | 139 |
142 ChannelNacl::~ChannelNacl() { | 140 ChannelNacl::~ChannelNacl() { |
143 CleanUp(); | 141 CleanUp(); |
144 Close(); | 142 Close(); |
145 } | 143 } |
146 | 144 |
147 bool ChannelNacl::Connect() { | 145 bool ChannelNacl::Connect() { |
148 WillConnect(); | 146 WillConnect(); |
149 | 147 |
150 if (pipe_ == -1) { | 148 if (pipe_ == -1) { |
151 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; | 149 DLOG(WARNING) << "Channel creation failed"; |
152 return false; | 150 return false; |
153 } | 151 } |
154 | 152 |
155 // Note that Connect is called on the "Channel" thread (i.e., the same thread | 153 // Note that Connect is called on the "Channel" thread (i.e., the same thread |
156 // where Channel::Send will be called, and the same thread that should receive | 154 // where Channel::Send will be called, and the same thread that should receive |
157 // messages). The constructor might be invoked on another thread (see | 155 // messages). The constructor might be invoked on another thread (see |
158 // ChannelProxy for an example of that). Therefore, we must wait until Connect | 156 // ChannelProxy for an example of that). Therefore, we must wait until Connect |
159 // is called to decide which SingleThreadTaskRunner to pass to | 157 // is called to decide which SingleThreadTaskRunner to pass to |
160 // ReaderThreadRunner. | 158 // ReaderThreadRunner. |
161 reader_thread_runner_.reset(new ReaderThreadRunner( | 159 reader_thread_runner_.reset(new ReaderThreadRunner( |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 374 |
377 // static | 375 // static |
378 std::unique_ptr<Channel> Channel::Create( | 376 std::unique_ptr<Channel> Channel::Create( |
379 const IPC::ChannelHandle& channel_handle, | 377 const IPC::ChannelHandle& channel_handle, |
380 Mode mode, | 378 Mode mode, |
381 Listener* listener) { | 379 Listener* listener) { |
382 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); | 380 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); |
383 } | 381 } |
384 | 382 |
385 } // namespace IPC | 383 } // namespace IPC |
OLD | NEW |