| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| 6 #define MOJO_EDK_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 6 #define MOJO_EDK_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| 7 | 7 |
| 8 #include "mojo/edk/system/message_in_transit.h" | 8 #include "mojo/edk/system/message_in_transit.h" |
| 9 #include "mojo/edk/system/message_pipe_endpoint.h" | 9 #include "mojo/edk/system/message_pipe_endpoint.h" |
| 10 #include "mojo/edk/system/ref_ptr.h" | 10 #include "mojo/edk/util/ref_ptr.h" |
| 11 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 namespace system { | 14 namespace system { |
| 15 | 15 |
| 16 class ChannelEndpoint; | 16 class ChannelEndpoint; |
| 17 class LocalMessagePipeEndpoint; | 17 class LocalMessagePipeEndpoint; |
| 18 class MessagePipe; | 18 class MessagePipe; |
| 19 | 19 |
| 20 // A |ProxyMessagePipeEndpoint| is an endpoint which delegates everything to a | 20 // A |ProxyMessagePipeEndpoint| is an endpoint which delegates everything to a |
| 21 // |ChannelEndpoint|, which may be co-owned by a |Channel|. Like any | 21 // |ChannelEndpoint|, which may be co-owned by a |Channel|. Like any |
| 22 // |MessagePipeEndpoint|, a |ProxyMessagePipeEndpoint| is owned by a | 22 // |MessagePipeEndpoint|, a |ProxyMessagePipeEndpoint| is owned by a |
| 23 // |MessagePipe|. | 23 // |MessagePipe|. |
| 24 // | 24 // |
| 25 // For example, a |MessagePipe| with one endpoint local and the other endpoint | 25 // For example, a |MessagePipe| with one endpoint local and the other endpoint |
| 26 // remote consists of a |LocalMessagePipeEndpoint| and a | 26 // remote consists of a |LocalMessagePipeEndpoint| and a |
| 27 // |ProxyMessagePipeEndpoint|, with only the local endpoint being accessible via | 27 // |ProxyMessagePipeEndpoint|, with only the local endpoint being accessible via |
| 28 // a |MessagePipeDispatcher|. | 28 // a |MessagePipeDispatcher|. |
| 29 class ProxyMessagePipeEndpoint final : public MessagePipeEndpoint { | 29 class ProxyMessagePipeEndpoint final : public MessagePipeEndpoint { |
| 30 public: | 30 public: |
| 31 explicit ProxyMessagePipeEndpoint(RefPtr<ChannelEndpoint>&& channel_endpoint); | 31 explicit ProxyMessagePipeEndpoint( |
| 32 util::RefPtr<ChannelEndpoint>&& channel_endpoint); |
| 32 ~ProxyMessagePipeEndpoint() override; | 33 ~ProxyMessagePipeEndpoint() override; |
| 33 | 34 |
| 34 // Returns |channel_endpoint_| and resets |channel_endpoint_| to null. This | 35 // Returns |channel_endpoint_| and resets |channel_endpoint_| to null. This |
| 35 // may be called at most once, after which |Close()| need not be called. | 36 // may be called at most once, after which |Close()| need not be called. |
| 36 // | 37 // |
| 37 // Note: The returned |ChannelEndpoint| must have its client changed while | 38 // Note: The returned |ChannelEndpoint| must have its client changed while |
| 38 // still under |MessagePipe|'s lock (which this must have also been called | 39 // still under |MessagePipe|'s lock (which this must have also been called |
| 39 // under). | 40 // under). |
| 40 RefPtr<ChannelEndpoint> ReleaseChannelEndpoint(); | 41 util::RefPtr<ChannelEndpoint> ReleaseChannelEndpoint(); |
| 41 | 42 |
| 42 // |MessagePipeEndpoint| implementation: | 43 // |MessagePipeEndpoint| implementation: |
| 43 Type GetType() const override; | 44 Type GetType() const override; |
| 44 bool OnPeerClose() override; | 45 bool OnPeerClose() override; |
| 45 void EnqueueMessage(std::unique_ptr<MessageInTransit> message) override; | 46 void EnqueueMessage(std::unique_ptr<MessageInTransit> message) override; |
| 46 void Close() override; | 47 void Close() override; |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 void DetachIfNecessary(); | 50 void DetachIfNecessary(); |
| 50 | 51 |
| 51 RefPtr<ChannelEndpoint> channel_endpoint_; | 52 util::RefPtr<ChannelEndpoint> channel_endpoint_; |
| 52 | 53 |
| 53 MOJO_DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); | 54 MOJO_DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 } // namespace system | 57 } // namespace system |
| 57 } // namespace mojo | 58 } // namespace mojo |
| 58 | 59 |
| 59 #endif // MOJO_EDK_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ | 60 #endif // MOJO_EDK_SYSTEM_PROXY_MESSAGE_PIPE_ENDPOINT_H_ |
| OLD | NEW |