OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/location.h" | 5 #include "base/location.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "ipc/ipc_channel_proxy.h" | 8 #include "ipc/ipc_channel_proxy.h" |
9 #include "ipc/ipc_logging.h" | 9 #include "ipc/ipc_logging.h" |
10 #include "ipc/ipc_message_utils.h" | 10 #include "ipc/ipc_message_utils.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 279 } |
280 | 280 |
281 //----------------------------------------------------------------------------- | 281 //----------------------------------------------------------------------------- |
282 | 282 |
283 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, | 283 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, |
284 Channel::Mode mode, | 284 Channel::Mode mode, |
285 Channel::Listener* listener, | 285 Channel::Listener* listener, |
286 base::MessageLoopProxy* ipc_thread) | 286 base::MessageLoopProxy* ipc_thread) |
287 : context_(new Context(listener, ipc_thread)), | 287 : context_(new Context(listener, ipc_thread)), |
288 outgoing_message_filter_(NULL) { | 288 outgoing_message_filter_(NULL) { |
289 Init(channel_handle, mode, ipc_thread, true); | 289 Init(channel_handle, mode, true); |
290 } | 290 } |
291 | 291 |
292 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, | 292 ChannelProxy::ChannelProxy(Context* context) |
293 Channel::Mode mode, | |
294 base::MessageLoopProxy* ipc_thread, | |
295 Context* context, | |
296 bool create_pipe_now) | |
297 : context_(context), | 293 : context_(context), |
298 outgoing_message_filter_(NULL) { | 294 outgoing_message_filter_(NULL) { |
299 Init(channel_handle, mode, ipc_thread, create_pipe_now); | |
300 } | 295 } |
301 | 296 |
302 ChannelProxy::~ChannelProxy() { | 297 ChannelProxy::~ChannelProxy() { |
303 Close(); | 298 Close(); |
304 } | 299 } |
305 | 300 |
306 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, | 301 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
dmac
2011/11/04 22:30:44
anyway to enforce that this is only called once?
kkania
2011/11/07 20:25:16
added did_init_
| |
307 Channel::Mode mode, | 302 Channel::Mode mode, |
308 base::MessageLoopProxy* ipc_thread_loop, | |
309 bool create_pipe_now) { | 303 bool create_pipe_now) { |
310 #if defined(OS_POSIX) | 304 #if defined(OS_POSIX) |
311 // When we are creating a server on POSIX, we need its file descriptor | 305 // When we are creating a server on POSIX, we need its file descriptor |
312 // to be created immediately so that it can be accessed and passed | 306 // to be created immediately so that it can be accessed and passed |
313 // to other processes. Forcing it to be created immediately avoids | 307 // to other processes. Forcing it to be created immediately avoids |
314 // race conditions that may otherwise arise. | 308 // race conditions that may otherwise arise. |
315 if (mode & Channel::MODE_SERVER_FLAG) { | 309 if (mode & Channel::MODE_SERVER_FLAG) { |
316 create_pipe_now = true; | 310 create_pipe_now = true; |
317 } | 311 } |
318 #endif // defined(OS_POSIX) | 312 #endif // defined(OS_POSIX) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 Channel* channel = context_.get()->channel_.get(); | 389 Channel* channel = context_.get()->channel_.get(); |
396 // Channel must have been created first. | 390 // Channel must have been created first. |
397 DCHECK(channel) << context_.get()->channel_id_; | 391 DCHECK(channel) << context_.get()->channel_id_; |
398 return channel->GetClientEuid(client_euid); | 392 return channel->GetClientEuid(client_euid); |
399 } | 393 } |
400 #endif | 394 #endif |
401 | 395 |
402 //----------------------------------------------------------------------------- | 396 //----------------------------------------------------------------------------- |
403 | 397 |
404 } // namespace IPC | 398 } // namespace IPC |
OLD | NEW |