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

Side by Side Diff: webrtc/p2p/base/relayserver.cc

Issue 1793553002: Using 64-bit timestamp in webrtc/p2p (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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/relayserver.h ('k') | webrtc/p2p/base/stunport.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 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 RelayServerBinding* binding; 348 RelayServerBinding* binding;
349 349
350 BindingMap::iterator biter = bindings_.find(username); 350 BindingMap::iterator biter = bindings_.find(username);
351 if (biter != bindings_.end()) { 351 if (biter != bindings_.end()) {
352 binding = biter->second; 352 binding = biter->second;
353 } else { 353 } else {
354 // NOTE: In the future, bindings will be created by the bot only. This 354 // NOTE: In the future, bindings will be created by the bot only. This
355 // else-branch will then disappear. 355 // else-branch will then disappear.
356 356
357 // Compute the appropriate lifetime for this binding. 357 // Compute the appropriate lifetime for this binding.
358 uint32_t lifetime = MAX_LIFETIME; 358 int lifetime = MAX_LIFETIME;
359 const StunUInt32Attribute* lifetime_attr = 359 const StunUInt32Attribute* lifetime_attr =
360 request.GetUInt32(STUN_ATTR_LIFETIME); 360 request.GetUInt32(STUN_ATTR_LIFETIME);
361 if (lifetime_attr) 361 if (lifetime_attr)
362 lifetime = std::min(lifetime, lifetime_attr->value() * 1000); 362 lifetime =
363 std::min(lifetime, static_cast<int>(lifetime_attr->value() * 1000));
363 364
364 binding = new RelayServerBinding(this, username, "0", lifetime); 365 binding = new RelayServerBinding(this, username, "0", lifetime);
365 binding->SignalTimeout.connect(this, &RelayServer::OnTimeout); 366 binding->SignalTimeout.connect(this, &RelayServer::OnTimeout);
366 bindings_[username] = binding; 367 bindings_[username] = binding;
367 368
368 if (log_bindings_) { 369 if (log_bindings_) {
369 LOG(LS_INFO) << "Added new binding " << username << ", " 370 LOG(LS_INFO) << "Added new binding " << username << ", "
370 << bindings_.size() << " total"; 371 << bindings_.size() << " total";
371 } 372 }
372 } 373 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 void RelayServerConnection::Unlock() { 647 void RelayServerConnection::Unlock() {
647 locked_ = false; 648 locked_ = false;
648 } 649 }
649 650
650 // IDs used for posted messages: 651 // IDs used for posted messages:
651 const uint32_t MSG_LIFETIME_TIMER = 1; 652 const uint32_t MSG_LIFETIME_TIMER = 1;
652 653
653 RelayServerBinding::RelayServerBinding(RelayServer* server, 654 RelayServerBinding::RelayServerBinding(RelayServer* server,
654 const std::string& username, 655 const std::string& username,
655 const std::string& password, 656 const std::string& password,
656 uint32_t lifetime) 657 int lifetime)
657 : server_(server), 658 : server_(server),
658 username_(username), 659 username_(username),
659 password_(password), 660 password_(password),
660 lifetime_(lifetime) { 661 lifetime_(lifetime) {
661 // For now, every connection uses the standard magic cookie value. 662 // For now, every connection uses the standard magic cookie value.
662 magic_cookie_.append( 663 magic_cookie_.append(
663 reinterpret_cast<const char*>(TURN_MAGIC_COOKIE_VALUE), 664 reinterpret_cast<const char*>(TURN_MAGIC_COOKIE_VALUE),
664 sizeof(TURN_MAGIC_COOKIE_VALUE)); 665 sizeof(TURN_MAGIC_COOKIE_VALUE));
665 666
666 // Initialize the last-used time to now. 667 // Initialize the last-used time to now.
(...skipping 19 matching lines...) Expand all
686 687
687 void RelayServerBinding::AddInternalConnection(RelayServerConnection* conn) { 688 void RelayServerBinding::AddInternalConnection(RelayServerConnection* conn) {
688 internal_connections_.push_back(conn); 689 internal_connections_.push_back(conn);
689 } 690 }
690 691
691 void RelayServerBinding::AddExternalConnection(RelayServerConnection* conn) { 692 void RelayServerBinding::AddExternalConnection(RelayServerConnection* conn) {
692 external_connections_.push_back(conn); 693 external_connections_.push_back(conn);
693 } 694 }
694 695
695 void RelayServerBinding::NoteUsed() { 696 void RelayServerBinding::NoteUsed() {
696 last_used_ = rtc::Time(); 697 last_used_ = rtc::Time64();
697 } 698 }
698 699
699 bool RelayServerBinding::HasMagicCookie(const char* bytes, size_t size) const { 700 bool RelayServerBinding::HasMagicCookie(const char* bytes, size_t size) const {
700 if (size < 24 + magic_cookie_.size()) { 701 if (size < 24 + magic_cookie_.size()) {
701 return false; 702 return false;
702 } else { 703 } else {
703 return memcmp(bytes + 24, magic_cookie_.c_str(), magic_cookie_.size()) == 0; 704 return memcmp(bytes + 24, magic_cookie_.c_str(), magic_cookie_.size()) == 0;
704 } 705 }
705 } 706 }
706 707
(...skipping 20 matching lines...) Expand all
727 } 728 }
728 return 0; 729 return 0;
729 } 730 }
730 731
731 void RelayServerBinding::OnMessage(rtc::Message *pmsg) { 732 void RelayServerBinding::OnMessage(rtc::Message *pmsg) {
732 if (pmsg->message_id == MSG_LIFETIME_TIMER) { 733 if (pmsg->message_id == MSG_LIFETIME_TIMER) {
733 ASSERT(!pmsg->pdata); 734 ASSERT(!pmsg->pdata);
734 735
735 // If the lifetime timeout has been exceeded, then send a signal. 736 // If the lifetime timeout has been exceeded, then send a signal.
736 // Otherwise, just keep waiting. 737 // Otherwise, just keep waiting.
737 if (rtc::Time() >= last_used_ + lifetime_) { 738 if (rtc::Time64() >= last_used_ + lifetime_) {
738 LOG(LS_INFO) << "Expiring binding " << username_; 739 LOG(LS_INFO) << "Expiring binding " << username_;
739 SignalTimeout(this); 740 SignalTimeout(this);
740 } else { 741 } else {
741 server_->thread()->PostDelayed(lifetime_, this, MSG_LIFETIME_TIMER); 742 server_->thread()->PostDelayed(lifetime_, this, MSG_LIFETIME_TIMER);
742 } 743 }
743 744
744 } else { 745 } else {
745 ASSERT(false); 746 ASSERT(false);
746 } 747 }
747 } 748 }
748 749
749 } // namespace cricket 750 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/relayserver.h ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698