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

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

Issue 1556743002: Bind a socket to a network if the network handle is set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix a compiling issue for Windows Created 4 years, 11 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
11 #ifndef WEBRTC_BASE_PHYSICALSOCKETSERVER_H__ 11 #ifndef WEBRTC_BASE_PHYSICALSOCKETSERVER_H__
12 #define WEBRTC_BASE_PHYSICALSOCKETSERVER_H__ 12 #define WEBRTC_BASE_PHYSICALSOCKETSERVER_H__
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/asyncfile.h" 16 #include "webrtc/base/asyncfile.h"
17 #include "webrtc/base/nethelpers.h" 17 #include "webrtc/base/nethelpers.h"
18 #include "webrtc/base/networkmonitor.h"
18 #include "webrtc/base/scoped_ptr.h" 19 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/base/socketserver.h" 20 #include "webrtc/base/socketserver.h"
20 #include "webrtc/base/criticalsection.h" 21 #include "webrtc/base/criticalsection.h"
21 22
22 #if defined(WEBRTC_POSIX) 23 #if defined(WEBRTC_POSIX)
23 typedef int SOCKET; 24 typedef int SOCKET;
24 #endif // WEBRTC_POSIX 25 #endif // WEBRTC_POSIX
25 26
26 namespace rtc { 27 namespace rtc {
27 28
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 68
68 AsyncSocket* CreateAsyncSocket(int type) override; 69 AsyncSocket* CreateAsyncSocket(int type) override;
69 AsyncSocket* CreateAsyncSocket(int family, int type) override; 70 AsyncSocket* CreateAsyncSocket(int family, int type) override;
70 71
71 // Internal Factory for Accept 72 // Internal Factory for Accept
72 AsyncSocket* WrapSocket(SOCKET s); 73 AsyncSocket* WrapSocket(SOCKET s);
73 74
74 // SocketServer: 75 // SocketServer:
75 bool Wait(int cms, bool process_io) override; 76 bool Wait(int cms, bool process_io) override;
76 void WakeUp() override; 77 void WakeUp() override;
78 void MaybeSetNetworkBinder() override;
pthatcher1 2016/01/14 20:07:24 This could use a comment, about what "maybe" means
honghaiz3 2016/01/15 01:00:38 Removed this.
77 79
78 void Add(Dispatcher* dispatcher); 80 void Add(Dispatcher* dispatcher);
79 void Remove(Dispatcher* dispatcher); 81 void Remove(Dispatcher* dispatcher);
80 82
83 NetworkBinderInterface* network_binder() { return network_binder_; }
84
81 #if defined(WEBRTC_POSIX) 85 #if defined(WEBRTC_POSIX)
82 AsyncFile* CreateFile(int fd); 86 AsyncFile* CreateFile(int fd);
83 87
84 // Sets the function to be executed in response to the specified POSIX signal. 88 // Sets the function to be executed in response to the specified POSIX signal.
85 // The function is executed from inside Wait() using the "self-pipe trick"-- 89 // The function is executed from inside Wait() using the "self-pipe trick"--
86 // regardless of which thread receives the signal--and hence can safely 90 // regardless of which thread receives the signal--and hence can safely
87 // manipulate user-level data structures. 91 // manipulate user-level data structures.
88 // "handler" may be SIG_IGN, SIG_DFL, or a user-specified function, just like 92 // "handler" may be SIG_IGN, SIG_DFL, or a user-specified function, just like
89 // with signal(2). 93 // with signal(2).
90 // Only one PhysicalSocketServer should have user-level signal handlers. 94 // Only one PhysicalSocketServer should have user-level signal handlers.
(...skipping 16 matching lines...) Expand all
107 scoped_ptr<PosixSignalDispatcher> signal_dispatcher_; 111 scoped_ptr<PosixSignalDispatcher> signal_dispatcher_;
108 #endif 112 #endif
109 DispatcherList dispatchers_; 113 DispatcherList dispatchers_;
110 IteratorList iterators_; 114 IteratorList iterators_;
111 Signaler* signal_wakeup_; 115 Signaler* signal_wakeup_;
112 CriticalSection crit_; 116 CriticalSection crit_;
113 bool fWait_; 117 bool fWait_;
114 #if defined(WEBRTC_WIN) 118 #if defined(WEBRTC_WIN)
115 WSAEVENT socket_ev_; 119 WSAEVENT socket_ev_;
116 #endif 120 #endif
121 NetworkBinderInterface* network_binder_ = nullptr;
117 }; 122 };
118 123
119 class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { 124 class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> {
120 public: 125 public:
121 PhysicalSocket(PhysicalSocketServer* ss, SOCKET s = INVALID_SOCKET); 126 PhysicalSocket(PhysicalSocketServer* ss, SOCKET s = INVALID_SOCKET);
122 ~PhysicalSocket() override; 127 ~PhysicalSocket() override;
123 128
124 // Creates the underlying OS socket (same as the "socket" function). 129 // Creates the underlying OS socket (same as the "socket" function).
125 virtual bool Create(int family, int type); 130 virtual bool Create(int family, int type);
126 131
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 static int next_id_; 218 static int next_id_;
214 int id_; 219 int id_;
215 bool signal_close_; 220 bool signal_close_;
216 int signal_err_; 221 int signal_err_;
217 #endif // WEBRTC_WIN 222 #endif // WEBRTC_WIN
218 }; 223 };
219 224
220 } // namespace rtc 225 } // namespace rtc
221 226
222 #endif // WEBRTC_BASE_PHYSICALSOCKETSERVER_H__ 227 #endif // WEBRTC_BASE_PHYSICALSOCKETSERVER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698