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

Side by Side Diff: remoting/protocol/connection_tester.cc

Issue 8930016: Fix valgrind warning in remoting_unittests due to uninitialized memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "remoting/protocol/connection_tester.h" 5 #include "remoting/protocol/connection_tester.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 void StreamConnectionTester::Done() { 54 void StreamConnectionTester::Done() {
55 done_ = true; 55 done_ = true;
56 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 56 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
57 } 57 }
58 58
59 void StreamConnectionTester::InitBuffers() { 59 void StreamConnectionTester::InitBuffers() {
60 output_buffer_ = new net::DrainableIOBuffer( 60 output_buffer_ = new net::DrainableIOBuffer(
61 new net::IOBuffer(test_data_size_), test_data_size_); 61 new net::IOBuffer(test_data_size_), test_data_size_);
62 for (int i = 0; i < test_data_size_; ++i) {
63 output_buffer_->data()[i] = static_cast<char>(i);
64 }
62 65
63 input_buffer_ = new net::GrowableIOBuffer(); 66 input_buffer_ = new net::GrowableIOBuffer();
64 } 67 }
65 68
66 void StreamConnectionTester::DoWrite() { 69 void StreamConnectionTester::DoWrite() {
67 int result = 1; 70 int result = 1;
68 while (result > 0) { 71 while (result > 0) {
69 if (output_buffer_->BytesRemaining() == 0) 72 if (output_buffer_->BytesRemaining() == 0)
70 break; 73 break;
71 74
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 171 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
169 } 172 }
170 173
171 void DatagramConnectionTester::DoWrite() { 174 void DatagramConnectionTester::DoWrite() {
172 if (packets_sent_ >= message_count_) { 175 if (packets_sent_ >= message_count_) {
173 Done(); 176 Done();
174 return; 177 return;
175 } 178 }
176 179
177 scoped_refptr<net::IOBuffer> packet(new net::IOBuffer(message_size_)); 180 scoped_refptr<net::IOBuffer> packet(new net::IOBuffer(message_size_));
178 memset(packet->data(), 123, message_size_); 181 for (int i = 0; i < message_size_; ++i) {
182 packet->data()[i] = static_cast<char>(i);
183 }
179 sent_packets_[packets_sent_] = packet; 184 sent_packets_[packets_sent_] = packet;
180 // Put index of this packet in the beginning of the packet body. 185 // Put index of this packet in the beginning of the packet body.
181 memcpy(packet->data(), &packets_sent_, sizeof(packets_sent_)); 186 memcpy(packet->data(), &packets_sent_, sizeof(packets_sent_));
182 187
183 int result = client_socket_->Write( 188 int result = client_socket_->Write(
184 packet, message_size_, 189 packet, message_size_,
185 base::Bind(&DatagramConnectionTester::OnWritten, base::Unretained(this))); 190 base::Bind(&DatagramConnectionTester::OnWritten, base::Unretained(this)));
186 HandleWriteResult(result); 191 HandleWriteResult(result);
187 } 192 }
188 193
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(), 247 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(),
243 message_size_) != 0) 248 message_size_) != 0)
244 bad_packets_received_++; 249 bad_packets_received_++;
245 } 250 }
246 } 251 }
247 } 252 }
248 } 253 }
249 254
250 } // namespace protocol 255 } // namespace protocol
251 } // namespace remoting 256 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698