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_sync_channel.h" | 5 #include "ipc/ipc_sync_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 } | 295 } |
296 | 296 |
297 bool SyncChannel::SyncContext::TryToUnblockListener(const Message* msg) { | 297 bool SyncChannel::SyncContext::TryToUnblockListener(const Message* msg) { |
298 base::AutoLock auto_lock(deserializers_lock_); | 298 base::AutoLock auto_lock(deserializers_lock_); |
299 if (deserializers_.empty() || | 299 if (deserializers_.empty() || |
300 !SyncMessage::IsMessageReplyTo(*msg, deserializers_.back().id)) { | 300 !SyncMessage::IsMessageReplyTo(*msg, deserializers_.back().id)) { |
301 return false; | 301 return false; |
302 } | 302 } |
303 | 303 |
304 if (!msg->is_reply_error()) { | 304 if (!msg->is_reply_error()) { |
305 deserializers_.back().send_result = deserializers_.back().deserializer-> | 305 bool send_result = deserializers_.back().deserializer-> |
306 SerializeOutputParameters(*msg); | 306 SerializeOutputParameters(*msg); |
307 deserializers_.back().send_result = send_result; | |
308 LOG_IF(ERROR, !send_result) << "Couldn't deserialize reply message"; | |
309 } else { | |
310 LOG(ERROR) << "Received error reply"; | |
piman
2012/08/10 17:06:15
I'm afraid this is going to be spammy. There's qui
Bernhard Bauer
2012/08/13 07:39:35
Added a TODO. FWIW, in my (casual) testing this di
| |
307 } | 311 } |
308 deserializers_.back().done_event->Signal(); | 312 deserializers_.back().done_event->Signal(); |
309 | 313 |
310 return true; | 314 return true; |
311 } | 315 } |
312 | 316 |
313 void SyncChannel::SyncContext::Clear() { | 317 void SyncChannel::SyncContext::Clear() { |
314 CancelPendingSends(); | 318 CancelPendingSends(); |
315 received_sync_msgs_->RemoveContext(this); | 319 received_sync_msgs_->RemoveContext(this); |
316 Context::Clear(); | 320 Context::Clear(); |
(...skipping 14 matching lines...) Expand all Loading... | |
331 | 335 |
332 if (msg.should_unblock()) { | 336 if (msg.should_unblock()) { |
333 received_sync_msgs_->QueueMessage(msg, this); | 337 received_sync_msgs_->QueueMessage(msg, this); |
334 return true; | 338 return true; |
335 } | 339 } |
336 | 340 |
337 return Context::OnMessageReceivedNoFilter(msg); | 341 return Context::OnMessageReceivedNoFilter(msg); |
338 } | 342 } |
339 | 343 |
340 void SyncChannel::SyncContext::OnChannelError() { | 344 void SyncChannel::SyncContext::OnChannelError() { |
341 CancelPendingSends(); | 345 CancelPendingSends(); |
piman
2012/08/10 17:06:15
I think this is going to be one of the most common
Bernhard Bauer
2012/08/13 07:39:35
Good catch! Added logging.
| |
342 shutdown_watcher_.StopWatching(); | 346 shutdown_watcher_.StopWatching(); |
343 Context::OnChannelError(); | 347 Context::OnChannelError(); |
344 } | 348 } |
345 | 349 |
346 void SyncChannel::SyncContext::OnChannelOpened() { | 350 void SyncChannel::SyncContext::OnChannelOpened() { |
347 shutdown_watcher_.StartWatching(shutdown_event_, this); | 351 shutdown_watcher_.StartWatching(shutdown_event_, this); |
348 Context::OnChannelOpened(); | 352 Context::OnChannelOpened(); |
349 } | 353 } |
350 | 354 |
351 void SyncChannel::SyncContext::OnChannelClosed() { | 355 void SyncChannel::SyncContext::OnChannelClosed() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 424 |
421 bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) { | 425 bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) { |
422 if (!message->is_sync()) { | 426 if (!message->is_sync()) { |
423 ChannelProxy::Send(message); | 427 ChannelProxy::Send(message); |
424 return true; | 428 return true; |
425 } | 429 } |
426 | 430 |
427 // *this* might get deleted in WaitForReply. | 431 // *this* might get deleted in WaitForReply. |
428 scoped_refptr<SyncContext> context(sync_context()); | 432 scoped_refptr<SyncContext> context(sync_context()); |
429 if (context->shutdown_event()->IsSignaled()) { | 433 if (context->shutdown_event()->IsSignaled()) { |
434 LOG(ERROR) << "shutdown event is signaled"; | |
430 delete message; | 435 delete message; |
431 return false; | 436 return false; |
432 } | 437 } |
433 | 438 |
434 DCHECK(sync_messages_with_no_timeout_allowed_ || | 439 DCHECK(sync_messages_with_no_timeout_allowed_ || |
435 timeout_ms != base::kNoTimeout); | 440 timeout_ms != base::kNoTimeout); |
436 SyncMessage* sync_msg = static_cast<SyncMessage*>(message); | 441 SyncMessage* sync_msg = static_cast<SyncMessage*>(message); |
437 context->Push(sync_msg); | 442 context->Push(sync_msg); |
438 int message_id = SyncMessage::GetMessageId(*sync_msg); | 443 int message_id = SyncMessage::GetMessageId(*sync_msg); |
439 WaitableEvent* pump_messages_event = sync_msg->pump_messages_event(); | 444 WaitableEvent* pump_messages_event = sync_msg->pump_messages_event(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 // Ideally we only want to watch this object when running a nested message | 538 // Ideally we only want to watch this object when running a nested message |
534 // loop. However, we don't know when it exits if there's another nested | 539 // loop. However, we don't know when it exits if there's another nested |
535 // message loop running under it or not, so we wouldn't know whether to | 540 // message loop running under it or not, so we wouldn't know whether to |
536 // stop or keep watching. So we always watch it, and create the event as | 541 // stop or keep watching. So we always watch it, and create the event as |
537 // manual reset since the object watcher might otherwise reset the event | 542 // manual reset since the object watcher might otherwise reset the event |
538 // when we're doing a WaitMany. | 543 // when we're doing a WaitMany. |
539 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 544 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
540 } | 545 } |
541 | 546 |
542 } // namespace IPC | 547 } // namespace IPC |
OLD | NEW |