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

Side by Side Diff: webrtc/base/virtualsocketserver.cc

Issue 2019423006: Adding more detail to MessageQueue::Dispatch logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 local_addr_ = addr; 149 local_addr_ = addr;
150 int result = server_->Bind(this, &local_addr_); 150 int result = server_->Bind(this, &local_addr_);
151 if (result != 0) { 151 if (result != 0) {
152 local_addr_.Clear(); 152 local_addr_.Clear();
153 error_ = EADDRINUSE; 153 error_ = EADDRINUSE;
154 } else { 154 } else {
155 bound_ = true; 155 bound_ = true;
156 was_any_ = addr.IsAnyIP(); 156 was_any_ = addr.IsAnyIP();
157 // Post a message here such that test case could have chance to 157 // Post a message here such that test case could have chance to
158 // process the local address. (i.e. SetAlternativeLocalAddress). 158 // process the local address. (i.e. SetAlternativeLocalAddress).
159 server_->msg_queue_->Post(this, MSG_ID_ADDRESS_BOUND); 159 server_->msg_queue_->Post(FROM_HERE, this, MSG_ID_ADDRESS_BOUND);
160 } 160 }
161 return result; 161 return result;
162 } 162 }
163 163
164 int VirtualSocket::Connect(const SocketAddress& addr) { 164 int VirtualSocket::Connect(const SocketAddress& addr) {
165 return InitiateConnect(addr, true); 165 return InitiateConnect(addr, true);
166 } 166 }
167 167
168 int VirtualSocket::Close() { 168 int VirtualSocket::Close() {
169 if (!local_addr_.IsNil() && bound_) { 169 if (!local_addr_.IsNil() && bound_) {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 bool use_delay) { 747 bool use_delay) {
748 uint32_t delay = use_delay ? GetRandomTransitDelay() : 0; 748 uint32_t delay = use_delay ? GetRandomTransitDelay() : 0;
749 VirtualSocket* remote = LookupBinding(remote_addr); 749 VirtualSocket* remote = LookupBinding(remote_addr);
750 if (!CanInteractWith(socket, remote)) { 750 if (!CanInteractWith(socket, remote)) {
751 LOG(LS_INFO) << "Address family mismatch between " 751 LOG(LS_INFO) << "Address family mismatch between "
752 << socket->GetLocalAddress() << " and " << remote_addr; 752 << socket->GetLocalAddress() << " and " << remote_addr;
753 return -1; 753 return -1;
754 } 754 }
755 if (remote != NULL) { 755 if (remote != NULL) {
756 SocketAddress addr = socket->GetLocalAddress(); 756 SocketAddress addr = socket->GetLocalAddress();
757 msg_queue_->PostDelayed(delay, remote, MSG_ID_CONNECT, 757 msg_queue_->PostDelayed(FROM_HERE, delay, remote, MSG_ID_CONNECT,
758 new MessageAddress(addr)); 758 new MessageAddress(addr));
759 } else { 759 } else {
760 LOG(LS_INFO) << "No one listening at " << remote_addr; 760 LOG(LS_INFO) << "No one listening at " << remote_addr;
761 msg_queue_->PostDelayed(delay, socket, MSG_ID_DISCONNECT); 761 msg_queue_->PostDelayed(FROM_HERE, delay, socket, MSG_ID_DISCONNECT);
762 } 762 }
763 return 0; 763 return 0;
764 } 764 }
765 765
766 bool VirtualSocketServer::Disconnect(VirtualSocket* socket) { 766 bool VirtualSocketServer::Disconnect(VirtualSocket* socket) {
767 if (socket) { 767 if (socket) {
768 // Remove the mapping. 768 // Remove the mapping.
769 msg_queue_->Post(socket, MSG_ID_DISCONNECT); 769 msg_queue_->Post(FROM_HERE, socket, MSG_ID_DISCONNECT);
770 return true; 770 return true;
771 } 771 }
772 return false; 772 return false;
773 } 773 }
774 774
775 int VirtualSocketServer::SendUdp(VirtualSocket* socket, 775 int VirtualSocketServer::SendUdp(VirtualSocket* socket,
776 const char* data, size_t data_size, 776 const char* data, size_t data_size,
777 const SocketAddress& remote_addr) { 777 const SocketAddress& remote_addr) {
778 // See if we want to drop this packet. 778 // See if we want to drop this packet.
779 if (Random() < drop_prob_) { 779 if (Random() < drop_prob_) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // Post the packet as a message to be delivered (on our own thread) 907 // Post the packet as a message to be delivered (on our own thread)
908 Packet* p = new Packet(data, data_size, sender_addr); 908 Packet* p = new Packet(data, data_size, sender_addr);
909 909
910 int64_t ts = TimeAfter(send_delay + transit_delay); 910 int64_t ts = TimeAfter(send_delay + transit_delay);
911 if (ordered) { 911 if (ordered) {
912 // Ensure that new packets arrive after previous ones 912 // Ensure that new packets arrive after previous ones
913 // TODO: consider ordering on a per-socket basis, since this 913 // TODO: consider ordering on a per-socket basis, since this
914 // introduces artificial delay. 914 // introduces artificial delay.
915 ts = std::max(ts, network_delay_); 915 ts = std::max(ts, network_delay_);
916 } 916 }
917 msg_queue_->PostAt(ts, recipient, MSG_ID_PACKET, p); 917 msg_queue_->PostAt(FROM_HERE, ts, recipient, MSG_ID_PACKET, p);
918 network_delay_ = std::max(ts, network_delay_); 918 network_delay_ = std::max(ts, network_delay_);
919 } 919 }
920 920
921 void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket, 921 void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket,
922 int64_t cur_time) { 922 int64_t cur_time) {
923 while (!socket->network_.empty() && 923 while (!socket->network_.empty() &&
924 (socket->network_.front().done_time <= cur_time)) { 924 (socket->network_.front().done_time <= cur_time)) {
925 ASSERT(socket->network_size_ >= socket->network_.front().size); 925 ASSERT(socket->network_size_ >= socket->network_.front().size);
926 socket->network_size_ -= socket->network_.front().size; 926 socket->network_size_ -= socket->network_.front().size;
927 socket->network_.pop_front(); 927 socket->network_.pop_front();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) { 1135 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) {
1136 RTC_DCHECK(!IPIsAny(from_addr)); 1136 RTC_DCHECK(!IPIsAny(from_addr));
1137 if (from_addr.family() == AF_INET) { 1137 if (from_addr.family() == AF_INET) {
1138 default_route_v4_ = from_addr; 1138 default_route_v4_ = from_addr;
1139 } else if (from_addr.family() == AF_INET6) { 1139 } else if (from_addr.family() == AF_INET6) {
1140 default_route_v6_ = from_addr; 1140 default_route_v6_ = from_addr;
1141 } 1141 }
1142 } 1142 }
1143 1143
1144 } // namespace rtc 1144 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698