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

Side by Side Diff: test/cctest/test-sockets.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-spaces.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 2
3 #include "v8.h" 3 #include "v8.h"
4 #include "platform.h" 4 #include "platform.h"
5 #include "cctest.h" 5 #include "cctest.h"
6 6
7 7
8 using namespace ::v8::internal; 8 using namespace ::v8::internal;
9 9
10 10
11 class SocketListenerThread : public Thread { 11 class SocketListenerThread : public Thread {
12 public: 12 public:
13 explicit SocketListenerThread(int port, int data_size) 13 explicit SocketListenerThread(Isolate* isolate, int port, int data_size)
14 : port_(port), data_size_(data_size), server_(NULL), client_(NULL), 14 : Thread(isolate), port_(port), data_size_(data_size), server_(NULL),
15 listening_(OS::CreateSemaphore(0)) { 15 client_(NULL), listening_(OS::CreateSemaphore(0)) {
16 data_ = new char[data_size_]; 16 data_ = new char[data_size_];
17 } 17 }
18 ~SocketListenerThread() { 18 ~SocketListenerThread() {
19 // Close both sockets. 19 // Close both sockets.
20 delete client_; 20 delete client_;
21 delete server_; 21 delete server_;
22 delete listening_; 22 delete listening_;
23 delete[] data_; 23 delete[] data_;
24 } 24 }
25 25
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 static const char* kLocalhost = "localhost"; 81 static const char* kLocalhost = "localhost";
82 82
83 bool ok; 83 bool ok;
84 84
85 // Make a string with the port number. 85 // Make a string with the port number.
86 const int kPortBuferLen = 6; 86 const int kPortBuferLen = 6;
87 char port_str[kPortBuferLen]; 87 char port_str[kPortBuferLen];
88 OS::SNPrintF(Vector<char>(port_str, kPortBuferLen), "%d", port); 88 OS::SNPrintF(Vector<char>(port_str, kPortBuferLen), "%d", port);
89 89
90 // Create a socket listener. 90 // Create a socket listener.
91 SocketListenerThread* listener = new SocketListenerThread(port, len); 91 SocketListenerThread* listener = new SocketListenerThread(Isolate::Current(),
92 port, len);
92 listener->Start(); 93 listener->Start();
93 listener->WaitForListening(); 94 listener->WaitForListening();
94 95
95 // Connect and write some data. 96 // Connect and write some data.
96 Socket* client = OS::CreateSocket(); 97 Socket* client = OS::CreateSocket();
97 CHECK(client != NULL); 98 CHECK(client != NULL);
98 ok = client->Connect(kLocalhost, port_str); 99 ok = client->Connect(kLocalhost, port_str);
99 CHECK(ok); 100 CHECK(ok);
100 101
101 // Send all the data. 102 // Send all the data.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 154 }
154 155
155 156
156 TEST(HToNNToH) { 157 TEST(HToNNToH) {
157 uint16_t x = 1234; 158 uint16_t x = 1234;
158 CHECK_EQ(x, Socket::NToH(Socket::HToN(x))); 159 CHECK_EQ(x, Socket::NToH(Socket::HToN(x)));
159 160
160 uint32_t y = 12345678; 161 uint32_t y = 12345678;
161 CHECK(y == Socket::NToH(Socket::HToN(y))); 162 CHECK(y == Socket::NToH(Socket::HToN(y)));
162 } 163 }
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698