aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Networking
diff options
context:
space:
mode:
authorGravatar rmistry@google.com <rmistry@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-23 18:14:13 +0000
committerGravatar rmistry@google.com <rmistry@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-23 18:14:13 +0000
commitd6176b0dcacb124539e0cfd051e6d93a9782f020 (patch)
tree9e6f4b465e54c9b26e1ba70cd8890b55abb08464 /experimental/Networking
parentfbfcd5602128ec010c82cb733c9cdc0a3254f9f3 (diff)
Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/)
This CL is part II of IV (I broke down the 1280 files into 4 CLs). Review URL: https://codereview.appspot.com/6474054 git-svn-id: http://skia.googlecode.com/svn/trunk@5263 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Networking')
-rw-r--r--experimental/Networking/SampleNetPipeReader.cpp24
-rw-r--r--experimental/Networking/SkSockets.cpp22
-rw-r--r--experimental/Networking/SkSockets.h36
3 files changed, 41 insertions, 41 deletions
diff --git a/experimental/Networking/SampleNetPipeReader.cpp b/experimental/Networking/SampleNetPipeReader.cpp
index f58d5c2164..4332cbd287 100644
--- a/experimental/Networking/SampleNetPipeReader.cpp
+++ b/experimental/Networking/SampleNetPipeReader.cpp
@@ -14,7 +14,7 @@
* received all the data transmitted and attempt to reproduce the drawing calls.
* This reader will only keep the latest batch of data. In order to keep up with
* the server, which may be producing data at a much higher rate than the reader
- * is consuming, the reader will attempt multiple reads and only render the
+ * is consuming, the reader will attempt multiple reads and only render the
* latest frame. this behavior can be adjusted by changing MAX_READS_PER_FRAME
* or disabled by setting fSync to false
*/
@@ -23,11 +23,11 @@
class NetPipeReaderView : public SampleView {
public:
- NetPipeReaderView() {
+ NetPipeReaderView() {
fSocket = NULL;
fSync = true;
}
-
+
~NetPipeReaderView() {
if (fSocket) {
delete fSocket;
@@ -36,23 +36,23 @@ public:
}
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Net Pipe Reader");
- menu->appendTextField("Server IP", "Server IP", this->getSinkID(),
+ menu->appendTextField("Server IP", "Server IP", this->getSinkID(),
"IP address");
menu->appendSwitch("Sync", "Sync", this->getSinkID(), fSync);
}
-
+
protected:
static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
NetPipeReaderView* view = (NetPipeReaderView*)context;
view->onRead(data, size);
}
-
+
void onRead(const void* data, size_t size) {
if (size > 0)
fDataArray.append(size, (const char*)data);
}
-
+
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Net Pipe Reader");
@@ -76,7 +76,7 @@ protected:
return true;
return this->INHERITED::onEvent(evt);
}
-
+
void onDrawContent(SkCanvas* canvas) {
if (NULL == fSocket)
return;
@@ -85,7 +85,7 @@ protected:
int dataToRemove = fDataArray.count();
if (fSync) {
int numreads = 0;
- while (fSocket->readPacket(readData, this) > 0 &&
+ while (fSocket->readPacket(readData, this) > 0 &&
numreads < MAX_READS_PER_FRAME) {
// at this point, new data has been read and stored, discard
// old data since it's not needed anymore
@@ -95,18 +95,18 @@ protected:
++numreads;
}
// clean up if max reads reached
- if (numreads == MAX_READS_PER_FRAME &&
+ if (numreads == MAX_READS_PER_FRAME &&
fDataArray.count() > dataToRemove)
fDataArray.remove(0, dataToRemove);
}
else {
- if (fSocket->readPacket(readData, this) > 0)
+ if (fSocket->readPacket(readData, this) > 0)
fDataArray.remove(0, dataToRemove);
}
}
else
fSocket->connectToServer();
-
+
SkGPipeReader reader(canvas);
size_t bytesRead;
SkGPipeReader::Status fStatus = reader.playback(fDataArray.begin(),
diff --git a/experimental/Networking/SkSockets.cpp b/experimental/Networking/SkSockets.cpp
index 7b7d6fcff7..db9da09d4d 100644
--- a/experimental/Networking/SkSockets.cpp
+++ b/experimental/Networking/SkSockets.cpp
@@ -33,7 +33,7 @@ int SkSocket::createSocket() {
return -1;
}
int reuse = 1;
-
+
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int)) < 0) {
SkDebugf("error: %s\n", strerror(errno));
return -1;
@@ -49,10 +49,10 @@ int SkSocket::createSocket() {
void SkSocket::closeSocket(int sockfd) {
if (!fReady)
return;
-
+
close(sockfd);
//SkDebugf("Closed fd:%d\n", sockfd);
-
+
if (FD_ISSET(sockfd, &fMasterSet)) {
FD_CLR(sockfd, &fMasterSet);
if (sockfd >= fMaxfd) {
@@ -60,7 +60,7 @@ void SkSocket::closeSocket(int sockfd) {
fMaxfd -= 1;
}
}
- if (0 == fMaxfd)
+ if (0 == fMaxfd)
fConnected = false;
}
@@ -70,7 +70,7 @@ void SkSocket::onFailedConnection(int sockfd) {
void SkSocket::setNonBlocking(int sockfd) {
int flags = fcntl(sockfd, F_GETFL);
- fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
+ fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
}
void SkSocket::addToMasterSet(int sockfd) {
@@ -79,9 +79,9 @@ void SkSocket::addToMasterSet(int sockfd) {
fMaxfd = sockfd;
}
-int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType,
+int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType,
void*), void* context) {
- if (!fConnected || !fReady || NULL == onRead || NULL == context
+ if (!fConnected || !fReady || NULL == onRead || NULL == context
|| fReadSuspended)
return -1;
@@ -91,7 +91,7 @@ int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType,
for (int i = 0; i <= fMaxfd; ++i) {
if (!FD_ISSET (i, &fMasterSet))
continue;
-
+
memset(packet, 0, PACKET_SIZE);
SkDynamicMemoryWStream stream;
int attempts = 0;
@@ -155,13 +155,13 @@ int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType,
this->onFailedConnection(i);
continue;
}
-
+
if (bytesReadInTransfer > 0) {
SkData* data = stream.copyToData();
SkASSERT(data->size() == bytesReadInTransfer);
onRead(i, data->data(), data->size(), h.type, context);
data->unref();
-
+
totalBytesRead += bytesReadInTransfer;
}
}
@@ -312,7 +312,7 @@ int SkTCPServer::disconnectAll() {
SkTCPClient::SkTCPClient(const char* hostname, int port) {
//Add fSockfd since the client will be using it to read/write
this->addToMasterSet(fSockfd);
-
+
hostent* server = gethostbyname(hostname);
if (server) {
fServerAddr.sin_family = AF_INET;
diff --git a/experimental/Networking/SkSockets.h b/experimental/Networking/SkSockets.h
index a72f67d3a9..8d85446ecc 100644
--- a/experimental/Networking/SkSockets.h
+++ b/experimental/Networking/SkSockets.h
@@ -32,14 +32,14 @@ public:
kIncomplete_state,
kDone_state
};
-
+
enum DataType {
kPipeAppend_type,
kPipeReplace_type,
kString_type,
kInt_type
};
-
+
bool isConnected() { return fConnected; }
/**
* Write data to the socket. Data is a pointer to the beginning of the data
@@ -51,12 +51,12 @@ public:
* was an error during the transfer, in which case the method returns -1.
* For blocking sockets, write will block indefinitely if the socket at the
* other end of the connection doesn't receive any data.
- * NOTE: This method guarantees that all of the data will be sent unless
- * there was an error, so it may block temporarily when the write buffer is
+ * NOTE: This method guarantees that all of the data will be sent unless
+ * there was an error, so it may block temporarily when the write buffer is
* full
*/
int writePacket(void* data, size_t size, DataType type = kPipeAppend_type);
-
+
/**
* Read a logical packet from socket. The data read will be stored
* sequentially in the dataArray. This method will keep running until all
@@ -66,16 +66,16 @@ public:
* nonblocking sockets, read will return 0 if there's nothing to read. For
* blocking sockets, read will block indefinitely if the socket doesn't
* receive any data.
- * NOTE: This method guarantees that all the data in a logical packet will
+ * NOTE: This method guarantees that all the data in a logical packet will
* be read so it may block temporarily if it's waiting for parts of a
* packet
*/
- int readPacket(void (*onRead)(int cid, const void* data, size_t size,
+ int readPacket(void (*onRead)(int cid, const void* data, size_t size,
DataType type, void*), void* context);
/**
* Suspend network transfers until resume() is called. Leaves all
- * connections in tact.
+ * connections in tact.
*/
void suspendAll() { fReadSuspended = fWriteSuspended = true; }
/**
@@ -101,7 +101,7 @@ protected:
* Create a socket and return its file descriptor. Returns -1 on failure
*/
int createSocket();
-
+
/**
* Close the socket specified by the socket file descriptor argument. Will
* update fMaxfd and working set properly
@@ -119,7 +119,7 @@ protected:
* Set the socket specified by the socket file descriptor as nonblocking
*/
void setNonBlocking(int sockfd);
-
+
/**
* Add the socket specified by the socket file descriptor to the master
* file descriptor set, which is used to in the select() to detect new data
@@ -134,10 +134,10 @@ protected:
int fMaxfd;
int fPort;
int fSockfd;
-
- /**
+
+ /**
* fMasterSet contains all the file descriptors to be used for read/write.
- * For clients, this only contains the client socket. For servers, this
+ * For clients, this only contains the client socket. For servers, this
* contains all the file descriptors associated with established connections
* to clients
*/
@@ -156,7 +156,7 @@ public:
/**
* Accept any incoming connections to the server, will accept 1 connection
- * at a time. Returns -1 on error. For blocking sockets, this method will
+ * at a time. Returns -1 on error. For blocking sockets, this method will
* block until a client calls connectToServer()
*/
int acceptConnections();
@@ -179,15 +179,15 @@ public:
SkTCPClient(const char* hostname, int port = DEFAULT_PORT);
/**
- * Connect to server. Returns -1 on error or failure. Call this to connect
- * or reconnect to the server. For blocking sockets, this method will block
+ * Connect to server. Returns -1 on error or failure. Call this to connect
+ * or reconnect to the server. For blocking sockets, this method will block
* until the connection is accepted by the server.
*/
int connectToServer();
protected:
/**
- * Client needs to recreate the socket when a connection is broken because
- * connect can only be called successfully once.
+ * Client needs to recreate the socket when a connection is broken because
+ * connect can only be called successfully once.
*/
virtual void onFailedConnection(int sockfd);
private: