Commit f87d1530 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

The SendAll method on Socket was a helper method that did not really belong in platform.

Review URL: http://codereview.chromium.org/40104

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1414 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 870b6c46
......@@ -656,7 +656,6 @@ class FreeBSDSocket : public Socket {
// Data Transimission
int Send(const char* data, int len) const;
bool SendAll(const char* data, int len) const;
int Receive(char* data, int len) const;
bool IsValid() const { return socket_ != -1; }
......@@ -736,19 +735,6 @@ int FreeBSDSocket::Send(const char* data, int len) const {
}
bool FreeBSDSocket::SendAll(const char* data, int len) const {
int sent_len = 0;
while (sent_len < len) {
int status = Send(data, len);
if (status <= 0) {
return false;
}
sent_len += status;
}
return true;
}
int FreeBSDSocket::Receive(char* data, int len) const {
int status = recv(socket_, data, len, 0);
return status;
......
......@@ -640,7 +640,6 @@ class LinuxSocket : public Socket {
// Data Transimission
int Send(const char* data, int len) const;
bool SendAll(const char* data, int len) const;
int Receive(char* data, int len) const;
bool IsValid() const { return socket_ != -1; }
......@@ -720,19 +719,6 @@ int LinuxSocket::Send(const char* data, int len) const {
}
bool LinuxSocket::SendAll(const char* data, int len) const {
int sent_len = 0;
while (sent_len < len) {
int status = Send(data, len);
if (status <= 0) {
return false;
}
sent_len += status;
}
return true;
}
int LinuxSocket::Receive(char* data, int len) const {
int status = recv(socket_, data, len, 0);
return status;
......
......@@ -607,7 +607,6 @@ class MacOSSocket : public Socket {
// Data Transimission
int Send(const char* data, int len) const;
bool SendAll(const char* data, int len) const;
int Receive(char* data, int len) const;
bool IsValid() const { return socket_ != -1; }
......@@ -693,19 +692,6 @@ int MacOSSocket::Send(const char* data, int len) const {
}
bool MacOSSocket::SendAll(const char* data, int len) const {
int sent_len = 0;
while (sent_len < len) {
int status = Send(data, len);
if (status <= 0) {
return false;
}
sent_len += status;
}
return true;
}
int MacOSSocket::Receive(char* data, int len) const {
int status = recv(socket_, data, len, 0);
return status;
......
......@@ -1583,7 +1583,6 @@ class Win32Socket : public Socket {
// Data Transimission
int Send(const char* data, int len) const;
bool SendAll(const char* data, int len) const;
int Receive(char* data, int len) const;
bool IsValid() const { return socket_ != INVALID_SOCKET; }
......@@ -1663,19 +1662,6 @@ int Win32Socket::Send(const char* data, int len) const {
}
bool Win32Socket::SendAll(const char* data, int len) const {
int sent_len = 0;
while (sent_len < len) {
int status = Send(data, len);
if (status <= 0) {
return false;
}
sent_len += status;
}
return true;
}
int Win32Socket::Receive(char* data, int len) const {
int status = recv(socket_, data, len, 0);
return status;
......
......@@ -437,7 +437,6 @@ class Socket {
// Data Transimission
virtual int Send(const char* data, int len) const = 0;
virtual bool SendAll(const char* data, int len) const = 0;
virtual int Receive(char* data, int len) const = 0;
virtual bool IsValid() const = 0;
......
......@@ -63,6 +63,19 @@ void SocketListenerThread::Run() {
}
static bool SendAll(Socket* socket, const char* data, int len) {
int sent_len = 0;
while (sent_len < len) {
int status = socket->Send(data, len);
if (status <= 0) {
return false;
}
sent_len += status;
}
return true;
}
static void SendAndReceive(char *data, int len) {
bool ok;
......@@ -78,7 +91,7 @@ static void SendAndReceive(char *data, int len) {
CHECK(ok);
// Send all the data.
ok = client->SendAll(data, len);
ok = SendAll(client, data, len);
CHECK(ok);
// Wait until data is received.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment