Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3970)

Unified Diff: chrome/common/ipc_sync_channel.cc

Issue 8175: Fix a problem with the SyncChannel rewrite. DispatchReplies needs to be call... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/ipc_sync_channel.cc
===================================================================
--- chrome/common/ipc_sync_channel.cc (revision 3934)
+++ chrome/common/ipc_sync_channel.cc (working copy)
@@ -126,14 +126,6 @@
}
}
- // Called on the IPC thread when the current sync Send() call is unblocked.
- void DidUnblock() {
- if (!received_replies_.empty()) {
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &ReceivedSyncMsgQueue::DispatchReplies));
- }
- }
-
// SyncChannel calls this in its destructor.
void RemoveListener(Channel::Listener* listener) {
AutoLock auto_lock(message_lock_);
@@ -167,14 +159,6 @@
static base::LazyInstance<base::ThreadLocalPointer<ReceivedSyncMsgQueue> >
lazy_tls_ptr_;
- private:
- ReceivedSyncMsgQueue() :
- dispatch_event_(CreateEvent(NULL, TRUE, FALSE, NULL)),
- task_pending_(false),
- listener_message_loop_(MessageLoop::current()),
- listener_count_(0) {
- }
-
// Called on the ipc thread to check if we can unblock any current Send()
// calls based on a queued reply.
void DispatchReplies() {
@@ -188,6 +172,14 @@
}
}
+ private:
+ ReceivedSyncMsgQueue() :
+ dispatch_event_(CreateEvent(NULL, TRUE, FALSE, NULL)),
+ task_pending_(false),
+ listener_message_loop_(MessageLoop::current()),
+ listener_count_(0) {
+ }
+
// Holds information about a queued synchronous message.
struct ReceivedMessage {
ReceivedMessage(Message* m, Channel::Listener* l, const std::wstring& i)
@@ -252,12 +244,25 @@
}
bool SyncChannel::SyncContext::Pop() {
- AutoLock auto_lock(deserializers_lock_);
- PendingSyncMsg msg = deserializers_.back();
- delete msg.deserializer;
- CloseHandle(msg.done_event);
- deserializers_.pop_back();
- return msg.send_result;
+ bool result;
+ {
+ AutoLock auto_lock(deserializers_lock_);
+ PendingSyncMsg msg = deserializers_.back();
+ delete msg.deserializer;
+ CloseHandle(msg.done_event);
+ deserializers_.pop_back();
+ result = msg.send_result;
+ }
+
+ // We got a reply to a synchronous Send() call that's blocking the listener
+ // thread. However, further down the call stack there could be another
+ // blocking Send() call, whose reply we received after we made this last
+ // Send() call. So check if we have any queued replies available that
+ // can now unblock the listener thread.
+ ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
+ received_sync_msgs_.get(), &ReceivedSyncMsgQueue::DispatchReplies));
+
+ return result;
}
HANDLE SyncChannel::SyncContext::GetSendDoneEvent() {
@@ -274,27 +279,18 @@
}
bool SyncChannel::SyncContext::TryToUnblockListener(const Message* msg) {
- {
- AutoLock auto_lock(deserializers_lock_);
- if (deserializers_.empty() ||
- !SyncMessage::IsMessageReplyTo(*msg, deserializers_.back().id)) {
- return false;
- }
+ AutoLock auto_lock(deserializers_lock_);
+ if (deserializers_.empty() ||
+ !SyncMessage::IsMessageReplyTo(*msg, deserializers_.back().id)) {
+ return false;
+ }
- if (!msg->is_reply_error()) {
- deserializers_.back().send_result = deserializers_.back().deserializer->
- SerializeOutputParameters(*msg);
- }
- SetEvent(deserializers_.back().done_event);
+ if (!msg->is_reply_error()) {
+ deserializers_.back().send_result = deserializers_.back().deserializer->
+ SerializeOutputParameters(*msg);
}
+ SetEvent(deserializers_.back().done_event);
- // We got a reply to a synchronous Send() call that's blocking the listener
- // thread. However, further down the call stack there could be another
- // blocking Send() call, whose reply we received after we made this last
- // Send() call. So check if we have any queued replies available that
- // can now unblock the listener thread.
- received_sync_msgs_->DidUnblock();
-
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698