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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // TODO(bauerb): Remove logging once investigation of http://crbug.com/141055 | 304 // TODO(bauerb): Remove logging once investigation of http://crbug.com/141055 |
305 // has finished. | 305 // has finished. |
306 if (!msg->is_reply_error()) { | 306 if (!msg->is_reply_error()) { |
307 bool send_result = deserializers_.back().deserializer-> | 307 bool send_result = deserializers_.back().deserializer-> |
308 SerializeOutputParameters(*msg); | 308 SerializeOutputParameters(*msg); |
309 deserializers_.back().send_result = send_result; | 309 deserializers_.back().send_result = send_result; |
310 LOG_IF(ERROR, !send_result) << "Couldn't deserialize reply message"; | 310 VLOG_IF(1, !send_result) << "Couldn't deserialize reply message"; |
311 } else { | 311 } else { |
312 LOG(ERROR) << "Received error reply"; | 312 VLOG(1) << "Received error reply"; |
313 } | 313 } |
314 deserializers_.back().done_event->Signal(); | 314 deserializers_.back().done_event->Signal(); |
315 | 315 |
316 return true; | 316 return true; |
317 } | 317 } |
318 | 318 |
319 void SyncChannel::SyncContext::Clear() { | 319 void SyncChannel::SyncContext::Clear() { |
320 CancelPendingSends(); | 320 CancelPendingSends(); |
321 received_sync_msgs_->RemoveContext(this); | 321 received_sync_msgs_->RemoveContext(this); |
322 Context::Clear(); | 322 Context::Clear(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 void SyncChannel::SyncContext::OnChannelClosed() { | 357 void SyncChannel::SyncContext::OnChannelClosed() { |
358 CancelPendingSends(); | 358 CancelPendingSends(); |
359 shutdown_watcher_.StopWatching(); | 359 shutdown_watcher_.StopWatching(); |
360 Context::OnChannelClosed(); | 360 Context::OnChannelClosed(); |
361 } | 361 } |
362 | 362 |
363 void SyncChannel::SyncContext::OnSendTimeout(int message_id) { | 363 void SyncChannel::SyncContext::OnSendTimeout(int message_id) { |
364 base::AutoLock auto_lock(deserializers_lock_); | 364 base::AutoLock auto_lock(deserializers_lock_); |
365 PendingSyncMessageQueue::iterator iter; | 365 PendingSyncMessageQueue::iterator iter; |
366 LOG(ERROR) << "Send timeout"; | 366 VLOG(1) << "Send timeout"; |
367 for (iter = deserializers_.begin(); iter != deserializers_.end(); iter++) { | 367 for (iter = deserializers_.begin(); iter != deserializers_.end(); iter++) { |
368 if (iter->id == message_id) { | 368 if (iter->id == message_id) { |
369 iter->done_event->Signal(); | 369 iter->done_event->Signal(); |
370 break; | 370 break; |
371 } | 371 } |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 void SyncChannel::SyncContext::CancelPendingSends() { | 375 void SyncChannel::SyncContext::CancelPendingSends() { |
376 base::AutoLock auto_lock(deserializers_lock_); | 376 base::AutoLock auto_lock(deserializers_lock_); |
377 PendingSyncMessageQueue::iterator iter; | 377 PendingSyncMessageQueue::iterator iter; |
378 LOG(ERROR) << "Canceling pending sends"; | 378 // TODO(bauerb): Remove once http://crbug/141055 is fixed. |
| 379 VLOG(1) << "Canceling pending sends"; |
379 for (iter = deserializers_.begin(); iter != deserializers_.end(); iter++) | 380 for (iter = deserializers_.begin(); iter != deserializers_.end(); iter++) |
380 iter->done_event->Signal(); | 381 iter->done_event->Signal(); |
381 } | 382 } |
382 | 383 |
383 void SyncChannel::SyncContext::OnWaitableEventSignaled(WaitableEvent* event) { | 384 void SyncChannel::SyncContext::OnWaitableEventSignaled(WaitableEvent* event) { |
384 if (event == shutdown_event_) { | 385 if (event == shutdown_event_) { |
385 // Process shut down before we can get a reply to a synchronous message. | 386 // Process shut down before we can get a reply to a synchronous message. |
386 // Cancel pending Send calls, which will end up setting the send done event. | 387 // Cancel pending Send calls, which will end up setting the send done event. |
387 CancelPendingSends(); | 388 CancelPendingSends(); |
388 } else { | 389 } else { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 429 |
429 bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) { | 430 bool SyncChannel::SendWithTimeout(Message* message, int timeout_ms) { |
430 if (!message->is_sync()) { | 431 if (!message->is_sync()) { |
431 ChannelProxy::Send(message); | 432 ChannelProxy::Send(message); |
432 return true; | 433 return true; |
433 } | 434 } |
434 | 435 |
435 // *this* might get deleted in WaitForReply. | 436 // *this* might get deleted in WaitForReply. |
436 scoped_refptr<SyncContext> context(sync_context()); | 437 scoped_refptr<SyncContext> context(sync_context()); |
437 if (context->shutdown_event()->IsSignaled()) { | 438 if (context->shutdown_event()->IsSignaled()) { |
438 LOG(ERROR) << "shutdown event is signaled"; | 439 VLOG(1) << "shutdown event is signaled"; |
439 delete message; | 440 delete message; |
440 return false; | 441 return false; |
441 } | 442 } |
442 | 443 |
443 DCHECK(sync_messages_with_no_timeout_allowed_ || | 444 DCHECK(sync_messages_with_no_timeout_allowed_ || |
444 timeout_ms != base::kNoTimeout); | 445 timeout_ms != base::kNoTimeout); |
445 SyncMessage* sync_msg = static_cast<SyncMessage*>(message); | 446 SyncMessage* sync_msg = static_cast<SyncMessage*>(message); |
446 context->Push(sync_msg); | 447 context->Push(sync_msg); |
447 int message_id = SyncMessage::GetMessageId(*sync_msg); | 448 int message_id = SyncMessage::GetMessageId(*sync_msg); |
448 WaitableEvent* pump_messages_event = sync_msg->pump_messages_event(); | 449 WaitableEvent* pump_messages_event = sync_msg->pump_messages_event(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // Ideally we only want to watch this object when running a nested message | 543 // Ideally we only want to watch this object when running a nested message |
543 // loop. However, we don't know when it exits if there's another nested | 544 // loop. However, we don't know when it exits if there's another nested |
544 // message loop running under it or not, so we wouldn't know whether to | 545 // message loop running under it or not, so we wouldn't know whether to |
545 // stop or keep watching. So we always watch it, and create the event as | 546 // stop or keep watching. So we always watch it, and create the event as |
546 // manual reset since the object watcher might otherwise reset the event | 547 // manual reset since the object watcher might otherwise reset the event |
547 // when we're doing a WaitMany. | 548 // when we're doing a WaitMany. |
548 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 549 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
549 } | 550 } |
550 | 551 |
551 } // namespace IPC | 552 } // namespace IPC |
OLD | NEW |