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 "mojo/edk/system/channel_endpoint_client.h" | 10 #include "mojo/edk/system/channel_endpoint_client.h" |
11 #include "mojo/edk/system/mutex.h" | 11 #include "mojo/edk/util/mutex.h" |
12 #include "mojo/edk/util/ref_ptr.h" | 12 #include "mojo/edk/util/ref_ptr.h" |
| 13 #include "mojo/edk/util/thread_annotations.h" |
13 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 namespace system { | 17 namespace system { |
17 | 18 |
18 class ChannelEndpoint; | 19 class ChannelEndpoint; |
19 | 20 |
20 // This is a simple |ChannelEndpointClient| that just relays messages between | 21 // This is a simple |ChannelEndpointClient| that just relays messages between |
21 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). | 22 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). |
22 class EndpointRelayer final : public ChannelEndpointClient { | 23 class EndpointRelayer final : public ChannelEndpointClient { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // |ChannelEndpointClient| methods: | 78 // |ChannelEndpointClient| methods: |
78 bool OnReadMessage(unsigned port, MessageInTransit* message) override; | 79 bool OnReadMessage(unsigned port, MessageInTransit* message) override; |
79 void OnDetachFromChannel(unsigned port) override; | 80 void OnDetachFromChannel(unsigned port) override; |
80 | 81 |
81 private: | 82 private: |
82 FRIEND_MAKE_REF_COUNTED(EndpointRelayer); | 83 FRIEND_MAKE_REF_COUNTED(EndpointRelayer); |
83 | 84 |
84 EndpointRelayer(); | 85 EndpointRelayer(); |
85 ~EndpointRelayer() override; | 86 ~EndpointRelayer() override; |
86 | 87 |
87 Mutex mutex_; | 88 util::Mutex mutex_; |
88 util::RefPtr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); | 89 util::RefPtr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); |
89 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); | 90 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); |
90 | 91 |
91 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer); | 92 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer); |
92 }; | 93 }; |
93 | 94 |
94 } // namespace system | 95 } // namespace system |
95 } // namespace mojo | 96 } // namespace mojo |
96 | 97 |
97 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ | 98 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ |
OLD | NEW |