Close autocomplete popup when IME candidate window is open (on Windows), so they...
[chromium-blink-merge.git] / ipc / ipc_sync_message_filter.h
blobcdaef85785aaf7dadbfff44f8aab6aa342a98afd
1 // Copyright (c) 2011 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.
5 #ifndef IPC_IPC_SYNC_MESSAGE_FILTER_H_
6 #define IPC_IPC_SYNC_MESSAGE_FILTER_H_
7 #pragma once
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
12 #include "ipc/ipc_channel_proxy.h"
13 #include "ipc/ipc_sync_message.h"
14 #include <set>
16 namespace base {
17 class MessageLoopProxy;
18 class WaitableEvent;
21 namespace IPC {
23 class MessageReplyDeserializer;
25 // This MessageFilter allows sending synchronous IPC messages from a thread
26 // other than the listener thread associated with the SyncChannel. It does not
27 // support fancy features that SyncChannel does, such as handling recursion or
28 // receiving messages while waiting for a response. Note that this object can
29 // be used to send simultaneous synchronous messages from different threads.
30 class IPC_EXPORT SyncMessageFilter : public ChannelProxy::MessageFilter,
31 public Message::Sender {
32 public:
33 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event);
34 virtual ~SyncMessageFilter();
36 // Message::Sender implementation.
37 virtual bool Send(Message* message);
39 // ChannelProxy::MessageFilter implementation.
40 virtual void OnFilterAdded(Channel* channel);
41 virtual void OnChannelError();
42 virtual void OnChannelClosing();
43 virtual bool OnMessageReceived(const Message& message);
45 private:
46 void SendOnIOThread(Message* message);
47 // Signal all the pending sends as done, used in an error condition.
48 void SignalAllEvents();
50 // The channel to which this filter was added.
51 Channel* channel_;
53 // The process's main thread.
54 scoped_refptr<base::MessageLoopProxy> listener_loop_;
56 // The message loop where the Channel lives.
57 scoped_refptr<base::MessageLoopProxy> io_loop_;
59 typedef std::set<PendingSyncMsg*> PendingSyncMessages;
60 PendingSyncMessages pending_sync_messages_;
62 // Locks data members above.
63 base::Lock lock_;
65 base::WaitableEvent* shutdown_event_;
67 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter);
70 } // namespace IPC
72 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_