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

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

Issue 1197853003: Add P2PDatagramSocket and P2PStreamSocket interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "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/message_loop.h" 8 #include "base/message_loop/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"
11 #include "net/socket/stream_socket.h" 11 #include "remoting/protocol/p2p_socket.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 namespace protocol { 15 namespace protocol {
16 16
17 StreamConnectionTester::StreamConnectionTester(net::StreamSocket* client_socket, 17 StreamConnectionTester::StreamConnectionTester(P2PStreamSocket* client_socket,
18 net::StreamSocket* host_socket, 18 P2PStreamSocket* host_socket,
19 int message_size, 19 int message_size,
20 int message_count) 20 int message_count)
21 : message_loop_(base::MessageLoop::current()), 21 : message_loop_(base::MessageLoop::current()),
22 host_socket_(host_socket), 22 host_socket_(host_socket),
23 client_socket_(client_socket), 23 client_socket_(client_socket),
24 message_size_(message_size), 24 message_size_(message_size),
25 test_data_size_(message_size * message_count), 25 test_data_size_(message_size * message_count),
26 done_(false), 26 done_(false),
27 write_errors_(0), 27 write_errors_(0),
28 read_errors_(0) { 28 read_errors_(0) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 read_errors_++; 120 read_errors_++;
121 Done(); 121 Done();
122 } else if (result > 0) { 122 } else if (result > 0) {
123 // Allocate memory for the next read. 123 // Allocate memory for the next read.
124 input_buffer_->set_offset(input_buffer_->offset() + result); 124 input_buffer_->set_offset(input_buffer_->offset() + result);
125 if (input_buffer_->offset() == test_data_size_) 125 if (input_buffer_->offset() == test_data_size_)
126 Done(); 126 Done();
127 } 127 }
128 } 128 }
129 129
130 DatagramConnectionTester::DatagramConnectionTester(net::Socket* client_socket, 130 DatagramConnectionTester::DatagramConnectionTester(
131 net::Socket* host_socket, 131 P2PDatagramSocket* client_socket,
132 int message_size, 132 P2PDatagramSocket* host_socket,
133 int message_count, 133 int message_size,
134 int delay_ms) 134 int message_count,
135 int delay_ms)
135 : message_loop_(base::MessageLoop::current()), 136 : message_loop_(base::MessageLoop::current()),
136 host_socket_(host_socket), 137 host_socket_(host_socket),
137 client_socket_(client_socket), 138 client_socket_(client_socket),
138 message_size_(message_size), 139 message_size_(message_size),
139 message_count_(message_count), 140 message_count_(message_count),
140 delay_ms_(delay_ms), 141 delay_ms_(delay_ms),
141 done_(false), 142 done_(false),
142 write_errors_(0), 143 write_errors_(0),
143 read_errors_(0), 144 read_errors_(0),
144 packets_sent_(0), 145 packets_sent_(0),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(), 253 if (memcmp(read_buffer_->data(), sent_packets_[packet_id]->data(),
253 message_size_) != 0) 254 message_size_) != 0)
254 bad_packets_received_++; 255 bad_packets_received_++;
255 } 256 }
256 } 257 }
257 } 258 }
258 } 259 }
259 260
260 } // namespace protocol 261 } // namespace protocol
261 } // namespace remoting 262 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698