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

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

Issue 2369013002: Delete macsocketserver.h and related files. (Closed)
Patch Set: Drop macsocketserver_unittest.cc. Created 4 years, 2 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
(Empty)
1 /*
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10 // MacAsyncSocket is a kind of AsyncSocket. It only creates sockets
11 // of the TCP type, and does not (yet) support listen and accept. It works
12 // asynchronously, which means that users of this socket should connect to
13 // the various events declared in asyncsocket.h to receive notifications about
14 // this socket.
15
16 #ifndef WEBRTC_BASE_MACASYNCSOCKET_H__
17 #define WEBRTC_BASE_MACASYNCSOCKET_H__
18
19 #include <CoreFoundation/CoreFoundation.h>
20
21 #include "webrtc/base/asyncsocket.h"
22 #include "webrtc/base/constructormagic.h"
23 #include "webrtc/base/nethelpers.h"
24
25 namespace rtc {
26
27 class MacBaseSocketServer;
28
29 class MacAsyncSocket : public AsyncSocket, public sigslot::has_slots<> {
30 public:
31 MacAsyncSocket(MacBaseSocketServer* ss, int family);
32 ~MacAsyncSocket() override;
33
34 bool valid() const { return source_ != NULL; }
35
36 // Socket interface
37 SocketAddress GetLocalAddress() const override;
38 SocketAddress GetRemoteAddress() const override;
39 int Bind(const SocketAddress& addr) override;
40 int Connect(const SocketAddress& addr) override;
41 int Send(const void* buffer, size_t length) override;
42 int SendTo(const void* buffer,
43 size_t length,
44 const SocketAddress& addr) override;
45 int Recv(void* buffer, size_t length, int64_t* timestamp) override;
46 int RecvFrom(void* buffer,
47 size_t length,
48 SocketAddress* out_addr,
49 int64_t* timestamp) override;
50 int Listen(int backlog) override;
51 MacAsyncSocket* Accept(SocketAddress* out_addr) override;
52 int Close() override;
53 int GetError() const override;
54 void SetError(int error) override;
55 ConnState GetState() const override;
56 int EstimateMTU(uint16_t* mtu) override;
57 int GetOption(Option opt, int* value) override;
58 int SetOption(Option opt, int value) override;
59
60 // For the MacBaseSocketServer to disable callbacks when process_io is false.
61 void EnableCallbacks();
62 void DisableCallbacks();
63
64 protected:
65 void OnResolveResult(SignalThread* thread);
66 int DoConnect(const SocketAddress& addr);
67
68 private:
69 // Creates an async socket from an existing bsd socket
70 MacAsyncSocket(MacBaseSocketServer* ss, int family, int native_socket);
71
72 // Attaches the socket to the CFRunloop and sets the wrapped bsd socket
73 // to async mode
74 void Initialize(int family);
75
76 // Translate the SocketAddress into a CFDataRef to pass to CF socket
77 // functions. Caller must call CFRelease on the result when done.
78 static CFDataRef CopyCFAddress(const SocketAddress& address);
79
80 // Callback for the underlying CFSocketRef.
81 static void MacAsyncSocketCallBack(CFSocketRef s,
82 CFSocketCallBackType callbackType,
83 CFDataRef address,
84 const void* data,
85 void* info);
86
87 MacBaseSocketServer* ss_;
88 CFSocketRef socket_;
89 int native_socket_;
90 CFRunLoopSourceRef source_;
91 int current_callbacks_;
92 bool disabled_;
93 int error_;
94 ConnState state_;
95 AsyncResolver* resolver_;
96
97 RTC_DISALLOW_COPY_AND_ASSIGN(MacAsyncSocket);
98 };
99
100 } // namespace rtc
101
102 #endif // WEBRTC_BASE_MACASYNCSOCKET_H__
OLDNEW
« webrtc/base/BUILD.gn ('K') | « webrtc/base/base.gyp ('k') | webrtc/base/macasyncsocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698