OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ipc/ipc_channel_proxy.h" | 5 #include "ipc/ipc_channel_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 bool ChannelProxy::Context::TryFilters(const Message& message) { | 58 bool ChannelProxy::Context::TryFilters(const Message& message) { |
59 DCHECK(message_filter_router_); | 59 DCHECK(message_filter_router_); |
60 #ifdef IPC_MESSAGE_LOG_ENABLED | 60 #ifdef IPC_MESSAGE_LOG_ENABLED |
61 Logging* logger = Logging::GetInstance(); | 61 Logging* logger = Logging::GetInstance(); |
62 if (logger->Enabled()) | 62 if (logger->Enabled()) |
63 logger->OnPreDispatchMessage(message); | 63 logger->OnPreDispatchMessage(message); |
64 #endif | 64 #endif |
65 | 65 |
66 if (message_filter_router_->TryFilters(message)) { | 66 if (message_filter_router_->TryFilters(message)) { |
| 67 if (message.dispatch_error()) { |
| 68 listener_task_runner_->PostTask( |
| 69 FROM_HERE, base::Bind(&Context::OnDispatchBadMessage, this, message)); |
| 70 } |
67 #ifdef IPC_MESSAGE_LOG_ENABLED | 71 #ifdef IPC_MESSAGE_LOG_ENABLED |
68 if (logger->Enabled()) | 72 if (logger->Enabled()) |
69 logger->OnPostDispatchMessage(message, channel_id_); | 73 logger->OnPostDispatchMessage(message, channel_id_); |
70 #endif | 74 #endif |
71 return true; | 75 return true; |
72 } | 76 } |
73 return false; | 77 return false; |
74 } | 78 } |
75 | 79 |
76 // Called on the IPC::Channel thread | 80 // Called on the IPC::Channel thread |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (message.type() == IPC_LOGGING_ID) { | 264 if (message.type() == IPC_LOGGING_ID) { |
261 logger->OnReceivedLoggingMessage(message); | 265 logger->OnReceivedLoggingMessage(message); |
262 return; | 266 return; |
263 } | 267 } |
264 | 268 |
265 if (logger->Enabled()) | 269 if (logger->Enabled()) |
266 logger->OnPreDispatchMessage(message); | 270 logger->OnPreDispatchMessage(message); |
267 #endif | 271 #endif |
268 | 272 |
269 listener_->OnMessageReceived(message); | 273 listener_->OnMessageReceived(message); |
| 274 if (message.dispatch_error()) |
| 275 listener_->OnBadMessageReceived(message); |
270 | 276 |
271 #ifdef IPC_MESSAGE_LOG_ENABLED | 277 #ifdef IPC_MESSAGE_LOG_ENABLED |
272 if (logger->Enabled()) | 278 if (logger->Enabled()) |
273 logger->OnPostDispatchMessage(message, channel_id_); | 279 logger->OnPostDispatchMessage(message, channel_id_); |
274 #endif | 280 #endif |
275 } | 281 } |
276 | 282 |
277 // Called on the listener's thread | 283 // Called on the listener's thread |
278 void ChannelProxy::Context::OnDispatchConnected() { | 284 void ChannelProxy::Context::OnDispatchConnected() { |
279 if (channel_connected_called_) | 285 if (channel_connected_called_) |
280 return; | 286 return; |
281 | 287 |
282 channel_connected_called_ = true; | 288 channel_connected_called_ = true; |
283 if (listener_) | 289 if (listener_) |
284 listener_->OnChannelConnected(peer_pid_); | 290 listener_->OnChannelConnected(peer_pid_); |
285 } | 291 } |
286 | 292 |
287 // Called on the listener's thread | 293 // Called on the listener's thread |
288 void ChannelProxy::Context::OnDispatchError() { | 294 void ChannelProxy::Context::OnDispatchError() { |
289 if (listener_) | 295 if (listener_) |
290 listener_->OnChannelError(); | 296 listener_->OnChannelError(); |
291 } | 297 } |
292 | 298 |
| 299 // Called on the listener's thread |
| 300 void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { |
| 301 if (listener_) |
| 302 listener_->OnBadMessageReceived(message); |
| 303 } |
| 304 |
293 //----------------------------------------------------------------------------- | 305 //----------------------------------------------------------------------------- |
294 | 306 |
295 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, | 307 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, |
296 Channel::Mode mode, | 308 Channel::Mode mode, |
297 Listener* listener, | 309 Listener* listener, |
298 base::SingleThreadTaskRunner* ipc_task_runner) | 310 base::SingleThreadTaskRunner* ipc_task_runner) |
299 : context_(new Context(listener, ipc_task_runner)), | 311 : context_(new Context(listener, ipc_task_runner)), |
300 did_init_(false) { | 312 did_init_(false) { |
301 Init(channel_handle, mode, true); | 313 Init(channel_handle, mode, true); |
302 } | 314 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 Channel* channel = context_.get()->channel_.get(); | 436 Channel* channel = context_.get()->channel_.get(); |
425 // Channel must have been created first. | 437 // Channel must have been created first. |
426 DCHECK(channel) << context_.get()->channel_id_; | 438 DCHECK(channel) << context_.get()->channel_id_; |
427 return channel->GetPeerEuid(peer_euid); | 439 return channel->GetPeerEuid(peer_euid); |
428 } | 440 } |
429 #endif | 441 #endif |
430 | 442 |
431 //----------------------------------------------------------------------------- | 443 //----------------------------------------------------------------------------- |
432 | 444 |
433 } // namespace IPC | 445 } // namespace IPC |
OLD | NEW |