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 base::ProcessId ChannelNacl::GetPeerPID() const { | 145 base::ProcessId ChannelNacl::GetPeerPID() const { |
148 // This shouldn't actually get used in the untrusted side of the proxy, and we | 146 // This shouldn't actually get used in the untrusted side of the proxy, and we |
149 // don't have the real pid anyway. | 147 // don't have the real pid anyway. |
150 return -1; | 148 return -1; |
151 } | 149 } |
152 | 150 |
153 base::ProcessId ChannelNacl::GetSelfPID() const { | 151 base::ProcessId ChannelNacl::GetSelfPID() const { |
154 return -1; | 152 return -1; |
155 } | 153 } |
156 | 154 |
157 bool ChannelNacl::Connect() { | 155 bool ChannelNacl::Connect() { |
158 WillConnect(); | 156 WillConnect(); |
159 | 157 |
160 if (pipe_ == -1) { | 158 if (pipe_ == -1) { |
161 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; | 159 DLOG(WARNING) << "Channel creation failed"; |
162 return false; | 160 return false; |
163 } | 161 } |
164 | 162 |
165 // Note that Connect is called on the "Channel" thread (i.e., the same thread | 163 // Note that Connect is called on the "Channel" thread (i.e., the same thread |
166 // where Channel::Send will be called, and the same thread that should receive | 164 // where Channel::Send will be called, and the same thread that should receive |
167 // messages). The constructor might be invoked on another thread (see | 165 // messages). The constructor might be invoked on another thread (see |
168 // ChannelProxy for an example of that). Therefore, we must wait until Connect | 166 // ChannelProxy for an example of that). Therefore, we must wait until Connect |
169 // is called to decide which SingleThreadTaskRunner to pass to | 167 // is called to decide which SingleThreadTaskRunner to pass to |
170 // ReaderThreadRunner. | 168 // ReaderThreadRunner. |
171 reader_thread_runner_.reset(new ReaderThreadRunner( | 169 reader_thread_runner_.reset(new ReaderThreadRunner( |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 390 |
393 // static | 391 // static |
394 std::unique_ptr<Channel> Channel::Create( | 392 std::unique_ptr<Channel> Channel::Create( |
395 const IPC::ChannelHandle& channel_handle, | 393 const IPC::ChannelHandle& channel_handle, |
396 Mode mode, | 394 Mode mode, |
397 Listener* listener) { | 395 Listener* listener) { |
398 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); | 396 return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); |
399 } | 397 } |
400 | 398 |
401 } // namespace IPC | 399 } // namespace IPC |
OLD | NEW |