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

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

Issue 1396783004: Convert mojo::system::ChannelEndpointClient to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « mojo/edk/system/dispatcher_unittest.cc ('k') | mojo/edk/system/endpoint_relayer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "mojo/edk/system/channel_endpoint_client.h" 10 #include "mojo/edk/system/channel_endpoint_client.h"
12 #include "mojo/edk/system/mutex.h" 11 #include "mojo/edk/system/mutex.h"
13 #include "mojo/edk/system/ref_ptr.h" 12 #include "mojo/edk/system/ref_ptr.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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ChannelEndpoint* peer_endpoint, 54 ChannelEndpoint* peer_endpoint,
56 MessageInTransit* message) = 0; 55 MessageInTransit* message) = 0;
57 56
58 protected: 57 protected:
59 Filter() {} 58 Filter() {}
60 59
61 private: 60 private:
62 MOJO_DISALLOW_COPY_AND_ASSIGN(Filter); 61 MOJO_DISALLOW_COPY_AND_ASSIGN(Filter);
63 }; 62 };
64 63
65 EndpointRelayer(); 64 // Note: Use |MakeRefCounted<EndpointRelayer>()|.
66 65
67 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). 66 // Gets the other port number (i.e., 0 -> 1, 1 -> 0).
68 static unsigned GetPeerPort(unsigned port); 67 static unsigned GetPeerPort(unsigned port);
69 68
70 // Initialize this object. This must be called before any other method. 69 // Initialize this object. This must be called before any other method.
71 void Init(RefPtr<ChannelEndpoint>&& endpoint0, 70 void Init(RefPtr<ChannelEndpoint>&& endpoint0,
72 RefPtr<ChannelEndpoint>&& endpoint1) MOJO_NOT_THREAD_SAFE; 71 RefPtr<ChannelEndpoint>&& endpoint1) MOJO_NOT_THREAD_SAFE;
73 72
74 // Sets (or resets) the filter, which can (optionally) handle/filter 73 // Sets (or resets) the filter, which can (optionally) handle/filter
75 // |Type::ENDPOINT_CLIENT| messages (see |Filter| above). 74 // |Type::ENDPOINT_CLIENT| messages (see |Filter| above).
76 void SetFilter(std::unique_ptr<Filter> filter); 75 void SetFilter(std::unique_ptr<Filter> filter);
77 76
78 // |ChannelEndpointClient| methods: 77 // |ChannelEndpointClient| methods:
79 bool OnReadMessage(unsigned port, MessageInTransit* message) override; 78 bool OnReadMessage(unsigned port, MessageInTransit* message) override;
80 void OnDetachFromChannel(unsigned port) override; 79 void OnDetachFromChannel(unsigned port) override;
81 80
82 private: 81 private:
82 FRIEND_MAKE_REF_COUNTED(EndpointRelayer);
83
84 EndpointRelayer();
83 ~EndpointRelayer() override; 85 ~EndpointRelayer() override;
84 86
85 Mutex mutex_; 87 Mutex mutex_;
86 RefPtr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); 88 RefPtr<ChannelEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_);
87 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_); 89 std::unique_ptr<Filter> filter_ MOJO_GUARDED_BY(mutex_);
88 90
89 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer); 91 MOJO_DISALLOW_COPY_AND_ASSIGN(EndpointRelayer);
90 }; 92 };
91 93
92 } // namespace system 94 } // namespace system
93 } // namespace mojo 95 } // namespace mojo
94 96
95 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_ 97 #endif // MOJO_EDK_SYSTEM_ENDPOINT_RELAYER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher_unittest.cc ('k') | mojo/edk/system/endpoint_relayer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698