| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | |
| 11 #include "mojo/edk/system/channel_endpoint_client.h" | 10 #include "mojo/edk/system/channel_endpoint_client.h" |
| 11 #include "mojo/edk/system/mutex.h" |
| 12 #include "mojo/edk/system/system_impl_export.h" | 12 #include "mojo/edk/system/system_impl_export.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace system { | 16 namespace system { |
| 17 | 17 |
| 18 class ChannelEndpoint; | 18 class ChannelEndpoint; |
| 19 | 19 |
| 20 // This is a simple |ChannelEndpointClient| that just relays messages between | 20 // This is a simple |ChannelEndpointClient| that just relays messages between |
| 21 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). | 21 // two |ChannelEndpoint|s (without the overhead of |MessagePipe|). |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // |Type::ENDPOINT_CLIENT| messages (see |Filter| above). | 74 // |Type::ENDPOINT_CLIENT| messages (see |Filter| above). |
| 75 void SetFilter(scoped_ptr<Filter> filter); | 75 void SetFilter(scoped_ptr<Filter> filter); |
| 76 | 76 |
| 77 // |ChannelEndpointClient| methods: | 77 // |ChannelEndpointClient| methods: |
| 78 bool OnReadMessage(unsigned port, MessageInTransit* message) override; | 78 bool OnReadMessage(unsigned port, MessageInTransit* message) override; |
| 79 void OnDetachFromChannel(unsigned port) override; | 79 void OnDetachFromChannel(unsigned port) override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 ~EndpointRelayer() override; | 82 ~EndpointRelayer() override; |
| 83 | 83 |
| 84 // TODO(vtl): We could probably get away without the lock if we had a | 84 Mutex mutex_; |
| 85 // thread-safe |scoped_refptr|. | 85 scoped_refptr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); |
| 86 base::Lock lock_; // Protects the following members. | 86 scoped_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); |
| 87 scoped_refptr<ChannelEndpoint> endpoints_[2]; | |
| 88 scoped_ptr<Filter> filter_; | |
| 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 |