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

Unified Diff: tools/android/forwarder2/socket.h

Issue 11269036: Support HTTP test-server based net unit tests on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang build + sync Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: tools/android/forwarder2/socket.h
diff --git a/tools/android/forwarder2/socket.h b/tools/android/forwarder2/socket.h
index 15a04b06669e6c33fbd5cc2f1521c6ae5749b70f..701406988e292e05e3ee9dbb82cd6ac95b218019 100644
--- a/tools/android/forwarder2/socket.h
+++ b/tools/android/forwarder2/socket.h
@@ -46,23 +46,24 @@ class Socket {
// Just a wrapper around unix read() function.
// Reads up to buffer_size, but may read less then buffer_size.
// Returns the number of bytes read.
- int Read(char* buffer, size_t buffer_size);
+ int Read(void* buffer, size_t buffer_size);
// Same as Read(), just a wrapper around write().
- int Write(const char* buffer, size_t count);
+ int Write(const void* buffer, size_t count);
// Calls Read() multiple times until num_bytes is written to the provided
// buffer. No bounds checking is performed.
// Returns number of bytes read, which can be different from num_bytes in case
// of errror.
- int ReadNumBytes(char* buffer, size_t num_bytes);
+ int ReadNumBytes(void* buffer, size_t num_bytes);
// Calls Write() multiple times until num_bytes is written. No bounds checking
// is performed. Returns number of bytes written, which can be different from
// num_bytes in case of errror.
- int WriteNumBytes(const char* buffer, size_t num_bytes);
+ int WriteNumBytes(const void* buffer, size_t num_bytes);
- // Calls WriteNumBytes for the given std::string.
+ // Calls WriteNumBytes for the given std::string. Note that the null
+ // terminator is not written to the socket.
int WriteString(const std::string& buffer);
bool has_error() const { return socket_error_; }
@@ -77,6 +78,10 @@ class Socket {
// anymore.
void reset_exit_notifier_fd() { exit_notifier_fd_ = -1; }
+ // Returns whether Accept() or Connect() was interrupted because the socket
+ // received an exit notification.
+ bool exited() const { return exited_; }
+
static int GetHighestFileDescriptor(const Socket& s1, const Socket& s2);
private:
@@ -104,12 +109,9 @@ class Socket {
WRITE
};
- // Waits until either the Socket or the |exit_notifier_fd_| has received a
- // read event (accept or read). Returns false iff an exit notification was
- // received. If |read| is false, it waits until Socket is ready to write,
- // instead. If |timeout_secs| is a non-negative value, it sets the timeout,
- // for the select operation.
- bool WaitForEvent(EventType type, int timeout_secs) const;
+ // Waits until either the Socket or the |exit_notifier_fd_| has received an
+ // event.
+ bool WaitForEvent(EventType type, int timeout_secs);
int socket_;
int port_;
@@ -133,6 +135,8 @@ class Socket {
// and Accept.
int exit_notifier_fd_;
+ bool exited_;
+
DISALLOW_COPY_AND_ASSIGN(Socket);
};

Powered by Google App Engine
This is Rietveld 408576698