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

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

Issue 2171183002: Remove ports that are not used by any channel after timeout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: fix a comment Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Methods to set/get ICE role and tiebreaker values. 146 // Methods to set/get ICE role and tiebreaker values.
147 IceRole GetIceRole() const { return ice_role_; } 147 IceRole GetIceRole() const { return ice_role_; }
148 void SetIceRole(IceRole role) { ice_role_ = role; } 148 void SetIceRole(IceRole role) { ice_role_ = role; }
149 149
150 void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; } 150 void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; }
151 uint64_t IceTiebreaker() const { return tiebreaker_; } 151 uint64_t IceTiebreaker() const { return tiebreaker_; }
152 152
153 virtual bool SharedSocket() const { return shared_socket_; } 153 virtual bool SharedSocket() const { return shared_socket_; }
154 void ResetSharedSocket() { shared_socket_ = false; } 154 void ResetSharedSocket() { shared_socket_ = false; }
155 155
156 virtual void StartBeingUsed();
157 virtual void StopBeingUsed();
pthatcher1 2016/07/27 18:33:15 As we talked in person, would it make sense to jus
honghaiz3 2016/07/28 01:22:49 Done.
158
156 // The thread on which this port performs its I/O. 159 // The thread on which this port performs its I/O.
157 rtc::Thread* thread() { return thread_; } 160 rtc::Thread* thread() { return thread_; }
158 161
159 // The factory used to create the sockets of this port. 162 // The factory used to create the sockets of this port.
160 rtc::PacketSocketFactory* socket_factory() const { return factory_; } 163 rtc::PacketSocketFactory* socket_factory() const { return factory_; }
161 void set_socket_factory(rtc::PacketSocketFactory* factory) { 164 void set_socket_factory(rtc::PacketSocketFactory* factory) {
162 factory_ = factory; 165 factory_ = factory;
163 } 166 }
164 167
165 // For debugging purposes. 168 // For debugging purposes.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Called when the socket is currently able to send. 293 // Called when the socket is currently able to send.
291 void OnReadyToSend(); 294 void OnReadyToSend();
292 295
293 // Called when the Connection discovers a local peer reflexive candidate. 296 // Called when the Connection discovers a local peer reflexive candidate.
294 // Returns the index of the new local candidate. 297 // Returns the index of the new local candidate.
295 size_t AddPrflxCandidate(const Candidate& local); 298 size_t AddPrflxCandidate(const Candidate& local);
296 299
297 int16_t network_cost() const { return network_cost_; } 300 int16_t network_cost() const { return network_cost_; }
298 301
299 protected: 302 protected:
300 enum { 303 enum { MSG_CHECK_DEAD = 0, MSG_FIRST_AVAILABLE };
301 MSG_DEAD = 0,
302 MSG_FIRST_AVAILABLE
303 };
304 304
305 virtual void UpdateNetworkCost(); 305 virtual void UpdateNetworkCost();
306 306
307 void set_type(const std::string& type) { type_ = type; } 307 void set_type(const std::string& type) { type_ = type; }
308 308
309 void AddAddress(const rtc::SocketAddress& address, 309 void AddAddress(const rtc::SocketAddress& address,
310 const rtc::SocketAddress& base_address, 310 const rtc::SocketAddress& base_address,
311 const rtc::SocketAddress& related_address, 311 const rtc::SocketAddress& related_address,
312 const std::string& protocol, 312 const std::string& protocol,
313 const std::string& relay_protocol, 313 const std::string& relay_protocol,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 351
352 // Extra work to be done in subclasses when a connection is destroyed. 352 // Extra work to be done in subclasses when a connection is destroyed.
353 virtual void HandleConnectionDestroyed(Connection* conn) {} 353 virtual void HandleConnectionDestroyed(Connection* conn) {}
354 354
355 private: 355 private:
356 void Construct(); 356 void Construct();
357 // Called when one of our connections deletes itself. 357 // Called when one of our connections deletes itself.
358 void OnConnectionDestroyed(Connection* conn); 358 void OnConnectionDestroyed(Connection* conn);
359 359
360 // Whether this port is dead, and hence, should be destroyed on the controlled 360 // Whether this port is dead, and hence, should be destroyed.
361 // side. 361 bool dead() const;
362 bool dead() const {
363 return ice_role_ == ICEROLE_CONTROLLED && connections_.empty();
364 }
365 362
366 void OnNetworkTypeChanged(const rtc::Network* network); 363 void OnNetworkTypeChanged(const rtc::Network* network);
367 364
368 rtc::Thread* thread_; 365 rtc::Thread* thread_;
369 rtc::PacketSocketFactory* factory_; 366 rtc::PacketSocketFactory* factory_;
370 std::string type_; 367 std::string type_;
371 bool send_retransmit_count_attribute_; 368 bool send_retransmit_count_attribute_;
372 rtc::Network* network_; 369 rtc::Network* network_;
373 rtc::IPAddress ip_; 370 rtc::IPAddress ip_;
374 uint16_t min_port_; 371 uint16_t min_port_;
(...skipping 19 matching lines...) Expand all
394 uint64_t tiebreaker_; 391 uint64_t tiebreaker_;
395 bool shared_socket_; 392 bool shared_socket_;
396 // Information to use when going through a proxy. 393 // Information to use when going through a proxy.
397 std::string user_agent_; 394 std::string user_agent_;
398 rtc::ProxyInfo proxy_; 395 rtc::ProxyInfo proxy_;
399 396
400 // A virtual cost perceived by the user, usually based on the network type 397 // A virtual cost perceived by the user, usually based on the network type
401 // (WiFi. vs. Cellular). It takes precedence over the priority when 398 // (WiFi. vs. Cellular). It takes precedence over the priority when
402 // comparing two connections. 399 // comparing two connections.
403 uint16_t network_cost_; 400 uint16_t network_cost_;
401 // Whether a port is being used by a transport channel. A port should not be
402 // destroyed if it is being used.
403 bool is_used_ = false;
pthatcher1 2016/07/27 18:33:15 Maybe we can just use !pruned_ && !candidates_.emp
honghaiz3 2016/07/28 01:22:49 I think you said better to have state. Removed "is
404 int64_t last_time_all_connections_removed_ = 0;
pthatcher1 2016/07/27 18:33:15 Can you move this "fix" for the timing of deletion
honghaiz3 2016/07/28 01:22:49 Done.
404 405
405 friend class Connection; 406 friend class Connection;
406 }; 407 };
407 408
408 // Represents a communication link between a port on the local client and a 409 // Represents a communication link between a port on the local client and a
409 // port on the remote client. 410 // port on the remote client.
410 class Connection : public CandidatePairInterface, 411 class Connection : public CandidatePairInterface,
411 public rtc::MessageHandler, 412 public rtc::MessageHandler,
412 public sigslot::has_slots<> { 413 public sigslot::has_slots<> {
413 public: 414 public:
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 const rtc::PacketOptions& options) override; 686 const rtc::PacketOptions& options) override;
686 int GetError() override { return error_; } 687 int GetError() override { return error_; }
687 688
688 private: 689 private:
689 int error_ = 0; 690 int error_ = 0;
690 }; 691 };
691 692
692 } // namespace cricket 693 } // namespace cricket
693 694
694 #endif // WEBRTC_P2P_BASE_PORT_H_ 695 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698