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

Side by Side Diff: runtime/bin/sync_socket_macos.cc

Issue 2830273002: [dart:io][windows] Implements RawSynchronousSocket (Closed)
Patch Set: Fix Linux build Created 3 years, 8 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 | « runtime/bin/sync_socket_linux.cc ('k') | runtime/bin/sync_socket_win.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 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_MACOS) 8 #if defined(HOST_OS_MACOS)
9 9
10 #include "bin/sync_socket.h" 10 #include "bin/sync_socket.h"
11 11
12 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
13 13
14 #include "bin/fdutils.h" 14 #include "bin/fdutils.h"
15 #include "bin/socket_base.h"
15 #include "platform/signal_blocker.h" 16 #include "platform/signal_blocker.h"
16 17
17 namespace dart { 18 namespace dart {
18 namespace bin { 19 namespace bin {
19 20
20 SynchronousSocket::SynchronousSocket(intptr_t fd) : fd_(fd) {} 21 bool SynchronousSocket::Initialize() {
21 22 // Nothing to do on Linux.
22 23 return true;
23 void SynchronousSocket::SetClosedFd() {
24 fd_ = kClosedFd;
25 } 24 }
26 25
27 26
28 static intptr_t Create(const RawAddr& addr) { 27 static intptr_t Create(const RawAddr& addr) {
29 intptr_t fd; 28 intptr_t fd;
30 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 29 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
31 if (fd < 0) { 30 if (fd < 0) {
32 return -1; 31 return -1;
33 } 32 }
34 if (!FDUtils::SetCloseOnExec(fd)) { 33 if (!FDUtils::SetCloseOnExec(fd)) {
(...skipping 18 matching lines...) Expand all
53 52
54 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) { 53 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) {
55 intptr_t fd = Create(addr); 54 intptr_t fd = Create(addr);
56 if (fd < 0) { 55 if (fd < 0) {
57 return fd; 56 return fd;
58 } 57 }
59 return Connect(fd, addr); 58 return Connect(fd, addr);
60 } 59 }
61 60
62 61
62 intptr_t SynchronousSocket::Available(intptr_t fd) {
63 return SocketBase::Available(fd);
64 }
65
66
67 intptr_t SynchronousSocket::GetPort(intptr_t fd) {
68 return SocketBase::GetPort(fd);
69 }
70
71
72 SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) {
73 return SocketBase::GetRemotePeer(fd, port);
74 }
75
76
77 intptr_t SynchronousSocket::Read(intptr_t fd,
78 void* buffer,
79 intptr_t num_bytes) {
80 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync);
81 }
82
83
84 intptr_t SynchronousSocket::Write(intptr_t fd,
85 const void* buffer,
86 intptr_t num_bytes) {
87 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync);
88 }
89
90
63 void SynchronousSocket::ShutdownRead(intptr_t fd) { 91 void SynchronousSocket::ShutdownRead(intptr_t fd) {
64 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD)); 92 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD));
65 } 93 }
66 94
67 95
68 void SynchronousSocket::ShutdownWrite(intptr_t fd) { 96 void SynchronousSocket::ShutdownWrite(intptr_t fd) {
69 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR)); 97 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR));
70 } 98 }
71 99
100
101 void SynchronousSocket::Close(intptr_t fd) {
102 return SocketBase::Close(fd);
103 }
104
72 } // namespace bin 105 } // namespace bin
73 } // namespace dart 106 } // namespace dart
74 107
75 #endif // defined(HOST_OS_MACOS) 108 #endif // defined(HOST_OS_MACOS)
76 109
77 #endif // !defined(DART_IO_DISABLED) 110 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/sync_socket_linux.cc ('k') | runtime/bin/sync_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698