Skip to content

Commit

Permalink
Clean up socket.h header (#4174)
Browse files Browse the repository at this point in the history
b/369182833
madhurajayaraman authored Oct 1, 2024
1 parent 4ce5a3d commit ecdcebe
Showing 20 changed files with 7 additions and 859 deletions.
8 changes: 0 additions & 8 deletions net/base/net_errors.h
Original file line number Diff line number Diff line change
@@ -61,14 +61,6 @@ NET_EXPORT bool IsRequestBlockedError(int error);
NET_EXPORT Error MapSystemError(logging::SystemErrorCode os_error);

#if defined(STARBOARD)
// Map socket error code to Error.
NET_EXPORT Error MapSocketError(SbSocketError error);

// Gets the last socket error as a net error.
static inline Error MapLastSocketError(SbSocket socket) {
return MapSocketError(SbSocketGetLastError(socket));
}

// Gets the last system error as a net error.
static inline Error MapLastSystemError() {
return MapSystemError(SbSystemGetLastError());
3 changes: 0 additions & 3 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
@@ -88,17 +88,14 @@ static_library("starboard_platform") {
"//starboard/shared/posix/set_non_blocking_internal.cc",
"//starboard/shared/posix/socket_accept.cc",
"//starboard/shared/posix/socket_bind.cc",
"//starboard/shared/posix/socket_clear_last_error.cc",
"//starboard/shared/posix/socket_connect.cc",
"//starboard/shared/posix/socket_create.cc",
"//starboard/shared/posix/socket_destroy.cc",
"//starboard/shared/posix/socket_get_last_error.cc",
"//starboard/shared/posix/socket_get_local_address.cc",
"//starboard/shared/posix/socket_internal.cc",
"//starboard/shared/posix/socket_is_ipv6_supported.cc",
"//starboard/shared/posix/socket_listen.cc",
"//starboard/shared/posix/socket_receive_from.cc",
"//starboard/shared/posix/socket_send_to.cc",
"//starboard/shared/posix/socket_set_reuse_address.cc",
"//starboard/shared/posix/storage_write_record.cc",
"//starboard/shared/posix/system_break_into_debugger.cc",
18 changes: 0 additions & 18 deletions starboard/common/socket.cc
Original file line number Diff line number Diff line change
@@ -92,30 +92,12 @@ Socket* Socket::Accept() {
return NULL;
}

bool Socket::IsPending() {
return GetLastError() == kSbSocketPending;
}

SbSocketError Socket::GetLastError() {
return SbSocketGetLastError(socket_);
}

void Socket::ClearLastError() {
SbSocketClearLastError(socket_);
}

int Socket::ReceiveFrom(char* out_data,
int data_size,
SbSocketAddress* out_source) {
return SbSocketReceiveFrom(socket_, out_data, data_size, out_source);
}

int Socket::SendTo(const char* data,
int data_size,
const SbSocketAddress* destination) {
return SbSocketSendTo(socket_, data, data_size, destination);
}

bool Socket::GetLocalAddress(SbSocketAddress* out_address) {
return SbSocketGetLocalAddress(socket_, out_address);
}
3 changes: 0 additions & 3 deletions starboard/elf_loader/exported_symbols.cc
Original file line number Diff line number Diff line change
@@ -149,17 +149,14 @@ ExportedSymbols::ExportedSymbols() {
REGISTER_SYMBOL(SbPlayerWriteSamples);
REGISTER_SYMBOL(SbSocketAccept);
REGISTER_SYMBOL(SbSocketBind);
REGISTER_SYMBOL(SbSocketClearLastError);
REGISTER_SYMBOL(SbSocketConnect);
REGISTER_SYMBOL(SbSocketCreate);
REGISTER_SYMBOL(SbSocketDestroy);
REGISTER_SYMBOL(SbSocketGetInterfaceAddress);
REGISTER_SYMBOL(SbSocketGetLastError);
REGISTER_SYMBOL(SbSocketGetLocalAddress);
REGISTER_SYMBOL(SbSocketIsIpv6Supported);
REGISTER_SYMBOL(SbSocketListen);
REGISTER_SYMBOL(SbSocketReceiveFrom);
REGISTER_SYMBOL(SbSocketSendTo);
REGISTER_SYMBOL(SbSocketSetReuseAddress);
REGISTER_SYMBOL(SbSocketWaiterAdd);
REGISTER_SYMBOL(SbSocketWaiterCreate);
3 changes: 0 additions & 3 deletions starboard/linux/shared/BUILD.gn
Original file line number Diff line number Diff line change
@@ -158,17 +158,14 @@ static_library("starboard_platform_sources") {
"//starboard/shared/posix/set_non_blocking_internal.cc",
"//starboard/shared/posix/socket_accept.cc",
"//starboard/shared/posix/socket_bind.cc",
"//starboard/shared/posix/socket_clear_last_error.cc",
"//starboard/shared/posix/socket_connect.cc",
"//starboard/shared/posix/socket_create.cc",
"//starboard/shared/posix/socket_destroy.cc",
"//starboard/shared/posix/socket_get_last_error.cc",
"//starboard/shared/posix/socket_get_local_address.cc",
"//starboard/shared/posix/socket_internal.cc",
"//starboard/shared/posix/socket_is_ipv6_supported.cc",
"//starboard/shared/posix/socket_listen.cc",
"//starboard/shared/posix/socket_receive_from.cc",
"//starboard/shared/posix/socket_send_to.cc",
"//starboard/shared/posix/socket_set_reuse_address.cc",
"//starboard/shared/posix/storage_write_record.cc",
"//starboard/shared/posix/system_break_into_debugger.cc",
3 changes: 2 additions & 1 deletion starboard/nplb/socket_clear_last_error_test.cc
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

// The Sunny Day test is used in several other tests as the way to detect if the
// error is correct, so it is not repeated here.

#if SB_API_VERSION < 17
#include "starboard/common/socket.h"
#include "starboard/nplb/socket_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -46,3 +46,4 @@ TEST(SbSocketClearLastErrorTest, RainyDayInvalidSocket) {
} // namespace
} // namespace nplb
} // namespace starboard
#endif // SB_API_VERSION < 17
3 changes: 2 additions & 1 deletion starboard/nplb/socket_get_last_error_test.cc
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

// The Sunny Day test is used in several other tests as the way to detect if the
// error is correct, so it is not repeated here.

#if SB_API_VERSION < 17
#include "starboard/common/socket.h"
#include "testing/gtest/include/gtest/gtest.h"

@@ -29,3 +29,4 @@ TEST(SbSocketGetLastErrorTest, RainyDayInvalidSocket) {
} // namespace
} // namespace nplb
} // namespace starboard
#endif // SB_API_VERSION < 17
2 changes: 0 additions & 2 deletions starboard/nplb/socket_is_connected_and_idle_test.cc
Original file line number Diff line number Diff line change
@@ -80,7 +80,6 @@ TEST_P(PairSbSocketIsConnectedAndIdleTest, SunnyDay) {
EXPECT_TRUE(SbSocketDestroy(trio.client_socket));
EXPECT_TRUE(SbSocketDestroy(trio.listen_socket));
}
#endif // SB_API_VERSION < 17

TEST_P(SbSocketIsConnectedAndIdleTest, SunnyDayNotConnected) {
SbSocket socket = SbSocketCreate(GetAddressType(), kSbSocketProtocolTcp);
@@ -89,7 +88,6 @@ TEST_P(SbSocketIsConnectedAndIdleTest, SunnyDayNotConnected) {
EXPECT_TRUE(SbSocketDestroy(socket));
}

#if SB_API_VERSION < 17
TEST_P(SbSocketIsConnectedAndIdleTest, SunnyDayListeningNotConnected) {
SbSocket server_socket =
CreateListeningTcpSocket(GetAddressType(), GetPortNumberForTests());
5 changes: 3 additions & 2 deletions starboard/nplb/socket_receive_from_test.cc
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if SB_API_VERSION < 17

#include <utility>

#include "starboard/common/socket.h"
@@ -68,7 +70,6 @@ int Transfer(SbSocket receive_socket,
return size;
}

#if SB_API_VERSION < 17
TEST_P(PairSbSocketReceiveFromTest, SunnyDay) {
const int kBufSize = 256 * 1024;
const int kSockBufSize = kBufSize / 8;
@@ -133,8 +134,8 @@ INSTANTIATE_TEST_CASE_P(
std::make_pair(kSbSocketAddressTypeIpv6, kSbSocketAddressTypeIpv6),
std::make_pair(kSbSocketAddressTypeIpv6, kSbSocketAddressTypeIpv4)),
GetSbSocketAddressTypePairName);
#endif // SB_API_VERSION < 17

} // namespace
} // namespace nplb
} // namespace starboard
#endif // SB_API_VERSION < 17
3 changes: 0 additions & 3 deletions starboard/raspi/shared/BUILD.gn
Original file line number Diff line number Diff line change
@@ -116,17 +116,14 @@ static_library("starboard_platform_sources") {
"//starboard/shared/posix/set_non_blocking_internal.cc",
"//starboard/shared/posix/socket_accept.cc",
"//starboard/shared/posix/socket_bind.cc",
"//starboard/shared/posix/socket_clear_last_error.cc",
"//starboard/shared/posix/socket_connect.cc",
"//starboard/shared/posix/socket_create.cc",
"//starboard/shared/posix/socket_destroy.cc",
"//starboard/shared/posix/socket_get_last_error.cc",
"//starboard/shared/posix/socket_get_local_address.cc",
"//starboard/shared/posix/socket_internal.cc",
"//starboard/shared/posix/socket_is_ipv6_supported.cc",
"//starboard/shared/posix/socket_listen.cc",
"//starboard/shared/posix/socket_receive_from.cc",
"//starboard/shared/posix/socket_send_to.cc",
"//starboard/shared/posix/socket_set_reuse_address.cc",
"//starboard/shared/posix/storage_write_record.cc",
"//starboard/shared/posix/system_break_into_debugger.cc",
26 changes: 0 additions & 26 deletions starboard/shared/posix/socket_clear_last_error.cc

This file was deleted.

25 changes: 0 additions & 25 deletions starboard/shared/posix/socket_get_last_error.cc

This file was deleted.

96 changes: 0 additions & 96 deletions starboard/shared/posix/socket_send_to.cc

This file was deleted.

489 changes: 0 additions & 489 deletions starboard/shared/starboard/net_log.cc

This file was deleted.

73 changes: 0 additions & 73 deletions starboard/shared/starboard/net_log.h

This file was deleted.

19 changes: 0 additions & 19 deletions starboard/shared/stub/socket_clear_last_error.cc

This file was deleted.

19 changes: 0 additions & 19 deletions starboard/shared/stub/socket_get_last_error.cc

This file was deleted.

22 changes: 0 additions & 22 deletions starboard/shared/stub/socket_send_to.cc

This file was deleted.

43 changes: 0 additions & 43 deletions starboard/socket.h
Original file line number Diff line number Diff line change
@@ -207,20 +207,6 @@ SB_EXPORT SbSocketError SbSocketListen(SbSocket socket);
// |socket|: The SbSocket that is accepting a pending connection.
SB_EXPORT SbSocket SbSocketAccept(SbSocket socket);

// DEPRECATED with SB_API_VERSION 16
//
// Returns the last error set on |socket|. If |socket| is not valid, this
// function returns |kSbSocketErrorFailed|.
//
// |socket|: The SbSocket that the last error is returned for.
SB_EXPORT SbSocketError SbSocketGetLastError(SbSocket socket);

// DEPRECATED with SB_API_VERSION 16
//
// Clears the last error set on |socket|. The return value indicates whether
// the socket error was cleared.
SB_EXPORT bool SbSocketClearLastError(SbSocket socket);

// DEPRECATED with SB_API_VERSION 16
//
// Gets the address that this socket is bound to locally, if the socket is
@@ -299,35 +285,6 @@ SB_EXPORT int SbSocketReceiveFrom(SbSocket socket,
int data_size,
SbSocketAddress* out_source);

// DEPRECATED with SB_API_VERSION 16
//
// Writes up to |data_size| bytes of |data| to |destination| via
// |socket|. Returns the number of bytes written, or a negative number if
// there is an error, in which case |SbSocketGetLastError| can provide the
// precise error encountered.
//
// Note that this function is NOT specified to make a best effort to write all
// data on all platforms, but it MAY still do so. It is specified to write
// however many bytes are available conveniently. It can be run in a loop
// until SbSocketGetLastError returns |kSbSocketPending| to make it a
// best-effort write (but still only up to not blocking, unless you want to
// spin).
//
// |socket|: The SbSocket to use to write data.
// |data|: The data written to the socket. Must not be NULL.
// |data_size|: The number of bytes of |data| to write.
// |destination|: The location to which data is written. This value must be
// |NULL| for TCP connections, which can only have a single endpoint.
//
// The primary use of |destination| is to send datagram packets, which can
// go out to multiple sources from a single UDP server socket. TCP has two
// endpoints connected persistently, so setting |destination| when sending
// to a TCP socket will cause an error.
SB_EXPORT int SbSocketSendTo(SbSocket socket,
const char* data,
int data_size,
const SbSocketAddress* destination);

// DEPRECATED with SB_API_VERSION 16
//
// Sets the |SO_REUSEADDR|, or equivalent, option to |value| on |socket|.
3 changes: 0 additions & 3 deletions starboard/stub/BUILD.gn
Original file line number Diff line number Diff line change
@@ -103,17 +103,14 @@ static_library("stub_sources") {
"//starboard/shared/stub/player_write_samples.cc",
"//starboard/shared/stub/socket_accept.cc",
"//starboard/shared/stub/socket_bind.cc",
"//starboard/shared/stub/socket_clear_last_error.cc",
"//starboard/shared/stub/socket_connect.cc",
"//starboard/shared/stub/socket_create.cc",
"//starboard/shared/stub/socket_destroy.cc",
"//starboard/shared/stub/socket_get_interface_address.cc",
"//starboard/shared/stub/socket_get_last_error.cc",
"//starboard/shared/stub/socket_get_local_address.cc",
"//starboard/shared/stub/socket_is_ipv6_supported.cc",
"//starboard/shared/stub/socket_listen.cc",
"//starboard/shared/stub/socket_receive_from.cc",
"//starboard/shared/stub/socket_send_to.cc",
"//starboard/shared/stub/socket_set_reuse_address.cc",
"//starboard/shared/stub/socket_waiter_add.cc",
"//starboard/shared/stub/socket_waiter_create.cc",

0 comments on commit ecdcebe

Please sign in to comment.