| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 if (logger->Enabled()) | 89 if (logger->Enabled()) |
| 90 logger->OnPostDispatchMessage(message, channel_id_); | 90 logger->OnPostDispatchMessage(message, channel_id_); |
| 91 #endif | 91 #endif |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Called on the IPC::Channel thread | 98 // Called on the IPC::Channel thread |
| 99 void ChannelProxy::Context::OnMessageReceived(const Message& message) { | 99 bool ChannelProxy::Context::OnMessageReceived(const Message& message) { |
| 100 // First give a chance to the filters to process this message. | 100 // First give a chance to the filters to process this message. |
| 101 if (!TryFilters(message)) | 101 if (!TryFilters(message)) |
| 102 OnMessageReceivedNoFilter(message); | 102 OnMessageReceivedNoFilter(message); |
| 103 return true; |
| 103 } | 104 } |
| 104 | 105 |
| 105 // Called on the IPC::Channel thread | 106 // Called on the IPC::Channel thread |
| 106 void ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { | 107 bool ChannelProxy::Context::OnMessageReceivedNoFilter(const Message& message) { |
| 107 // NOTE: This code relies on the listener's message loop not going away while | 108 // NOTE: This code relies on the listener's message loop not going away while |
| 108 // this thread is active. That should be a reasonable assumption, but it | 109 // this thread is active. That should be a reasonable assumption, but it |
| 109 // feels risky. We may want to invent some more indirect way of referring to | 110 // feels risky. We may want to invent some more indirect way of referring to |
| 110 // a MessageLoop if this becomes a problem. | 111 // a MessageLoop if this becomes a problem. |
| 111 listener_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 112 listener_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 112 this, &Context::OnDispatchMessage, message)); | 113 this, &Context::OnDispatchMessage, message)); |
| 114 return true; |
| 113 } | 115 } |
| 114 | 116 |
| 115 // Called on the IPC::Channel thread | 117 // Called on the IPC::Channel thread |
| 116 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { | 118 void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { |
| 117 // Add any pending filters. This avoids a race condition where someone | 119 // Add any pending filters. This avoids a race condition where someone |
| 118 // creates a ChannelProxy, calls AddFilter, and then right after starts the | 120 // creates a ChannelProxy, calls AddFilter, and then right after starts the |
| 119 // peer process. The IO thread could receive a message before the task to add | 121 // peer process. The IO thread could receive a message before the task to add |
| 120 // the filter is run on the IO thread. | 122 // the filter is run on the IO thread. |
| 121 OnAddFilter(); | 123 OnAddFilter(); |
| 122 | 124 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 Channel *channel = context_.get()->channel_.get(); | 374 Channel *channel = context_.get()->channel_.get(); |
| 373 // Channel must have been created first. | 375 // Channel must have been created first. |
| 374 DCHECK(channel) << context_.get()->channel_id_; | 376 DCHECK(channel) << context_.get()->channel_id_; |
| 375 return channel->GetClientFileDescriptor(); | 377 return channel->GetClientFileDescriptor(); |
| 376 } | 378 } |
| 377 #endif | 379 #endif |
| 378 | 380 |
| 379 //----------------------------------------------------------------------------- | 381 //----------------------------------------------------------------------------- |
| 380 | 382 |
| 381 } // namespace IPC | 383 } // namespace IPC |
| OLD | NEW |