| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, | 72 void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, |
| 73 const Channel::Mode& mode) { | 73 const Channel::Mode& mode) { |
| 74 DCHECK(channel_.get() == NULL); | 74 DCHECK(channel_.get() == NULL); |
| 75 channel_id_ = handle.name; | 75 channel_id_ = handle.name; |
| 76 channel_.reset(new Channel(handle, mode, this)); | 76 channel_.reset(new Channel(handle, mode, this)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool ChannelProxy::Context::TryFilters(const Message& message) { | 79 bool ChannelProxy::Context::TryFilters(const Message& message) { |
| 80 #ifdef IPC_MESSAGE_LOG_ENABLED | 80 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 81 Logging* logger = Logging::current(); | 81 Logging* logger = Logging::GetInstance(); |
| 82 if (logger->Enabled()) | 82 if (logger->Enabled()) |
| 83 logger->OnPreDispatchMessage(message); | 83 logger->OnPreDispatchMessage(message); |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 for (size_t i = 0; i < filters_.size(); ++i) { | 86 for (size_t i = 0; i < filters_.size(); ++i) { |
| 87 if (filters_[i]->OnMessageReceived(message)) { | 87 if (filters_[i]->OnMessageReceived(message)) { |
| 88 #ifdef IPC_MESSAGE_LOG_ENABLED | 88 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 89 if (logger->Enabled()) | 89 if (logger->Enabled()) |
| 90 logger->OnPostDispatchMessage(message, channel_id_); | 90 logger->OnPostDispatchMessage(message, channel_id_); |
| 91 #endif | 91 #endif |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 | 234 |
| 235 // Called on the listener's thread | 235 // Called on the listener's thread |
| 236 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { | 236 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { |
| 237 if (!listener_) | 237 if (!listener_) |
| 238 return; | 238 return; |
| 239 | 239 |
| 240 OnDispatchConnected(); | 240 OnDispatchConnected(); |
| 241 | 241 |
| 242 #ifdef IPC_MESSAGE_LOG_ENABLED | 242 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 243 Logging* logger = Logging::current(); | 243 Logging* logger = Logging::GetInstance(); |
| 244 if (message.type() == IPC_LOGGING_ID) { | 244 if (message.type() == IPC_LOGGING_ID) { |
| 245 logger->OnReceivedLoggingMessage(message); | 245 logger->OnReceivedLoggingMessage(message); |
| 246 return; | 246 return; |
| 247 } | 247 } |
| 248 | 248 |
| 249 if (logger->Enabled()) | 249 if (logger->Enabled()) |
| 250 logger->OnPreDispatchMessage(message); | 250 logger->OnPreDispatchMessage(message); |
| 251 #endif | 251 #endif |
| 252 | 252 |
| 253 listener_->OnMessageReceived(message); | 253 listener_->OnMessageReceived(message); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 context_->Clear(); | 333 context_->Clear(); |
| 334 | 334 |
| 335 if (context_->ipc_message_loop()) { | 335 if (context_->ipc_message_loop()) { |
| 336 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 336 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 337 context_.get(), &Context::OnChannelClosed)); | 337 context_.get(), &Context::OnChannelClosed)); |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 bool ChannelProxy::Send(Message* message) { | 341 bool ChannelProxy::Send(Message* message) { |
| 342 #ifdef IPC_MESSAGE_LOG_ENABLED | 342 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 343 Logging::current()->OnSendMessage(message, context_->channel_id()); | 343 Logging::GetInstance()->OnSendMessage(message, context_->channel_id()); |
| 344 #endif | 344 #endif |
| 345 | 345 |
| 346 context_->ipc_message_loop()->PostTask(FROM_HERE, | 346 context_->ipc_message_loop()->PostTask(FROM_HERE, |
| 347 new SendTask(context_.get(), message)); | 347 new SendTask(context_.get(), message)); |
| 348 return true; | 348 return true; |
| 349 } | 349 } |
| 350 | 350 |
| 351 void ChannelProxy::AddFilter(MessageFilter* filter) { | 351 void ChannelProxy::AddFilter(MessageFilter* filter) { |
| 352 context_->AddFilter(filter); | 352 context_->AddFilter(filter); |
| 353 } | 353 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 372 Channel *channel = context_.get()->channel_.get(); | 372 Channel *channel = context_.get()->channel_.get(); |
| 373 // Channel must have been created first. | 373 // Channel must have been created first. |
| 374 DCHECK(channel) << context_.get()->channel_id_; | 374 DCHECK(channel) << context_.get()->channel_id_; |
| 375 return channel->GetClientFileDescriptor(); | 375 return channel->GetClientFileDescriptor(); |
| 376 } | 376 } |
| 377 #endif | 377 #endif |
| 378 | 378 |
| 379 //----------------------------------------------------------------------------- | 379 //----------------------------------------------------------------------------- |
| 380 | 380 |
| 381 } // namespace IPC | 381 } // namespace IPC |
| OLD | NEW |