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_proxy.h" | 5 #include "ipc/ipc_channel_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void ChannelProxy::Context::ClearIPCTaskRunner() { | 47 void ChannelProxy::Context::ClearIPCTaskRunner() { |
48 ipc_task_runner_ = NULL; | 48 ipc_task_runner_ = NULL; |
49 } | 49 } |
50 | 50 |
51 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, | 51 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, |
52 const Channel::Mode& mode) { | 52 const Channel::Mode& mode) { |
53 DCHECK(!channel_); | 53 DCHECK(!channel_); |
54 channel_id_ = handle.name; | 54 channel_id_ = handle.name; |
55 channel_ = Channel::CreateByModeForProxy(handle, mode, this); | 55 channel_ = Channel::Create(handle, mode, this); |
56 } | 56 } |
57 | 57 |
58 bool ChannelProxy::Context::TryFilters(const Message& message) { | 58 bool ChannelProxy::Context::TryFilters(const Message& message) { |
59 DCHECK(message_filter_router_); | 59 DCHECK(message_filter_router_); |
60 #ifdef IPC_MESSAGE_LOG_ENABLED | 60 #ifdef IPC_MESSAGE_LOG_ENABLED |
61 Logging* logger = Logging::GetInstance(); | 61 Logging* logger = Logging::GetInstance(); |
62 if (logger->Enabled()) | 62 if (logger->Enabled()) |
63 logger->OnPreDispatchMessage(message); | 63 logger->OnPreDispatchMessage(message); |
64 #endif | 64 #endif |
65 | 65 |
(...skipping 22 matching lines...) Expand all Loading... |
88 // Called on the IPC::Channel thread | 88 // Called on the IPC::Channel thread |
89 bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { | 89 bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { |
90 listener_task_runner_->PostTask( | 90 listener_task_runner_->PostTask( |
91 FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message)); | 91 FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message)); |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 // Called on the IPC::Channel thread | 95 // Called on the IPC::Channel thread |
96 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { | 96 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { |
97 // We cache off the peer_pid so it can be safely accessed from both threads. | 97 // We cache off the peer_pid so it can be safely accessed from both threads. |
98 peer_pid_ = channel_->peer_pid(); | 98 peer_pid_ = channel_->GetPeerPID(); |
99 | 99 |
100 // Add any pending filters. This avoids a race condition where someone | 100 // Add any pending filters. This avoids a race condition where someone |
101 // creates a ChannelProxy, calls AddFilter, and then right after starts the | 101 // creates a ChannelProxy, calls AddFilter, and then right after starts the |
102 // peer process. The IO thread could receive a message before the task to add | 102 // peer process. The IO thread could receive a message before the task to add |
103 // the filter is run on the IO thread. | 103 // the filter is run on the IO thread. |
104 OnAddFilter(); | 104 OnAddFilter(); |
105 | 105 |
106 // See above comment about using listener_task_runner_ here. | 106 // See above comment about using listener_task_runner_ here. |
107 listener_task_runner_->PostTask( | 107 listener_task_runner_->PostTask( |
108 FROM_HERE, base::Bind(&Context::OnDispatchConnected, this)); | 108 FROM_HERE, base::Bind(&Context::OnDispatchConnected, this)); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 Channel* channel = context_.get()->channel_.get(); | 443 Channel* channel = context_.get()->channel_.get(); |
444 // Channel must have been created first. | 444 // Channel must have been created first. |
445 DCHECK(channel) << context_.get()->channel_id_; | 445 DCHECK(channel) << context_.get()->channel_id_; |
446 return channel->GetPeerEuid(peer_euid); | 446 return channel->GetPeerEuid(peer_euid); |
447 } | 447 } |
448 #endif | 448 #endif |
449 | 449 |
450 //----------------------------------------------------------------------------- | 450 //----------------------------------------------------------------------------- |
451 | 451 |
452 } // namespace IPC | 452 } // namespace IPC |
OLD | NEW |