| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Called on the IPC::Channel thread | 111 // Called on the IPC::Channel thread |
| 112 void ChannelProxy::Context::OnChannelError() { | 112 void ChannelProxy::Context::OnChannelError() { |
| 113 for (size_t i = 0; i < filters_.size(); ++i) | 113 for (size_t i = 0; i < filters_.size(); ++i) |
| 114 filters_[i]->OnChannelError(); | 114 filters_[i]->OnSenderError(); |
| 115 | 115 |
| 116 // See above comment about using listener_task_runner_ here. | 116 // See above comment about using listener_task_runner_ here. |
| 117 listener_task_runner_->PostTask( | 117 listener_task_runner_->PostTask( |
| 118 FROM_HERE, base::Bind(&Context::OnDispatchError, this)); | 118 FROM_HERE, base::Bind(&Context::OnDispatchError, this)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Called on the IPC::Channel thread | 121 // Called on the IPC::Channel thread |
| 122 void ChannelProxy::Context::OnChannelOpened() { | 122 void ChannelProxy::Context::OnChannelOpened() { |
| 123 DCHECK(channel_ != NULL); | 123 DCHECK(channel_ != NULL); |
| 124 | 124 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Called on the IPC::Channel thread | 138 // Called on the IPC::Channel thread |
| 139 void ChannelProxy::Context::OnChannelClosed() { | 139 void ChannelProxy::Context::OnChannelClosed() { |
| 140 // It's okay for IPC::ChannelProxy::Close to be called more than once, which | 140 // It's okay for IPC::ChannelProxy::Close to be called more than once, which |
| 141 // would result in this branch being taken. | 141 // would result in this branch being taken. |
| 142 if (!channel_) | 142 if (!channel_) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 for (size_t i = 0; i < filters_.size(); ++i) { | 145 for (size_t i = 0; i < filters_.size(); ++i) { |
| 146 filters_[i]->OnChannelClosing(); | 146 filters_[i]->OnSenderClosing(); |
| 147 filters_[i]->OnFilterRemoved(); | 147 filters_[i]->OnFilterRemoved(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 // We don't need the filters anymore. | 150 // We don't need the filters anymore. |
| 151 message_filter_router_->Clear(); | 151 message_filter_router_->Clear(); |
| 152 filters_.clear(); | 152 filters_.clear(); |
| 153 // We don't need the lock, because at this point, the listener thread can't | 153 // We don't need the lock, because at this point, the listener thread can't |
| 154 // access it any more. | 154 // access it any more. |
| 155 pending_filters_.clear(); | 155 pending_filters_.clear(); |
| 156 | 156 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 192 } |
| 193 | 193 |
| 194 for (size_t i = 0; i < new_filters.size(); ++i) { | 194 for (size_t i = 0; i < new_filters.size(); ++i) { |
| 195 filters_.push_back(new_filters[i]); | 195 filters_.push_back(new_filters[i]); |
| 196 | 196 |
| 197 message_filter_router_->AddFilter(new_filters[i].get()); | 197 message_filter_router_->AddFilter(new_filters[i].get()); |
| 198 | 198 |
| 199 // The channel has already been created and connected, so we need to | 199 // The channel has already been created and connected, so we need to |
| 200 // inform the filters right now. | 200 // inform the filters right now. |
| 201 new_filters[i]->OnFilterAdded(channel_.get()); | 201 new_filters[i]->OnFilterAdded(channel_.get()); |
| 202 new_filters[i]->OnChannelConnected(peer_pid_); | 202 new_filters[i]->OnSenderConnected(); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Called on the IPC::Channel thread | 206 // Called on the IPC::Channel thread |
| 207 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { | 207 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { |
| 208 if (peer_pid_ == base::kNullProcessId) { | 208 if (peer_pid_ == base::kNullProcessId) { |
| 209 // The channel is not yet connected, so any filters are still pending. | 209 // The channel is not yet connected, so any filters are still pending. |
| 210 base::AutoLock auto_lock(pending_filters_lock_); | 210 base::AutoLock auto_lock(pending_filters_lock_); |
| 211 for (size_t i = 0; i < pending_filters_.size(); ++i) { | 211 for (size_t i = 0; i < pending_filters_.size(); ++i) { |
| 212 if (pending_filters_[i].get() == filter) { | 212 if (pending_filters_[i].get() == filter) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 Channel* channel = context_.get()->channel_.get(); | 434 Channel* channel = context_.get()->channel_.get(); |
| 435 // Channel must have been created first. | 435 // Channel must have been created first. |
| 436 DCHECK(channel) << context_.get()->channel_id_; | 436 DCHECK(channel) << context_.get()->channel_id_; |
| 437 return channel->TakeClientFileDescriptor(); | 437 return channel->TakeClientFileDescriptor(); |
| 438 } | 438 } |
| 439 #endif | 439 #endif |
| 440 | 440 |
| 441 //----------------------------------------------------------------------------- | 441 //----------------------------------------------------------------------------- |
| 442 | 442 |
| 443 } // namespace IPC | 443 } // namespace IPC |
| OLD | NEW |