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

Side by Side Diff: runtime/bin/sync_socket_android.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.cc ('k') | runtime/bin/sync_socket_fuchsia.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_ANDROID) 8 #if defined(HOST_OS_ANDROID)
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
22
23 void SynchronousSocket::SetClosedFd() {
24 fd_ = kClosedFd;
25 }
26
27
28 bool SynchronousSocket::Initialize() { 21 bool SynchronousSocket::Initialize() {
29 // Nothing to do on Android. 22 // Nothing to do on Android.
30 return true; 23 return true;
31 } 24 }
32 25
33 26
34 static intptr_t Create(const RawAddr& addr) { 27 static intptr_t Create(const RawAddr& addr) {
35 intptr_t fd; 28 intptr_t fd;
36 intptr_t type = SOCK_STREAM; 29 intptr_t type = SOCK_STREAM;
37 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, type, 0)); 30 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, type, 0));
(...skipping 18 matching lines...) Expand all
56 49
57 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) { 50 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) {
58 intptr_t fd = Create(addr); 51 intptr_t fd = Create(addr);
59 if (fd < 0) { 52 if (fd < 0) {
60 return fd; 53 return fd;
61 } 54 }
62 return Connect(fd, addr); 55 return Connect(fd, addr);
63 } 56 }
64 57
65 58
59 intptr_t SynchronousSocket::Available(intptr_t fd) {
60 return SocketBase::Available(fd);
61 }
62
63
64 intptr_t SynchronousSocket::GetPort(intptr_t fd) {
65 return SocketBase::GetPort(fd);
66 }
67
68
69 SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) {
70 return SocketBase::GetRemotePeer(fd, port);
71 }
72
73
74 intptr_t SynchronousSocket::Read(intptr_t fd,
75 void* buffer,
76 intptr_t num_bytes) {
77 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync);
78 }
79
80
81 intptr_t SynchronousSocket::Write(intptr_t fd,
82 const void* buffer,
83 intptr_t num_bytes) {
84 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync);
85 }
86
87
66 void SynchronousSocket::ShutdownRead(intptr_t fd) { 88 void SynchronousSocket::ShutdownRead(intptr_t fd) {
67 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD)); 89 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD));
68 } 90 }
69 91
70 92
71 void SynchronousSocket::ShutdownWrite(intptr_t fd) { 93 void SynchronousSocket::ShutdownWrite(intptr_t fd) {
72 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR)); 94 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR));
73 } 95 }
74 96
97
98 void SynchronousSocket::Close(intptr_t fd) {
99 return SocketBase::Close(fd);
100 }
101
75 } // namespace bin 102 } // namespace bin
76 } // namespace dart 103 } // namespace dart
77 104
78 #endif // defined(HOST_OS_ANDROID) 105 #endif // defined(HOST_OS_ANDROID)
79 106
80 #endif // !defined(DART_IO_DISABLED) 107 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/sync_socket.cc ('k') | runtime/bin/sync_socket_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698