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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/socket/ssl_server_socket_nss.cc ('k') | net/spdy/spdy_http_stream.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 (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(write_buffer.get(),
224 write_buffer->size(), 224 write_buffer->size(),
225 write_callback.callback()); 225 write_callback.callback());
226 write_result = write_callback.GetResult(write_result); 226 write_result = write_callback.GetResult(write_result);
227 ASSERT_TRUE(write_result >= 0); 227 ASSERT_TRUE(write_result >= 0);
228 ASSERT_TRUE(bytes_written + write_result <= message.size()); 228 ASSERT_TRUE(bytes_written + write_result <= message.size());
229 bytes_written += write_result; 229 bytes_written += write_result;
230 } 230 }
231 231
232 size_t bytes_read = 0; 232 size_t bytes_read = 0;
233 while (bytes_read < message.size()) { 233 while (bytes_read < message.size()) {
234 scoped_refptr<net::IOBufferWithSize> read_buffer( 234 scoped_refptr<net::IOBufferWithSize> read_buffer(
235 new net::IOBufferWithSize(message.size() - bytes_read)); 235 new net::IOBufferWithSize(message.size() - bytes_read));
236 TestCompletionCallback read_callback; 236 TestCompletionCallback read_callback;
237 int read_result = connecting_socket.Read(read_buffer, 237 int read_result = connecting_socket.Read(read_buffer.get(),
238 read_buffer->size(), 238 read_buffer->size(),
239 read_callback.callback()); 239 read_callback.callback());
240 read_result = read_callback.GetResult(read_result); 240 read_result = read_callback.GetResult(read_result);
241 ASSERT_TRUE(read_result >= 0); 241 ASSERT_TRUE(read_result >= 0);
242 ASSERT_TRUE(bytes_read + read_result <= message.size()); 242 ASSERT_TRUE(bytes_read + read_result <= message.size());
243 memmove(&buffer[bytes_read], read_buffer->data(), read_result); 243 memmove(&buffer[bytes_read], read_buffer->data(), read_result);
244 bytes_read += read_result; 244 bytes_read += read_result;
245 } 245 }
246 246
247 std::string received_message(buffer.begin(), buffer.end()); 247 std::string received_message(buffer.begin(), buffer.end());
248 ASSERT_EQ(message, received_message); 248 ASSERT_EQ(message, received_message);
249 } 249 }
250 250
251 } // namespace 251 } // namespace
252 252
253 } // namespace net 253 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_nss.cc ('k') | net/spdy/spdy_http_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698