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

Side by Side Diff: net/socket/tcp_server_socket_unittest.cc

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/tcp_server_socket.h" 5 #include "net/socket/tcp_server_socket.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 const std::string message("test message"); 213 const std::string message("test message");
214 std::vector<char> buffer(message.size()); 214 std::vector<char> buffer(message.size());
215 215
216 size_t bytes_written = 0; 216 size_t bytes_written = 0;
217 while (bytes_written < message.size()) { 217 while (bytes_written < message.size()) {
218 scoped_refptr<net::IOBufferWithSize> write_buffer( 218 scoped_refptr<net::IOBufferWithSize> write_buffer(
219 new net::IOBufferWithSize(message.size() - bytes_written)); 219 new net::IOBufferWithSize(message.size() - bytes_written));
220 memmove(write_buffer->data(), message.data(), message.size()); 220 memmove(write_buffer->data(), message.data(), message.size());
221 221
222 TestCompletionCallback write_callback; 222 TestCompletionCallback write_callback;
223 int write_result = accepted_socket->Write(write_buffer, 223 int write_result = accepted_socket->Write(
224 write_buffer->size(), 224 write_buffer.get(), write_buffer->size(), write_callback.callback());
225 write_callback.callback());
226 write_result = write_callback.GetResult(write_result); 225 write_result = write_callback.GetResult(write_result);
227 ASSERT_TRUE(write_result >= 0); 226 ASSERT_TRUE(write_result >= 0);
228 ASSERT_TRUE(bytes_written + write_result <= message.size()); 227 ASSERT_TRUE(bytes_written + write_result <= message.size());
229 bytes_written += write_result; 228 bytes_written += write_result;
230 } 229 }
231 230
232 size_t bytes_read = 0; 231 size_t bytes_read = 0;
233 while (bytes_read < message.size()) { 232 while (bytes_read < message.size()) {
234 scoped_refptr<net::IOBufferWithSize> read_buffer( 233 scoped_refptr<net::IOBufferWithSize> read_buffer(
235 new net::IOBufferWithSize(message.size() - bytes_read)); 234 new net::IOBufferWithSize(message.size() - bytes_read));
236 TestCompletionCallback read_callback; 235 TestCompletionCallback read_callback;
237 int read_result = connecting_socket.Read(read_buffer, 236 int read_result = connecting_socket.Read(
238 read_buffer->size(), 237 read_buffer.get(), read_buffer->size(), read_callback.callback());
239 read_callback.callback());
240 read_result = read_callback.GetResult(read_result); 238 read_result = read_callback.GetResult(read_result);
241 ASSERT_TRUE(read_result >= 0); 239 ASSERT_TRUE(read_result >= 0);
242 ASSERT_TRUE(bytes_read + read_result <= message.size()); 240 ASSERT_TRUE(bytes_read + read_result <= message.size());
243 memmove(&buffer[bytes_read], read_buffer->data(), read_result); 241 memmove(&buffer[bytes_read], read_buffer->data(), read_result);
244 bytes_read += read_result; 242 bytes_read += read_result;
245 } 243 }
246 244
247 std::string received_message(buffer.begin(), buffer.end()); 245 std::string received_message(buffer.begin(), buffer.end());
248 ASSERT_EQ(message, received_message); 246 ASSERT_EQ(message, received_message);
249 } 247 }
250 248
251 } // namespace 249 } // namespace
252 250
253 } // namespace net 251 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_listen_socket_unittest.cc ('k') | net/socket/transport_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698