| 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 "ipc/ipc_channel_proxy.h" | 7 #include "ipc/ipc_channel_proxy.h" |
| 8 #include "ipc/ipc_logging.h" | 8 #include "ipc/ipc_logging.h" |
| 9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 delete message; | 187 delete message; |
| 188 OnChannelClosed(); | 188 OnChannelClosed(); |
| 189 return; | 189 return; |
| 190 } | 190 } |
| 191 if (!channel_->Send(message)) | 191 if (!channel_->Send(message)) |
| 192 OnChannelError(); | 192 OnChannelError(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Called on the IPC::Channel thread | 195 // Called on the IPC::Channel thread |
| 196 void ChannelProxy::Context::OnAddFilter() { | 196 void ChannelProxy::Context::OnAddFilter() { |
| 197 std::vector<scoped_refptr<MessageFilter> > filters; | 197 std::vector<scoped_refptr<MessageFilter> > new_filters; |
| 198 { | 198 { |
| 199 base::AutoLock auto_lock(pending_filters_lock_); | 199 base::AutoLock auto_lock(pending_filters_lock_); |
| 200 filters.swap(pending_filters_); | 200 new_filters.swap(pending_filters_); |
| 201 } | 201 } |
| 202 | 202 |
| 203 for (size_t i = 0; i < filters.size(); ++i) { | 203 for (size_t i = 0; i < new_filters.size(); ++i) { |
| 204 filters_.push_back(filters[i]); | 204 filters_.push_back(new_filters[i]); |
| 205 | 205 |
| 206 // If the channel has already been created, then we need to send this | 206 // If the channel has already been created, then we need to send this |
| 207 // message so that the filter gets access to the Channel. | 207 // message so that the filter gets access to the Channel. |
| 208 if (channel_.get()) | 208 if (channel_.get()) |
| 209 filters[i]->OnFilterAdded(channel_.get()); | 209 new_filters[i]->OnFilterAdded(channel_.get()); |
| 210 // Ditto for the peer process id. | 210 // Ditto for if the channel has been connected. |
| 211 if (peer_pid_) | 211 if (peer_pid_) |
| 212 filters[i]->OnChannelConnected(peer_pid_); | 212 new_filters[i]->OnChannelConnected(peer_pid_); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Called on the IPC::Channel thread | 216 // Called on the IPC::Channel thread |
| 217 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { | 217 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { |
| 218 for (size_t i = 0; i < filters_.size(); ++i) { | 218 for (size_t i = 0; i < filters_.size(); ++i) { |
| 219 if (filters_[i].get() == filter) { | 219 if (filters_[i].get() == filter) { |
| 220 filter->OnFilterRemoved(); | 220 filter->OnFilterRemoved(); |
| 221 filters_.erase(filters_.begin() + i); | 221 filters_.erase(filters_.begin() + i); |
| 222 return; | 222 return; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 Channel *channel = context_.get()->channel_.get(); | 388 Channel *channel = context_.get()->channel_.get(); |
| 389 // Channel must have been created first. | 389 // Channel must have been created first. |
| 390 DCHECK(channel) << context_.get()->channel_id_; | 390 DCHECK(channel) << context_.get()->channel_id_; |
| 391 return channel->GetClientEuid(client_euid); | 391 return channel->GetClientEuid(client_euid); |
| 392 } | 392 } |
| 393 #endif | 393 #endif |
| 394 | 394 |
| 395 //----------------------------------------------------------------------------- | 395 //----------------------------------------------------------------------------- |
| 396 | 396 |
| 397 } // namespace IPC | 397 } // namespace IPC |
| OLD | NEW |