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

Side by Side Diff: chrome_frame/sync_msg_reply_dispatcher.cc

Issue 218019: Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/sync_msg_reply_dispatcher.h ('k') | chrome_frame/test/ChromeTab_UnitTests.vcproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome_frame/sync_msg_reply_dispatcher.h"
6
7 #include "ipc/ipc_sync_message.h"
8
9 void SyncMessageReplyDispatcher::Push(IPC::SyncMessage* msg, void* callback,
10 void* key) {
11 MessageSent pending(IPC::SyncMessage::GetMessageId(*msg),
12 msg->type(), callback, key);
13 AutoLock lock(message_queue_lock_);
14 message_queue_.push_back(pending);
15 }
16
17 bool SyncMessageReplyDispatcher::HandleMessageType(const IPC::Message& msg,
18 const MessageSent& origin) {
19 return false;
20 }
21
22 bool SyncMessageReplyDispatcher::OnMessageReceived(const IPC::Message& msg) {
23 MessageSent origin;
24 if (!Pop(msg, &origin)) {
25 return false;
26 }
27
28 // No callback e.g. no return values and/or don't care
29 if (origin.callback == NULL)
30 return true;
31
32 return HandleMessageType(msg, origin);
33 }
34
35 void SyncMessageReplyDispatcher::Cancel(void* key) {
36 DCHECK(key != NULL);
37 AutoLock lock(message_queue_lock_);
38 PendingSyncMessageQueue::iterator it;
39 for (it = message_queue_.begin(); it != message_queue_.end(); ++it) {
40 if (it->key == key) {
41 it->key = NULL;
42 }
43 }
44 }
45
46 bool SyncMessageReplyDispatcher::Pop(const IPC::Message& msg, MessageSent* t) {
47 if (!msg.is_reply())
48 return false;
49
50 int id = IPC::SyncMessage::GetMessageId(msg);
51 AutoLock lock(message_queue_lock_);
52 PendingSyncMessageQueue::iterator it;
53 for (it = message_queue_.begin(); it != message_queue_.end(); ++it) {
54 if (it->id == id) {
55 *t = *it;
56 message_queue_.erase(it);
57 return true;
58 }
59 }
60 return false;
61 }
OLDNEW
« no previous file with comments | « chrome_frame/sync_msg_reply_dispatcher.h ('k') | chrome_frame/test/ChromeTab_UnitTests.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698