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

Side by Side Diff: webrtc/p2p/base/transportcontroller.h

Issue 1380563002: Thinning out the Transport class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing code style and naming. 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 | « webrtc/p2p/base/transport_unittest.cc ('k') | webrtc/p2p/base/transportcontroller.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 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 std::string* err); 74 std::string* err);
75 // Start gathering candidates for any new transports, or transports doing an 75 // Start gathering candidates for any new transports, or transports doing an
76 // ICE restart. 76 // ICE restart.
77 void MaybeStartGathering(); 77 void MaybeStartGathering();
78 bool AddRemoteCandidates(const std::string& transport_name, 78 bool AddRemoteCandidates(const std::string& transport_name,
79 const Candidates& candidates, 79 const Candidates& candidates,
80 std::string* err); 80 std::string* err);
81 bool ReadyForRemoteCandidates(const std::string& transport_name); 81 bool ReadyForRemoteCandidates(const std::string& transport_name);
82 bool GetStats(const std::string& transport_name, TransportStats* stats); 82 bool GetStats(const std::string& transport_name, TransportStats* stats);
83 83
84 // Creates a channel if it doesn't exist. Otherwise, increments a reference
85 // count and returns an existing channel.
84 virtual TransportChannel* CreateTransportChannel_w( 86 virtual TransportChannel* CreateTransportChannel_w(
85 const std::string& transport_name, 87 const std::string& transport_name,
86 int component); 88 int component);
89
90 // Decrements a channel's reference count, and destroys the channel if
91 // nothing is referencing it.
87 virtual void DestroyTransportChannel_w(const std::string& transport_name, 92 virtual void DestroyTransportChannel_w(const std::string& transport_name,
88 int component); 93 int component);
89 94
90 // All of these signals are fired on the signalling thread. 95 // All of these signals are fired on the signalling thread.
91 96
92 // If any transport failed => failed, 97 // If any transport failed => failed,
93 // Else if all completed => completed, 98 // Else if all completed => completed,
94 // Else if all connected => connected, 99 // Else if all connected => connected,
95 // Else => connecting 100 // Else => connecting
96 sigslot::signal1<IceConnectionState> SignalConnectionState; 101 sigslot::signal1<IceConnectionState> SignalConnectionState;
(...skipping 17 matching lines...) Expand all
114 // Protected and virtual so we can override it in unit tests. 119 // Protected and virtual so we can override it in unit tests.
115 virtual Transport* CreateTransport_w(const std::string& transport_name); 120 virtual Transport* CreateTransport_w(const std::string& transport_name);
116 121
117 // For unit tests 122 // For unit tests
118 const std::map<std::string, Transport*>& transports() { return transports_; } 123 const std::map<std::string, Transport*>& transports() { return transports_; }
119 Transport* GetTransport_w(const std::string& transport_name); 124 Transport* GetTransport_w(const std::string& transport_name);
120 125
121 private: 126 private:
122 void OnMessage(rtc::Message* pmsg) override; 127 void OnMessage(rtc::Message* pmsg) override;
123 128
129 // It's the Transport that's currently responsible for creating/destroying
130 // channels, but the TransportController keeps track of how many external
131 // objects (BaseChannels) reference each channel.
132 struct RefCountedChannel {
133 RefCountedChannel() : impl_(nullptr), ref_(0) {}
134 explicit RefCountedChannel(TransportChannelImpl* impl)
135 : impl_(impl), ref_(0) {}
136
137 void AddRef() { ++ref_; }
138 void DecRef() {
139 ASSERT(ref_ > 0);
140 --ref_;
141 }
142 int ref() const { return ref_; }
143
144 TransportChannelImpl* get() const { return impl_; }
145 TransportChannelImpl* operator->() const { return impl_; }
146
147 private:
148 TransportChannelImpl* impl_;
149 int ref_;
150 };
151
152 std::vector<RefCountedChannel>::iterator FindChannel_w(
153 const std::string& transport_name,
154 int component);
155
124 Transport* GetOrCreateTransport_w(const std::string& transport_name); 156 Transport* GetOrCreateTransport_w(const std::string& transport_name);
125 void DestroyTransport_w(const std::string& transport_name); 157 void DestroyTransport_w(const std::string& transport_name);
126 void DestroyAllTransports_w(); 158 void DestroyAllTransports_w();
127 159
128 bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version); 160 bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version);
129 void SetIceConfig_w(const IceConfig& config); 161 void SetIceConfig_w(const IceConfig& config);
130 void SetIceRole_w(IceRole ice_role); 162 void SetIceRole_w(IceRole ice_role);
131 bool GetSslRole_w(rtc::SSLRole* role); 163 bool GetSslRole_w(rtc::SSLRole* role);
132 bool SetLocalCertificate_w( 164 bool SetLocalCertificate_w(
133 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); 165 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
(...skipping 11 matching lines...) Expand all
145 ContentAction action, 177 ContentAction action,
146 std::string* err); 178 std::string* err);
147 void MaybeStartGathering_w(); 179 void MaybeStartGathering_w();
148 bool AddRemoteCandidates_w(const std::string& transport_name, 180 bool AddRemoteCandidates_w(const std::string& transport_name,
149 const Candidates& candidates, 181 const Candidates& candidates,
150 std::string* err); 182 std::string* err);
151 bool ReadyForRemoteCandidates_w(const std::string& transport_name); 183 bool ReadyForRemoteCandidates_w(const std::string& transport_name);
152 bool GetStats_w(const std::string& transport_name, TransportStats* stats); 184 bool GetStats_w(const std::string& transport_name, TransportStats* stats);
153 185
154 // Handlers for signals from Transport. 186 // Handlers for signals from Transport.
155 void OnTransportConnecting_w(Transport* transport); 187 void OnChannelWritableState_w(TransportChannel* channel);
156 void OnTransportWritableState_w(Transport* transport); 188 void OnChannelReceivingState_w(TransportChannel* channel);
157 void OnTransportReceivingState_w(Transport* transport); 189 void OnChannelGatheringState_w(TransportChannelImpl* channel);
158 void OnTransportCompleted_w(Transport* transport); 190 void OnChannelCandidateGathered_w(TransportChannelImpl* channel,
159 void OnTransportFailed_w(Transport* transport); 191 const Candidate& candidate);
160 void OnTransportGatheringState_w(Transport* transport); 192 void OnChannelRoleConflict_w(TransportChannelImpl* channel);
161 void OnTransportCandidatesGathered_w( 193 void OnChannelConnectionRemoved_w(TransportChannelImpl* channel);
162 Transport* transport,
163 const std::vector<Candidate>& candidates);
164 void OnTransportRoleConflict_w();
165 194
166 void UpdateAggregateStates_w(); 195 void UpdateAggregateStates_w();
167 bool HasChannels_w();
168 196
169 rtc::Thread* const signaling_thread_ = nullptr; 197 rtc::Thread* const signaling_thread_ = nullptr;
170 rtc::Thread* const worker_thread_ = nullptr; 198 rtc::Thread* const worker_thread_ = nullptr;
171 typedef std::map<std::string, Transport*> TransportMap; 199 typedef std::map<std::string, Transport*> TransportMap;
172 TransportMap transports_; 200 TransportMap transports_;
173 201
202 std::vector<RefCountedChannel> channels_;
203
174 PortAllocator* const port_allocator_ = nullptr; 204 PortAllocator* const port_allocator_ = nullptr;
175 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10; 205 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10;
176 206
177 // Aggregate state for Transports 207 // Aggregate state for TransportChannelImpls.
178 IceConnectionState connection_state_ = kIceConnectionConnecting; 208 IceConnectionState connection_state_ = kIceConnectionConnecting;
179 bool receiving_ = false; 209 bool receiving_ = false;
180 IceGatheringState gathering_state_ = kIceGatheringNew; 210 IceGatheringState gathering_state_ = kIceGatheringNew;
181 211
182 // TODO(deadbeef): Move the fields below down to the transports themselves 212 // TODO(deadbeef): Move the fields below down to the transports themselves
183 IceConfig ice_config_; 213 IceConfig ice_config_;
184 IceRole ice_role_ = ICEROLE_CONTROLLING; 214 IceRole ice_role_ = ICEROLE_CONTROLLING;
185 // Flag which will be set to true after the first role switch 215 // Flag which will be set to true after the first role switch
186 bool ice_role_switch_ = false; 216 bool ice_role_switch_ = false;
187 uint64 ice_tiebreaker_ = rtc::CreateRandomId64(); 217 uint64 ice_tiebreaker_ = rtc::CreateRandomId64();
188 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 218 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
189 }; 219 };
190 220
191 } // namespace cricket 221 } // namespace cricket
192 222
193 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_ 223 #endif // WEBRTC_P2P_BASE_TRANSPORTCONTROLLER_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transport_unittest.cc ('k') | webrtc/p2p/base/transportcontroller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698