Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Side by Side Diff: mojo/edk/system/proxy_message_pipe_endpoint.h

Issue 1423713009: EDK: Move ref counting classes to mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_handle_dispatcher_unittest.cc ('k') | mojo/edk/system/proxy_message_pipe_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698