OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 #ifndef MOJO_EDK_SYSTEM_INCOMING_ENDPOINT_H_ | |
6 #define MOJO_EDK_SYSTEM_INCOMING_ENDPOINT_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/synchronization/lock.h" | |
11 #include "mojo/edk/system/channel_endpoint_client.h" | |
12 #include "mojo/edk/system/message_in_transit_queue.h" | |
13 #include "mojo/edk/system/system_impl_export.h" | |
14 | |
15 namespace mojo { | |
16 namespace system { | |
17 | |
18 class ChannelEndpoint; | |
19 class MessagePipe; | |
20 | |
21 // This is a simple |ChannelEndpointClient| that only receives messages. It's | |
22 // used for endpoints that are "received" by |Channel|, but not yet turned into | |
23 // |MessagePipe|s. | |
24 class MOJO_SYSTEM_IMPL_EXPORT IncomingEndpoint : public ChannelEndpointClient { | |
25 public: | |
26 IncomingEndpoint(); | |
27 | |
28 // Must be called before any other method. | |
29 scoped_refptr<ChannelEndpoint> Init(); | |
30 | |
31 scoped_refptr<MessagePipe> ConvertToMessagePipe(); | |
32 | |
33 // Must be called before destroying this object if |ConvertToMessagePipe()| | |
34 // wasn't called (but |Init()| was). | |
35 void Close(); | |
36 | |
37 // |ChannelEndpointClient| methods: | |
38 bool OnReadMessage(unsigned port, MessageInTransit* message) override; | |
39 void OnDetachFromChannel(unsigned port) override; | |
40 | |
41 private: | |
42 ~IncomingEndpoint() override; | |
43 | |
44 base::Lock lock_; // Protects the following members. | |
45 scoped_refptr<ChannelEndpoint> endpoint_; | |
46 MessageInTransitQueue message_queue_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(IncomingEndpoint); | |
49 }; | |
50 | |
51 } // namespace system | |
52 } // namespace mojo | |
53 | |
54 #endif // MOJO_EDK_SYSTEM_INCOMING_ENDPOINT_H_ | |
OLD | NEW |