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

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

Issue 2883313003: Remove VirtualSocketServer's dependency on PhysicalSocketServer. (Closed)
Patch Set: Created 3 years, 7 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/base/virtualsocket_unittest.cc ('k') | webrtc/base/virtualsocketserver.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
11 #ifndef WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ 11 #ifndef WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
12 #define WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ 12 #define WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
13 13
14 #include <deque> 14 #include <deque>
15 #include <map> 15 #include <map>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/base/event.h"
19 #include "webrtc/base/messagequeue.h" 20 #include "webrtc/base/messagequeue.h"
20 #include "webrtc/base/socketserver.h" 21 #include "webrtc/base/socketserver.h"
21 22
22 namespace rtc { 23 namespace rtc {
23 24
24 class Packet; 25 class Packet;
25 class VirtualSocket; 26 class VirtualSocket;
26 class SocketAddressPair; 27 class SocketAddressPair;
27 28
28 // Simulates a network in the same manner as a loopback interface. The 29 // Simulates a network in the same manner as a loopback interface. The
29 // interface can create as many addresses as you want. All of the sockets 30 // interface can create as many addresses as you want. All of the sockets
30 // created by this network will be able to communicate with one another, unless 31 // created by this network will be able to communicate with one another, unless
31 // they are bound to addresses from incompatible families. 32 // they are bound to addresses from incompatible families.
32 class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { 33 class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
33 public: 34 public:
34 // TODO: Add "owned" parameter. 35 VirtualSocketServer();
35 // If "owned" is set, the supplied socketserver will be deleted later.
36 explicit VirtualSocketServer(SocketServer* ss);
37 ~VirtualSocketServer() override; 36 ~VirtualSocketServer() override;
38 37
39 SocketServer* socketserver() { return server_; }
40
41 // The default route indicates which local address to use when a socket is 38 // The default route indicates which local address to use when a socket is
42 // bound to the 'any' address, e.g. 0.0.0.0. 39 // bound to the 'any' address, e.g. 0.0.0.0.
43 IPAddress GetDefaultRoute(int family); 40 IPAddress GetDefaultRoute(int family);
44 void SetDefaultRoute(const IPAddress& from_addr); 41 void SetDefaultRoute(const IPAddress& from_addr);
45 42
46 // Limits the network bandwidth (maximum bytes per second). Zero means that 43 // Limits the network bandwidth (maximum bytes per second). Zero means that
47 // all sends occur instantly. Defaults to 0. 44 // all sends occur instantly. Defaults to 0.
48 uint32_t bandwidth() const { return bandwidth_; } 45 uint32_t bandwidth() const { return bandwidth_; }
49 void set_bandwidth(uint32_t bandwidth) { bandwidth_ = bandwidth; } 46 void set_bandwidth(uint32_t bandwidth) { bandwidth_ = bandwidth; }
50 47
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 235
239 private: 236 private:
240 friend class VirtualSocket; 237 friend class VirtualSocket;
241 238
242 // Sending was previously blocked, but now isn't. 239 // Sending was previously blocked, but now isn't.
243 sigslot::signal0<> SignalReadyToSend; 240 sigslot::signal0<> SignalReadyToSend;
244 241
245 typedef std::map<SocketAddress, VirtualSocket*> AddressMap; 242 typedef std::map<SocketAddress, VirtualSocket*> AddressMap;
246 typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap; 243 typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap;
247 244
248 SocketServer* server_; 245 // Used to implement Wait/WakeUp.
249 bool server_owned_; 246 Event wakeup_;
250 MessageQueue* msg_queue_; 247 MessageQueue* msg_queue_;
251 bool stop_on_idle_; 248 bool stop_on_idle_;
252 in_addr next_ipv4_; 249 in_addr next_ipv4_;
253 in6_addr next_ipv6_; 250 in6_addr next_ipv6_;
254 uint16_t next_port_; 251 uint16_t next_port_;
255 AddressMap* bindings_; 252 AddressMap* bindings_;
256 ConnectionMap* connections_; 253 ConnectionMap* connections_;
257 254
258 IPAddress default_route_v4_; 255 IPAddress default_route_v4_;
259 IPAddress default_route_v6_; 256 IPAddress default_route_v6_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 382
386 // Store the options that are set 383 // Store the options that are set
387 OptionsMap options_map_; 384 OptionsMap options_map_;
388 385
389 friend class VirtualSocketServer; 386 friend class VirtualSocketServer;
390 }; 387 };
391 388
392 } // namespace rtc 389 } // namespace rtc
393 390
394 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ 391 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
OLDNEW
« no previous file with comments | « webrtc/base/virtualsocket_unittest.cc ('k') | webrtc/base/virtualsocketserver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698