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 #include "mojo/edk/system/endpoint_relayer.h" | 5 #include "mojo/edk/system/endpoint_relayer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/edk/system/channel_endpoint.h" | 10 #include "mojo/edk/system/channel_endpoint.h" |
11 #include "mojo/edk/system/message_in_transit.h" | 11 #include "mojo/edk/system/message_in_transit.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace system { | 14 namespace system { |
15 | 15 |
16 EndpointRelayer::EndpointRelayer() { | |
17 } | |
18 | |
19 // static | 16 // static |
20 unsigned EndpointRelayer::GetPeerPort(unsigned port) { | 17 unsigned EndpointRelayer::GetPeerPort(unsigned port) { |
21 DCHECK(port == 0 || port == 1); | 18 DCHECK(port == 0 || port == 1); |
22 return port ^ 1; | 19 return port ^ 1; |
23 } | 20 } |
24 | 21 |
25 void EndpointRelayer::Init(RefPtr<ChannelEndpoint>&& endpoint0, | 22 void EndpointRelayer::Init(RefPtr<ChannelEndpoint>&& endpoint0, |
26 RefPtr<ChannelEndpoint>&& endpoint1) { | 23 RefPtr<ChannelEndpoint>&& endpoint1) { |
27 DCHECK(endpoint0); | 24 DCHECK(endpoint0); |
28 DCHECK(endpoint1); | 25 DCHECK(endpoint1); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 endpoints_[port] = nullptr; | 67 endpoints_[port] = nullptr; |
71 } | 68 } |
72 | 69 |
73 unsigned peer_port = GetPeerPort(port); | 70 unsigned peer_port = GetPeerPort(port); |
74 if (endpoints_[peer_port]) { | 71 if (endpoints_[peer_port]) { |
75 endpoints_[peer_port]->DetachFromClient(); | 72 endpoints_[peer_port]->DetachFromClient(); |
76 endpoints_[peer_port] = nullptr; | 73 endpoints_[peer_port] = nullptr; |
77 } | 74 } |
78 } | 75 } |
79 | 76 |
| 77 EndpointRelayer::EndpointRelayer() {} |
| 78 |
80 EndpointRelayer::~EndpointRelayer() { | 79 EndpointRelayer::~EndpointRelayer() { |
81 DCHECK(!endpoints_[0]); | 80 DCHECK(!endpoints_[0]); |
82 DCHECK(!endpoints_[1]); | 81 DCHECK(!endpoints_[1]); |
83 } | 82 } |
84 | 83 |
85 } // namespace system | 84 } // namespace system |
86 } // namespace mojo | 85 } // namespace mojo |
OLD | NEW |