OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ |
6 #define MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ | 6 #define MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "mojo/edk/system/channel_endpoint_client.h" | 11 #include "mojo/edk/system/channel_endpoint_client.h" |
12 #include "mojo/edk/system/mutex.h" | 12 #include "mojo/edk/system/mutex.h" |
13 #include "mojo/edk/system/system_impl_export.h" | |
14 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
15 | 14 |
16 namespace mojo { | 15 namespace mojo { |
17 namespace system { | 16 namespace system { |
18 | 17 |
19 class ChannelEndpoint; | 18 class ChannelEndpoint; |
20 | 19 |
21 // This is a simple |ChannelEndpointClient| that just relays messages between | 20 // This is a simple |ChannelEndpointClient| that just relays messages between |
22 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). | 21 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). |
23 class MOJO_SYSTEM_IMPL_EXPORT EndpointRelayer final | 22 class EndpointRelayer final : public ChannelEndpointClient { |
24 : public ChannelEndpointClient { | |
25 public: | 23 public: |
26 // A class that can inspect and optionally handle messages of type | 24 // A class that can inspect and optionally handle messages of type |
27 // |Type::ENDPOINT_CLIENT| received from either |ChannelEndpoint|. | 25 // |Type::ENDPOINT_CLIENT| received from either |ChannelEndpoint|. |
28 // | 26 // |
29 // Instances of implementations of this class will be owned by | 27 // Instances of implementations of this class will be owned by |
30 // |EndpointRelayer|s. | 28 // |EndpointRelayer|s. |
31 // | 29 // |
32 // Destructors may not call methods of the |EndpointRelayer| (nor of the | 30 // Destructors may not call methods of the |EndpointRelayer| (nor of the |
33 // |ChannelEndpoint|s). | 31 // |ChannelEndpoint|s). |
34 class MOJO_SYSTEM_IMPL_EXPORT Filter { | 32 class Filter { |
35 public: | 33 public: |
36 virtual ~Filter() {} | 34 virtual ~Filter() {} |
37 | 35 |
38 // Called by |EndpointRelayer::OnReadMessage()| for messages of type | 36 // Called by |EndpointRelayer::OnReadMessage()| for messages of type |
39 // |Type::ENDPOINT_CLIENT|. This is only called by the |EndpointRelayer| if | 37 // |Type::ENDPOINT_CLIENT|. This is only called by the |EndpointRelayer| if |
40 // it is still the client of the sending endpoint. | 38 // it is still the client of the sending endpoint. |
41 // | 39 // |
42 // |endpoint| (which will not be null) is the |ChannelEndpoint| | 40 // |endpoint| (which will not be null) is the |ChannelEndpoint| |
43 // corresponding to |port| (i.e., the endpoint the message was received | 41 // corresponding to |port| (i.e., the endpoint the message was received |
44 // from), whereas |peer_endpoint| (which may be null) is that corresponding | 42 // from), whereas |peer_endpoint| (which may be null) is that corresponding |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 scoped_refptr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); | 85 scoped_refptr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); |
88 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); | 86 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); |
89 | 87 |
90 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer); | 88 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer); |
91 }; | 89 }; |
92 | 90 |
93 } // namespace system | 91 } // namespace system |
94 } // namespace mojo | 92 } // namespace mojo |
95 | 93 |
96 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ | 94 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ |
OLD | NEW |