1 // Copyright 2013 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 MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_
6 #define MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "mojo/system/message_in_transit_queue.h"
11 #include "mojo/system/message_pipe_endpoint.h"
12 #include "mojo/system/system_impl_export.h"
13 #include "mojo/system/waiter_list.h"
18 class MOJO_SYSTEM_IMPL_EXPORT LocalMessagePipeEndpoint
19 : public MessagePipeEndpoint
{
21 LocalMessagePipeEndpoint();
22 virtual ~LocalMessagePipeEndpoint();
24 // |MessagePipeEndpoint| implementation:
25 virtual Type
GetType() const OVERRIDE
;
26 virtual bool OnPeerClose() OVERRIDE
;
27 virtual void EnqueueMessage(scoped_ptr
<MessageInTransit
> message
) OVERRIDE
;
29 // There's a dispatcher for |LocalMessagePipeEndpoint|s, so we have to
30 // implement/override these:
31 virtual void Close() OVERRIDE
;
32 virtual void CancelAllWaiters() OVERRIDE
;
33 virtual MojoResult
ReadMessage(void* bytes
,
35 DispatcherVector
* dispatchers
,
36 uint32_t* num_dispatchers
,
37 MojoReadMessageFlags flags
) OVERRIDE
;
38 virtual MojoResult
AddWaiter(Waiter
* waiter
,
40 MojoResult wake_result
) OVERRIDE
;
41 virtual void RemoveWaiter(Waiter
* waiter
) OVERRIDE
;
43 // This is only to be used by |ProxyMessagePipeEndpoint|:
44 MessageInTransitQueue
* message_queue() { return &message_queue_
; }
47 MojoWaitFlags
SatisfiedFlags();
48 MojoWaitFlags
SatisfiableFlags();
53 // Queue of incoming messages.
54 MessageInTransitQueue message_queue_
;
55 WaiterList waiter_list_
;
57 DISALLOW_COPY_AND_ASSIGN(LocalMessagePipeEndpoint
);
63 #endif // MOJO_SYSTEM_LOCAL_MESSAGE_PIPE_ENDPOINT_H_