| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 438 |
| 439 ChannelProxy::Send(message); | 439 ChannelProxy::Send(message); |
| 440 | 440 |
| 441 if (timeout_ms != base::kNoTimeout) { | 441 if (timeout_ms != base::kNoTimeout) { |
| 442 // We use the sync message id so that when a message times out, we don't | 442 // We use the sync message id so that when a message times out, we don't |
| 443 // confuse it with another send that is either above/below this Send in | 443 // confuse it with another send that is either above/below this Send in |
| 444 // the call stack. | 444 // the call stack. |
| 445 context->ipc_message_loop()->PostDelayedTask( | 445 context->ipc_message_loop()->PostDelayedTask( |
| 446 FROM_HERE, | 446 FROM_HERE, |
| 447 base::Bind(&SyncContext::OnSendTimeout, context.get(), message_id), | 447 base::Bind(&SyncContext::OnSendTimeout, context.get(), message_id), |
| 448 timeout_ms); | 448 base::TimeDelta::FromMilliseconds(timeout_ms)); |
| 449 } | 449 } |
| 450 | 450 |
| 451 // Wait for reply, or for any other incoming synchronous messages. | 451 // Wait for reply, or for any other incoming synchronous messages. |
| 452 // *this* might get deleted, so only call static functions at this point. | 452 // *this* might get deleted, so only call static functions at this point. |
| 453 WaitForReply(context, pump_messages_event); | 453 WaitForReply(context, pump_messages_event); |
| 454 | 454 |
| 455 return context->Pop(); | 455 return context->Pop(); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void SyncChannel::WaitForReply( | 458 void SyncChannel::WaitForReply( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 // Ideally we only want to watch this object when running a nested message | 531 // Ideally we only want to watch this object when running a nested message |
| 532 // loop. However, we don't know when it exits if there's another nested | 532 // loop. However, we don't know when it exits if there's another nested |
| 533 // message loop running under it or not, so we wouldn't know whether to | 533 // message loop running under it or not, so we wouldn't know whether to |
| 534 // stop or keep watching. So we always watch it, and create the event as | 534 // stop or keep watching. So we always watch it, and create the event as |
| 535 // manual reset since the object watcher might otherwise reset the event | 535 // manual reset since the object watcher might otherwise reset the event |
| 536 // when we're doing a WaitMany. | 536 // when we're doing a WaitMany. |
| 537 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); | 537 dispatch_watcher_.StartWatching(sync_context()->GetDispatchEvent(), this); |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace IPC | 540 } // namespace IPC |
| OLD | NEW |