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/thread.h" | 8 #include "base/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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 private: | 30 private: |
31 scoped_refptr<ChannelProxy::Context> context_; | 31 scoped_refptr<ChannelProxy::Context> context_; |
32 scoped_ptr<Message> message_; | 32 scoped_ptr<Message> message_; |
33 | 33 |
34 DISALLOW_COPY_AND_ASSIGN(SendTask); | 34 DISALLOW_COPY_AND_ASSIGN(SendTask); |
35 }; | 35 }; |
36 | 36 |
37 //------------------------------------------------------------------------------ | 37 //------------------------------------------------------------------------------ |
38 | 38 |
| 39 ChannelProxy::MessageFilter::~MessageFilter() {} |
| 40 |
| 41 void ChannelProxy::MessageFilter::OnFilterAdded(Channel* channel) {} |
| 42 |
| 43 void ChannelProxy::MessageFilter::OnFilterRemoved() {} |
| 44 |
| 45 void ChannelProxy::MessageFilter::OnChannelConnected(int32 peer_pid) {} |
| 46 |
| 47 void ChannelProxy::MessageFilter::OnChannelError() {} |
| 48 |
| 49 void ChannelProxy::MessageFilter::OnChannelClosing() {} |
| 50 |
| 51 bool ChannelProxy::MessageFilter::OnMessageReceived(const Message& message) { |
| 52 return false; |
| 53 } |
| 54 |
| 55 void ChannelProxy::MessageFilter::OnDestruct() { |
| 56 delete this; |
| 57 } |
| 58 |
| 59 //------------------------------------------------------------------------------ |
| 60 |
39 ChannelProxy::Context::Context(Channel::Listener* listener, | 61 ChannelProxy::Context::Context(Channel::Listener* listener, |
40 MessageFilter* filter, | 62 MessageFilter* filter, |
41 MessageLoop* ipc_message_loop) | 63 MessageLoop* ipc_message_loop) |
42 : listener_message_loop_(MessageLoop::current()), | 64 : listener_message_loop_(MessageLoop::current()), |
43 listener_(listener), | 65 listener_(listener), |
44 ipc_message_loop_(ipc_message_loop), | 66 ipc_message_loop_(ipc_message_loop), |
45 channel_(NULL), | 67 channel_(NULL), |
46 peer_pid_(0), | 68 peer_pid_(0), |
47 channel_connected_called_(false) { | 69 channel_connected_called_(false) { |
48 if (filter) | 70 if (filter) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 Init(channel_id, mode, ipc_thread, true); | 263 Init(channel_id, mode, ipc_thread, true); |
242 } | 264 } |
243 | 265 |
244 ChannelProxy::ChannelProxy(const std::string& channel_id, Channel::Mode mode, | 266 ChannelProxy::ChannelProxy(const std::string& channel_id, Channel::Mode mode, |
245 MessageLoop* ipc_thread, Context* context, | 267 MessageLoop* ipc_thread, Context* context, |
246 bool create_pipe_now) | 268 bool create_pipe_now) |
247 : context_(context) { | 269 : context_(context) { |
248 Init(channel_id, mode, ipc_thread, create_pipe_now); | 270 Init(channel_id, mode, ipc_thread, create_pipe_now); |
249 } | 271 } |
250 | 272 |
| 273 ChannelProxy::~ChannelProxy() { |
| 274 Close(); |
| 275 } |
| 276 |
251 void ChannelProxy::Init(const std::string& channel_id, Channel::Mode mode, | 277 void ChannelProxy::Init(const std::string& channel_id, Channel::Mode mode, |
252 MessageLoop* ipc_thread_loop, bool create_pipe_now) { | 278 MessageLoop* ipc_thread_loop, bool create_pipe_now) { |
253 if (create_pipe_now) { | 279 if (create_pipe_now) { |
254 // Create the channel immediately. This effectively sets up the | 280 // Create the channel immediately. This effectively sets up the |
255 // low-level pipe so that the client can connect. Without creating | 281 // low-level pipe so that the client can connect. Without creating |
256 // the pipe immediately, it is possible for a listener to attempt | 282 // the pipe immediately, it is possible for a listener to attempt |
257 // to connect and get an error since the pipe doesn't exist yet. | 283 // to connect and get an error since the pipe doesn't exist yet. |
258 context_->CreateChannel(channel_id, mode); | 284 context_->CreateChannel(channel_id, mode); |
259 } else { | 285 } else { |
260 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 286 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 int ChannelProxy::GetClientFileDescriptor() const { | 338 int ChannelProxy::GetClientFileDescriptor() const { |
313 Channel *channel = context_.get()->channel_; | 339 Channel *channel = context_.get()->channel_; |
314 DCHECK(channel); // Channel must have been created first. | 340 DCHECK(channel); // Channel must have been created first. |
315 return channel->GetClientFileDescriptor(); | 341 return channel->GetClientFileDescriptor(); |
316 } | 342 } |
317 #endif | 343 #endif |
318 | 344 |
319 //----------------------------------------------------------------------------- | 345 //----------------------------------------------------------------------------- |
320 | 346 |
321 } // namespace IPC | 347 } // namespace IPC |
OLD | NEW |