ash: Extend launcher first button to include leading inset.
[chromium-blink-merge.git] / ipc / ipc_sync_message_filter.h
bloba4c27a269a316b963180afa549064f2519126037
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
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 <set>
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h"
14 #include "ipc/ipc_channel_proxy.h"
15 #include "ipc/ipc_sync_message.h"
17 namespace base {
18 class MessageLoopProxy;
19 class WaitableEvent;
22 namespace IPC {
24 // This MessageFilter allows sending synchronous IPC messages from a thread
25 // other than the listener thread associated with the SyncChannel. It does not
26 // support fancy features that SyncChannel does, such as handling recursion or
27 // receiving messages while waiting for a response. Note that this object can
28 // be used to send simultaneous synchronous messages from different threads.
29 class IPC_EXPORT SyncMessageFilter : public ChannelProxy::MessageFilter,
30 public Message::Sender {
31 public:
32 explicit SyncMessageFilter(base::WaitableEvent* shutdown_event);
34 // Message::Sender implementation.
35 virtual bool Send(Message* message) OVERRIDE;
37 // ChannelProxy::MessageFilter implementation.
38 virtual void OnFilterAdded(Channel* channel) OVERRIDE;
39 virtual void OnChannelError() OVERRIDE;
40 virtual void OnChannelClosing() OVERRIDE;
41 virtual bool OnMessageReceived(const Message& message) OVERRIDE;
43 protected:
44 virtual ~SyncMessageFilter();
46 private:
47 void SendOnIOThread(Message* message);
48 // Signal all the pending sends as done, used in an error condition.
49 void SignalAllEvents();
51 // The channel to which this filter was added.
52 Channel* channel_;
54 // The process's main thread.
55 scoped_refptr<base::MessageLoopProxy> listener_loop_;
57 // The message loop where the Channel lives.
58 scoped_refptr<base::MessageLoopProxy> io_loop_;
60 typedef std::set<PendingSyncMsg*> PendingSyncMessages;
61 PendingSyncMessages pending_sync_messages_;
63 // Locks data members above.
64 base::Lock lock_;
66 base::WaitableEvent* shutdown_event_;
68 DISALLOW_COPY_AND_ASSIGN(SyncMessageFilter);
71 } // namespace IPC
73 #endif // IPC_IPC_SYNC_MESSAGE_FILTER_H_