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

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

Issue 1327923002: Migrates QUIC sessions to a new network when old network is (about to be) disconnected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@home
Patch Set: More tests added and some fixes. Created 4 years, 11 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 "net/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 #include "net/ssl/ssl_cert_request_info.h" 28 #include "net/ssl/ssl_cert_request_info.h"
29 #include "net/ssl/ssl_connection_status_flags.h" 29 #include "net/ssl/ssl_connection_status_flags.h"
30 #include "net/ssl/ssl_failure_state.h" 30 #include "net/ssl/ssl_failure_state.h"
31 #include "net/ssl/ssl_info.h" 31 #include "net/ssl/ssl_info.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 33
34 #define NET_TRACE(level, s) VLOG(level) << s << __FUNCTION__ << "() " 34 #define NET_TRACE(level, s) VLOG(level) << s << __FUNCTION__ << "() "
35 35
36 namespace net { 36 namespace net {
37 37
38 NET_EXPORT NetworkChangeNotifier::NetworkHandle kDefaultNetworkForTests = 1;
39 NET_EXPORT NetworkChangeNotifier::NetworkHandle kNewNetworkForTests = 2;
Ryan Hamilton 2015/12/29 05:29:36 Is this used?
Jana 2016/01/06 23:01:17 It's used in the tests, but I declared it here wit
40
38 namespace { 41 namespace {
39 42
40 inline char AsciifyHigh(char x) { 43 inline char AsciifyHigh(char x) {
41 char nybble = static_cast<char>((x >> 4) & 0x0F); 44 char nybble = static_cast<char>((x >> 4) & 0x0F);
42 return nybble + ((nybble < 0x0A) ? '0' : 'A' - 10); 45 return nybble + ((nybble < 0x0A) ? '0' : 'A' - 10);
43 } 46 }
44 47
45 inline char AsciifyLow(char x) { 48 inline char AsciifyLow(char x) {
46 char nybble = static_cast<char>((x >> 0) & 0x0F); 49 char nybble = static_cast<char>((x >> 0) & 0x0F);
47 return nybble + ((nybble < 0x0A) ? '0' : 'A' - 10); 50 return nybble + ((nybble < 0x0A) ? '0' : 'A' - 10);
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 } 1239 }
1237 1240
1238 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data, 1241 MockUDPClientSocket::MockUDPClientSocket(SocketDataProvider* data,
1239 net::NetLog* net_log) 1242 net::NetLog* net_log)
1240 : connected_(false), 1243 : connected_(false),
1241 data_(data), 1244 data_(data),
1242 read_offset_(0), 1245 read_offset_(0),
1243 read_data_(SYNCHRONOUS, ERR_UNEXPECTED), 1246 read_data_(SYNCHRONOUS, ERR_UNEXPECTED),
1244 need_read_data_(true), 1247 need_read_data_(true),
1245 source_port_(123), 1248 source_port_(123),
1249 network_(NetworkChangeNotifier::kInvalidNetworkHandle),
1246 pending_read_buf_(NULL), 1250 pending_read_buf_(NULL),
1247 pending_read_buf_len_(0), 1251 pending_read_buf_len_(0),
1248 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_NONE)), 1252 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_NONE)),
1249 weak_factory_(this) { 1253 weak_factory_(this) {
1250 DCHECK(data_); 1254 DCHECK(data_);
1251 data_->Initialize(this); 1255 data_->Initialize(this);
1252 peer_addr_ = data->connect_data().peer_addr; 1256 peer_addr_ = data->connect_data().peer_addr;
1253 } 1257 }
1254 1258
1255 MockUDPClientSocket::~MockUDPClientSocket() { 1259 MockUDPClientSocket::~MockUDPClientSocket() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 *address = IPEndPoint(ip, source_port_); 1338 *address = IPEndPoint(ip, source_port_);
1335 return OK; 1339 return OK;
1336 } 1340 }
1337 1341
1338 const BoundNetLog& MockUDPClientSocket::NetLog() const { 1342 const BoundNetLog& MockUDPClientSocket::NetLog() const {
1339 return net_log_; 1343 return net_log_;
1340 } 1344 }
1341 1345
1342 int MockUDPClientSocket::BindToNetwork( 1346 int MockUDPClientSocket::BindToNetwork(
1343 NetworkChangeNotifier::NetworkHandle network) { 1347 NetworkChangeNotifier::NetworkHandle network) {
1344 return ERR_NOT_IMPLEMENTED; 1348 network_ = network;
1349 return OK;
1345 } 1350 }
1346 1351
1347 int MockUDPClientSocket::BindToDefaultNetwork() { 1352 int MockUDPClientSocket::BindToDefaultNetwork() {
1348 return ERR_NOT_IMPLEMENTED; 1353 network_ = kDefaultNetworkForTests;
1354 return OK;
1349 } 1355 }
1350 1356
1351 NetworkChangeNotifier::NetworkHandle MockUDPClientSocket::GetBoundNetwork() 1357 NetworkChangeNotifier::NetworkHandle MockUDPClientSocket::GetBoundNetwork()
1352 const { 1358 const {
1353 return NetworkChangeNotifier::kInvalidNetworkHandle; 1359 return network_;
1354 } 1360 }
1355 1361
1356 int MockUDPClientSocket::Connect(const IPEndPoint& address) { 1362 int MockUDPClientSocket::Connect(const IPEndPoint& address) {
1357 if (!data_) 1363 if (!data_)
1358 return ERR_UNEXPECTED; 1364 return ERR_UNEXPECTED;
1359 connected_ = true; 1365 connected_ = true;
1360 peer_addr_ = address; 1366 peer_addr_ = address;
1361 return data_->connect_data().result; 1367 return data_->connect_data().result;
1362 } 1368 }
1363 1369
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 } 1702 }
1697 1703
1698 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { 1704 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) {
1699 int64_t total = 0; 1705 int64_t total = 0;
1700 for (const MockWrite* write = writes; write != writes + writes_size; ++write) 1706 for (const MockWrite* write = writes; write != writes + writes_size; ++write)
1701 total += write->data_len; 1707 total += write->data_len;
1702 return total; 1708 return total;
1703 } 1709 }
1704 1710
1705 } // namespace net 1711 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698