| OLD | NEW |
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Sends the given packet to the socket at the given address (if one exists). | 162 // Sends the given packet to the socket at the given address (if one exists). |
| 163 int SendUdp(VirtualSocket* socket, const char* data, size_t data_size, | 163 int SendUdp(VirtualSocket* socket, const char* data, size_t data_size, |
| 164 const SocketAddress& remote_addr); | 164 const SocketAddress& remote_addr); |
| 165 | 165 |
| 166 // Moves as much data as possible from the sender's buffer to the network | 166 // Moves as much data as possible from the sender's buffer to the network |
| 167 void SendTcp(VirtualSocket* socket); | 167 void SendTcp(VirtualSocket* socket); |
| 168 | 168 |
| 169 // Places a packet on the network. | 169 // Places a packet on the network. |
| 170 void AddPacketToNetwork(VirtualSocket* socket, | 170 void AddPacketToNetwork(VirtualSocket* socket, |
| 171 VirtualSocket* recipient, | 171 VirtualSocket* recipient, |
| 172 uint32_t cur_time, | 172 int64_t cur_time, |
| 173 const char* data, | 173 const char* data, |
| 174 size_t data_size, | 174 size_t data_size, |
| 175 size_t header_size, | 175 size_t header_size, |
| 176 bool ordered); | 176 bool ordered); |
| 177 | 177 |
| 178 // Removes stale packets from the network | 178 // Removes stale packets from the network |
| 179 void PurgeNetworkPackets(VirtualSocket* socket, uint32_t cur_time); | 179 void PurgeNetworkPackets(VirtualSocket* socket, int64_t cur_time); |
| 180 | 180 |
| 181 // Computes the number of milliseconds required to send a packet of this size. | 181 // Computes the number of milliseconds required to send a packet of this size. |
| 182 uint32_t SendDelay(uint32_t size); | 182 uint32_t SendDelay(uint32_t size); |
| 183 | 183 |
| 184 // Returns a random transit delay chosen from the appropriate distribution. | 184 // Returns a random transit delay chosen from the appropriate distribution. |
| 185 uint32_t GetRandomTransitDelay(); | 185 uint32_t GetRandomTransitDelay(); |
| 186 | 186 |
| 187 // Basic operations on functions. Those that return a function also take | 187 // Basic operations on functions. Those that return a function also take |
| 188 // ownership of the function given (and hence, may modify or delete it). | 188 // ownership of the function given (and hence, may modify or delete it). |
| 189 static Function* Accumulate(Function* f); | 189 static Function* Accumulate(Function* f); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 220 private: | 220 private: |
| 221 friend class VirtualSocket; | 221 friend class VirtualSocket; |
| 222 | 222 |
| 223 typedef std::map<SocketAddress, VirtualSocket*> AddressMap; | 223 typedef std::map<SocketAddress, VirtualSocket*> AddressMap; |
| 224 typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap; | 224 typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap; |
| 225 | 225 |
| 226 SocketServer* server_; | 226 SocketServer* server_; |
| 227 bool server_owned_; | 227 bool server_owned_; |
| 228 MessageQueue* msg_queue_; | 228 MessageQueue* msg_queue_; |
| 229 bool stop_on_idle_; | 229 bool stop_on_idle_; |
| 230 uint32_t network_delay_; | 230 int64_t network_delay_; |
| 231 in_addr next_ipv4_; | 231 in_addr next_ipv4_; |
| 232 in6_addr next_ipv6_; | 232 in6_addr next_ipv6_; |
| 233 uint16_t next_port_; | 233 uint16_t next_port_; |
| 234 AddressMap* bindings_; | 234 AddressMap* bindings_; |
| 235 ConnectionMap* connections_; | 235 ConnectionMap* connections_; |
| 236 | 236 |
| 237 IPAddress default_route_v4_; | 237 IPAddress default_route_v4_; |
| 238 IPAddress default_route_v6_; | 238 IPAddress default_route_v6_; |
| 239 | 239 |
| 240 uint32_t bandwidth_; | 240 uint32_t bandwidth_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 bool was_any() { return was_any_; } | 287 bool was_any() { return was_any_; } |
| 288 void set_was_any(bool was_any) { was_any_ = was_any; } | 288 void set_was_any(bool was_any) { was_any_ = was_any; } |
| 289 | 289 |
| 290 // For testing purpose only. Fired when client socket is bound to an address. | 290 // For testing purpose only. Fired when client socket is bound to an address. |
| 291 sigslot::signal2<VirtualSocket*, const SocketAddress&> SignalAddressReady; | 291 sigslot::signal2<VirtualSocket*, const SocketAddress&> SignalAddressReady; |
| 292 | 292 |
| 293 private: | 293 private: |
| 294 struct NetworkEntry { | 294 struct NetworkEntry { |
| 295 size_t size; | 295 size_t size; |
| 296 uint32_t done_time; | 296 int64_t done_time; |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 typedef std::deque<SocketAddress> ListenQueue; | 299 typedef std::deque<SocketAddress> ListenQueue; |
| 300 typedef std::deque<NetworkEntry> NetworkQueue; | 300 typedef std::deque<NetworkEntry> NetworkQueue; |
| 301 typedef std::vector<char> SendBuffer; | 301 typedef std::vector<char> SendBuffer; |
| 302 typedef std::list<Packet*> RecvBuffer; | 302 typedef std::list<Packet*> RecvBuffer; |
| 303 typedef std::map<Option, int> OptionsMap; | 303 typedef std::map<Option, int> OptionsMap; |
| 304 | 304 |
| 305 int InitiateConnect(const SocketAddress& addr, bool use_delay); | 305 int InitiateConnect(const SocketAddress& addr, bool use_delay); |
| 306 void CompleteConnect(const SocketAddress& addr, bool notify); | 306 void CompleteConnect(const SocketAddress& addr, bool notify); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 // Store the options that are set | 350 // Store the options that are set |
| 351 OptionsMap options_map_; | 351 OptionsMap options_map_; |
| 352 | 352 |
| 353 friend class VirtualSocketServer; | 353 friend class VirtualSocketServer; |
| 354 }; | 354 }; |
| 355 | 355 |
| 356 } // namespace rtc | 356 } // namespace rtc |
| 357 | 357 |
| 358 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ | 358 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ |
| OLD | NEW |