| 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop.h" | |
| 8 #include "ipc/ipc_channel_proxy.h" | 7 #include "ipc/ipc_channel_proxy.h" |
| 9 #include "ipc/ipc_logging.h" | 8 #include "ipc/ipc_logging.h" |
| 10 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
| 11 | 10 |
| 12 namespace IPC { | 11 namespace IPC { |
| 13 | 12 |
| 14 //------------------------------------------------------------------------------ | 13 //------------------------------------------------------------------------------ |
| 15 | 14 |
| 16 // This task ensures the message is deleted if the task is deleted without | 15 // This task ensures the message is deleted if the task is deleted without |
| 17 // having been run. | 16 // having been run. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return false; | 52 return false; |
| 54 } | 53 } |
| 55 | 54 |
| 56 void ChannelProxy::MessageFilter::OnDestruct() const { | 55 void ChannelProxy::MessageFilter::OnDestruct() const { |
| 57 delete this; | 56 delete this; |
| 58 } | 57 } |
| 59 | 58 |
| 60 //------------------------------------------------------------------------------ | 59 //------------------------------------------------------------------------------ |
| 61 | 60 |
| 62 ChannelProxy::Context::Context(Channel::Listener* listener, | 61 ChannelProxy::Context::Context(Channel::Listener* listener, |
| 63 MessageLoop* ipc_message_loop) | 62 base::MessageLoopProxy* ipc_message_loop) |
| 64 : listener_message_loop_(MessageLoop::current()), | 63 : listener_message_loop_(base::MessageLoopProxy::CreateForCurrentThread()), |
| 65 listener_(listener), | 64 listener_(listener), |
| 66 ipc_message_loop_(ipc_message_loop), | 65 ipc_message_loop_(ipc_message_loop), |
| 67 peer_pid_(0), | 66 peer_pid_(0), |
| 68 channel_connected_called_(false) { | 67 channel_connected_called_(false) { |
| 69 } | 68 } |
| 70 | 69 |
| 70 ChannelProxy::Context::~Context() { |
| 71 } |
| 72 |
| 71 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, | 73 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, |
| 72 const Channel::Mode& mode) { | 74 const Channel::Mode& mode) { |
| 73 DCHECK(channel_.get() == NULL); | 75 DCHECK(channel_.get() == NULL); |
| 74 channel_id_ = handle.name; | 76 channel_id_ = handle.name; |
| 75 channel_.reset(new Channel(handle, mode, this)); | 77 channel_.reset(new Channel(handle, mode, this)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool ChannelProxy::Context::TryFilters(const Message& message) { | 80 bool ChannelProxy::Context::TryFilters(const Message& message) { |
| 79 #ifdef IPC_MESSAGE_LOG_ENABLED | 81 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 80 Logging* logger = Logging::GetInstance(); | 82 Logging* logger = Logging::GetInstance(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 void ChannelProxy::Context::OnDispatchError() { | 275 void ChannelProxy::Context::OnDispatchError() { |
| 274 if (listener_) | 276 if (listener_) |
| 275 listener_->OnChannelError(); | 277 listener_->OnChannelError(); |
| 276 } | 278 } |
| 277 | 279 |
| 278 //----------------------------------------------------------------------------- | 280 //----------------------------------------------------------------------------- |
| 279 | 281 |
| 280 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, | 282 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, |
| 281 Channel::Mode mode, | 283 Channel::Mode mode, |
| 282 Channel::Listener* listener, | 284 Channel::Listener* listener, |
| 283 MessageLoop* ipc_thread) | 285 base::MessageLoopProxy* ipc_thread) |
| 284 : context_(new Context(listener, ipc_thread)) { | 286 : context_(new Context(listener, ipc_thread)) { |
| 285 Init(channel_handle, mode, ipc_thread, true); | 287 Init(channel_handle, mode, ipc_thread, true); |
| 286 } | 288 } |
| 287 | 289 |
| 288 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, | 290 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, |
| 289 Channel::Mode mode, | 291 Channel::Mode mode, |
| 290 MessageLoop* ipc_thread, | 292 base::MessageLoopProxy* ipc_thread, |
| 291 Context* context, | 293 Context* context, |
| 292 bool create_pipe_now) | 294 bool create_pipe_now) |
| 293 : context_(context) { | 295 : context_(context) { |
| 294 Init(channel_handle, mode, ipc_thread, create_pipe_now); | 296 Init(channel_handle, mode, ipc_thread, create_pipe_now); |
| 295 } | 297 } |
| 296 | 298 |
| 297 ChannelProxy::~ChannelProxy() { | 299 ChannelProxy::~ChannelProxy() { |
| 298 Close(); | 300 Close(); |
| 299 } | 301 } |
| 300 | 302 |
| 301 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, | 303 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
| 302 Channel::Mode mode, MessageLoop* ipc_thread_loop, | 304 Channel::Mode mode, |
| 305 base::MessageLoopProxy* ipc_thread_loop, |
| 303 bool create_pipe_now) { | 306 bool create_pipe_now) { |
| 304 #if defined(OS_POSIX) | 307 #if defined(OS_POSIX) |
| 305 // When we are creating a server on POSIX, we need its file descriptor | 308 // When we are creating a server on POSIX, we need its file descriptor |
| 306 // to be created immediately so that it can be accessed and passed | 309 // to be created immediately so that it can be accessed and passed |
| 307 // to other processes. Forcing it to be created immediately avoids | 310 // to other processes. Forcing it to be created immediately avoids |
| 308 // race conditions that may otherwise arise. | 311 // race conditions that may otherwise arise. |
| 309 if (mode & Channel::MODE_SERVER_FLAG) { | 312 if (mode & Channel::MODE_SERVER_FLAG) { |
| 310 create_pipe_now = true; | 313 create_pipe_now = true; |
| 311 } | 314 } |
| 312 #endif // defined(OS_POSIX) | 315 #endif // defined(OS_POSIX) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 Channel *channel = context_.get()->channel_.get(); | 383 Channel *channel = context_.get()->channel_.get(); |
| 381 // Channel must have been created first. | 384 // Channel must have been created first. |
| 382 DCHECK(channel) << context_.get()->channel_id_; | 385 DCHECK(channel) << context_.get()->channel_id_; |
| 383 return channel->GetClientEuid(client_euid); | 386 return channel->GetClientEuid(client_euid); |
| 384 } | 387 } |
| 385 #endif | 388 #endif |
| 386 | 389 |
| 387 //----------------------------------------------------------------------------- | 390 //----------------------------------------------------------------------------- |
| 388 | 391 |
| 389 } // namespace IPC | 392 } // namespace IPC |
| OLD | NEW |