| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 ASSERT(username_attr != NULL); | 624 ASSERT(username_attr != NULL); |
| 625 username_ = username_attr->GetString(); | 625 username_ = username_attr->GetString(); |
| 626 const StunByteStringAttribute* origin_attr = | 626 const StunByteStringAttribute* origin_attr = |
| 627 msg->GetByteString(STUN_ATTR_ORIGIN); | 627 msg->GetByteString(STUN_ATTR_ORIGIN); |
| 628 if (origin_attr) { | 628 if (origin_attr) { |
| 629 origin_ = origin_attr->GetString(); | 629 origin_ = origin_attr->GetString(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Figure out the lifetime and start the allocation timer. | 632 // Figure out the lifetime and start the allocation timer. |
| 633 int lifetime_secs = ComputeLifetime(msg); | 633 int lifetime_secs = ComputeLifetime(msg); |
| 634 thread_->PostDelayed(lifetime_secs * 1000, this, MSG_ALLOCATION_TIMEOUT); | 634 thread_->PostDelayed(RTC_FROM_HERE, lifetime_secs * 1000, this, |
| 635 MSG_ALLOCATION_TIMEOUT); |
| 635 | 636 |
| 636 LOG_J(LS_INFO, this) << "Created allocation, lifetime=" << lifetime_secs; | 637 LOG_J(LS_INFO, this) << "Created allocation, lifetime=" << lifetime_secs; |
| 637 | 638 |
| 638 // We've already validated all the important bits; just send a response here. | 639 // We've already validated all the important bits; just send a response here. |
| 639 TurnMessage response; | 640 TurnMessage response; |
| 640 InitResponse(msg, &response); | 641 InitResponse(msg, &response); |
| 641 | 642 |
| 642 StunAddressAttribute* mapped_addr_attr = | 643 StunAddressAttribute* mapped_addr_attr = |
| 643 new StunXorAddressAttribute(STUN_ATTR_XOR_MAPPED_ADDRESS, conn_.src()); | 644 new StunXorAddressAttribute(STUN_ATTR_XOR_MAPPED_ADDRESS, conn_.src()); |
| 644 StunAddressAttribute* relayed_addr_attr = | 645 StunAddressAttribute* relayed_addr_attr = |
| 645 new StunXorAddressAttribute(STUN_ATTR_XOR_RELAYED_ADDRESS, | 646 new StunXorAddressAttribute(STUN_ATTR_XOR_RELAYED_ADDRESS, |
| 646 external_socket_->GetLocalAddress()); | 647 external_socket_->GetLocalAddress()); |
| 647 StunUInt32Attribute* lifetime_attr = | 648 StunUInt32Attribute* lifetime_attr = |
| 648 new StunUInt32Attribute(STUN_ATTR_LIFETIME, lifetime_secs); | 649 new StunUInt32Attribute(STUN_ATTR_LIFETIME, lifetime_secs); |
| 649 VERIFY(response.AddAttribute(mapped_addr_attr)); | 650 VERIFY(response.AddAttribute(mapped_addr_attr)); |
| 650 VERIFY(response.AddAttribute(relayed_addr_attr)); | 651 VERIFY(response.AddAttribute(relayed_addr_attr)); |
| 651 VERIFY(response.AddAttribute(lifetime_attr)); | 652 VERIFY(response.AddAttribute(lifetime_attr)); |
| 652 | 653 |
| 653 SendResponse(&response); | 654 SendResponse(&response); |
| 654 } | 655 } |
| 655 | 656 |
| 656 void TurnServerAllocation::HandleRefreshRequest(const TurnMessage* msg) { | 657 void TurnServerAllocation::HandleRefreshRequest(const TurnMessage* msg) { |
| 657 // Figure out the new lifetime. | 658 // Figure out the new lifetime. |
| 658 int lifetime_secs = ComputeLifetime(msg); | 659 int lifetime_secs = ComputeLifetime(msg); |
| 659 | 660 |
| 660 // Reset the expiration timer. | 661 // Reset the expiration timer. |
| 661 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); | 662 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); |
| 662 thread_->PostDelayed(lifetime_secs * 1000, this, MSG_ALLOCATION_TIMEOUT); | 663 thread_->PostDelayed(RTC_FROM_HERE, lifetime_secs * 1000, this, |
| 664 MSG_ALLOCATION_TIMEOUT); |
| 663 | 665 |
| 664 LOG_J(LS_INFO, this) << "Refreshed allocation, lifetime=" << lifetime_secs; | 666 LOG_J(LS_INFO, this) << "Refreshed allocation, lifetime=" << lifetime_secs; |
| 665 | 667 |
| 666 // Send a success response with a LIFETIME attribute. | 668 // Send a success response with a LIFETIME attribute. |
| 667 TurnMessage response; | 669 TurnMessage response; |
| 668 InitResponse(msg, &response); | 670 InitResponse(msg, &response); |
| 669 | 671 |
| 670 StunUInt32Attribute* lifetime_attr = | 672 StunUInt32Attribute* lifetime_attr = |
| 671 new StunUInt32Attribute(STUN_ATTR_LIFETIME, lifetime_secs); | 673 new StunUInt32Attribute(STUN_ATTR_LIFETIME, lifetime_secs); |
| 672 VERIFY(response.AddAttribute(lifetime_attr)); | 674 VERIFY(response.AddAttribute(lifetime_attr)); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 : thread_(thread), peer_(peer) { | 919 : thread_(thread), peer_(peer) { |
| 918 Refresh(); | 920 Refresh(); |
| 919 } | 921 } |
| 920 | 922 |
| 921 TurnServerAllocation::Permission::~Permission() { | 923 TurnServerAllocation::Permission::~Permission() { |
| 922 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); | 924 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); |
| 923 } | 925 } |
| 924 | 926 |
| 925 void TurnServerAllocation::Permission::Refresh() { | 927 void TurnServerAllocation::Permission::Refresh() { |
| 926 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); | 928 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); |
| 927 thread_->PostDelayed(kPermissionTimeout, this, MSG_ALLOCATION_TIMEOUT); | 929 thread_->PostDelayed(RTC_FROM_HERE, kPermissionTimeout, this, |
| 930 MSG_ALLOCATION_TIMEOUT); |
| 928 } | 931 } |
| 929 | 932 |
| 930 void TurnServerAllocation::Permission::OnMessage(rtc::Message* msg) { | 933 void TurnServerAllocation::Permission::OnMessage(rtc::Message* msg) { |
| 931 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); | 934 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
| 932 SignalDestroyed(this); | 935 SignalDestroyed(this); |
| 933 delete this; | 936 delete this; |
| 934 } | 937 } |
| 935 | 938 |
| 936 TurnServerAllocation::Channel::Channel(rtc::Thread* thread, int id, | 939 TurnServerAllocation::Channel::Channel(rtc::Thread* thread, int id, |
| 937 const rtc::SocketAddress& peer) | 940 const rtc::SocketAddress& peer) |
| 938 : thread_(thread), id_(id), peer_(peer) { | 941 : thread_(thread), id_(id), peer_(peer) { |
| 939 Refresh(); | 942 Refresh(); |
| 940 } | 943 } |
| 941 | 944 |
| 942 TurnServerAllocation::Channel::~Channel() { | 945 TurnServerAllocation::Channel::~Channel() { |
| 943 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); | 946 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); |
| 944 } | 947 } |
| 945 | 948 |
| 946 void TurnServerAllocation::Channel::Refresh() { | 949 void TurnServerAllocation::Channel::Refresh() { |
| 947 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); | 950 thread_->Clear(this, MSG_ALLOCATION_TIMEOUT); |
| 948 thread_->PostDelayed(kChannelTimeout, this, MSG_ALLOCATION_TIMEOUT); | 951 thread_->PostDelayed(RTC_FROM_HERE, kChannelTimeout, this, |
| 952 MSG_ALLOCATION_TIMEOUT); |
| 949 } | 953 } |
| 950 | 954 |
| 951 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { | 955 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { |
| 952 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); | 956 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
| 953 SignalDestroyed(this); | 957 SignalDestroyed(this); |
| 954 delete this; | 958 delete this; |
| 955 } | 959 } |
| 956 | 960 |
| 957 } // namespace cricket | 961 } // namespace cricket |
| OLD | NEW |