OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/ref_counted.h" | 6 #include "base/ref_counted.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" |
10 #include "ipc/ipc_logging.h" | 10 #include "ipc/ipc_logging.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return; | 188 return; |
189 } | 189 } |
190 if (!channel_->Send(message)) | 190 if (!channel_->Send(message)) |
191 OnChannelError(); | 191 OnChannelError(); |
192 } | 192 } |
193 | 193 |
194 // Called on the IPC::Channel thread | 194 // Called on the IPC::Channel thread |
195 void ChannelProxy::Context::OnAddFilter() { | 195 void ChannelProxy::Context::OnAddFilter() { |
196 std::vector<scoped_refptr<MessageFilter> > filters; | 196 std::vector<scoped_refptr<MessageFilter> > filters; |
197 { | 197 { |
198 AutoLock auto_lock(pending_filters_lock_); | 198 base::AutoLock auto_lock(pending_filters_lock_); |
199 filters.swap(pending_filters_); | 199 filters.swap(pending_filters_); |
200 } | 200 } |
201 | 201 |
202 for (size_t i = 0; i < filters.size(); ++i) { | 202 for (size_t i = 0; i < filters.size(); ++i) { |
203 filters_.push_back(filters[i]); | 203 filters_.push_back(filters[i]); |
204 | 204 |
205 // If the channel has already been created, then we need to send this | 205 // If the channel has already been created, then we need to send this |
206 // message so that the filter gets access to the Channel. | 206 // message so that the filter gets access to the Channel. |
207 if (channel_.get()) | 207 if (channel_.get()) |
208 filters[i]->OnFilterAdded(channel_.get()); | 208 filters[i]->OnFilterAdded(channel_.get()); |
(...skipping 11 matching lines...) Expand all Loading... |
220 filters_.erase(filters_.begin() + i); | 220 filters_.erase(filters_.begin() + i); |
221 return; | 221 return; |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 NOTREACHED() << "filter to be removed not found"; | 225 NOTREACHED() << "filter to be removed not found"; |
226 } | 226 } |
227 | 227 |
228 // Called on the listener's thread | 228 // Called on the listener's thread |
229 void ChannelProxy::Context::AddFilter(MessageFilter* filter) { | 229 void ChannelProxy::Context::AddFilter(MessageFilter* filter) { |
230 AutoLock auto_lock(pending_filters_lock_); | 230 base::AutoLock auto_lock(pending_filters_lock_); |
231 pending_filters_.push_back(make_scoped_refptr(filter)); | 231 pending_filters_.push_back(make_scoped_refptr(filter)); |
232 ipc_message_loop_->PostTask( | 232 ipc_message_loop_->PostTask( |
233 FROM_HERE, | 233 FROM_HERE, |
234 NewRunnableMethod(this, &Context::OnAddFilter)); | 234 NewRunnableMethod(this, &Context::OnAddFilter)); |
235 } | 235 } |
236 | 236 |
237 // Called on the listener's thread | 237 // Called on the listener's thread |
238 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { | 238 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { |
239 if (!listener_) | 239 if (!listener_) |
240 return; | 240 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 Channel *channel = context_.get()->channel_.get(); | 374 Channel *channel = context_.get()->channel_.get(); |
375 // Channel must have been created first. | 375 // Channel must have been created first. |
376 DCHECK(channel) << context_.get()->channel_id_; | 376 DCHECK(channel) << context_.get()->channel_id_; |
377 return channel->GetClientFileDescriptor(); | 377 return channel->GetClientFileDescriptor(); |
378 } | 378 } |
379 #endif | 379 #endif |
380 | 380 |
381 //----------------------------------------------------------------------------- | 381 //----------------------------------------------------------------------------- |
382 | 382 |
383 } // namespace IPC | 383 } // namespace IPC |
OLD | NEW |