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

Side by Side Diff: net/quic/chromium/quic_chromium_client_session_test.cc

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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/quic/chromium/quic_chromium_client_session.h" 5 #include "net/quic/chromium/quic_chromium_client_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "net/base/test_completion_callback.h" 13 #include "net/base/test_completion_callback.h"
14 #include "net/cert/cert_verify_result.h" 14 #include "net/cert/cert_verify_result.h"
15 #include "net/http/transport_security_state.h" 15 #include "net/http/transport_security_state.h"
16 #include "net/log/net_log_source.h"
16 #include "net/log/test_net_log.h" 17 #include "net/log/test_net_log.h"
17 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" 18 #include "net/quic/chromium/crypto/proof_verifier_chromium.h"
18 #include "net/quic/chromium/quic_chromium_alarm_factory.h" 19 #include "net/quic/chromium/quic_chromium_alarm_factory.h"
19 #include "net/quic/chromium/quic_chromium_client_session_peer.h" 20 #include "net/quic/chromium/quic_chromium_client_session_peer.h"
20 #include "net/quic/chromium/quic_chromium_connection_helper.h" 21 #include "net/quic/chromium/quic_chromium_connection_helper.h"
21 #include "net/quic/chromium/quic_chromium_packet_reader.h" 22 #include "net/quic/chromium/quic_chromium_packet_reader.h"
22 #include "net/quic/chromium/quic_chromium_packet_writer.h" 23 #include "net/quic/chromium/quic_chromium_packet_writer.h"
23 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" 24 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h"
24 #include "net/quic/core/crypto/crypto_protocol.h" 25 #include "net/quic/core/crypto/crypto_protocol.h"
25 #include "net/quic/core/crypto/quic_decrypter.h" 26 #include "net/quic/core/crypto/quic_decrypter.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Perspective::IS_SERVER) { 98 Perspective::IS_SERVER) {
98 // Advance the time, because timers do not like uninitialized times. 99 // Advance the time, because timers do not like uninitialized times.
99 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 100 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
100 } 101 }
101 102
102 void Initialize() { 103 void Initialize() {
103 socket_factory_.AddSocketDataProvider(socket_data_.get()); 104 socket_factory_.AddSocketDataProvider(socket_data_.get());
104 std::unique_ptr<DatagramClientSocket> socket = 105 std::unique_ptr<DatagramClientSocket> socket =
105 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, 106 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND,
106 base::Bind(&base::RandInt), 107 base::Bind(&base::RandInt),
107 &net_log_, NetLog::Source()); 108 &net_log_, NetLogSource());
108 socket->Connect(kIpEndPoint); 109 socket->Connect(kIpEndPoint);
109 QuicChromiumPacketWriter* writer = 110 QuicChromiumPacketWriter* writer =
110 new net::QuicChromiumPacketWriter(socket.get()); 111 new net::QuicChromiumPacketWriter(socket.get());
111 QuicConnection* connection = new QuicConnection( 112 QuicConnection* connection = new QuicConnection(
112 0, kIpEndPoint, &helper_, &alarm_factory_, writer, true, 113 0, kIpEndPoint, &helper_, &alarm_factory_, writer, true,
113 Perspective::IS_CLIENT, SupportedVersions(GetParam())); 114 Perspective::IS_CLIENT, SupportedVersions(GetParam()));
114 session_.reset(new QuicChromiumClientSession( 115 session_.reset(new QuicChromiumClientSession(
115 connection, std::move(socket), 116 connection, std::move(socket),
116 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_, 117 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_,
117 &transport_security_state_, 118 &transport_security_state_,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 MockWrite(SYNCHRONOUS, ack_and_data_out->data(), 407 MockWrite(SYNCHRONOUS, ack_and_data_out->data(),
407 ack_and_data_out->length(), 3)}; 408 ack_and_data_out->length(), 3)};
408 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, 409 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
409 arraysize(writes)); 410 arraysize(writes));
410 socket_factory_.AddSocketDataProvider(&socket_data); 411 socket_factory_.AddSocketDataProvider(&socket_data);
411 412
412 // Create connected socket. 413 // Create connected socket.
413 std::unique_ptr<DatagramClientSocket> new_socket = 414 std::unique_ptr<DatagramClientSocket> new_socket =
414 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, 415 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND,
415 base::Bind(&base::RandInt), 416 base::Bind(&base::RandInt),
416 &net_log_, NetLog::Source()); 417 &net_log_, NetLogSource());
417 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); 418 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk());
418 419
419 // Create reader and writer. 420 // Create reader and writer.
420 std::unique_ptr<QuicChromiumPacketReader> new_reader( 421 std::unique_ptr<QuicChromiumPacketReader> new_reader(
421 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), 422 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(),
422 kQuicYieldAfterPacketsRead, 423 kQuicYieldAfterPacketsRead,
423 QuicTime::Delta::FromMilliseconds( 424 QuicTime::Delta::FromMilliseconds(
424 kQuicYieldAfterDurationMilliseconds), 425 kQuicYieldAfterDurationMilliseconds),
425 bound_test_net_log_.bound())); 426 bound_test_net_log_.bound()));
426 std::unique_ptr<QuicChromiumPacketWriter> new_writer( 427 std::unique_ptr<QuicChromiumPacketWriter> new_writer(
(...skipping 29 matching lines...) Expand all
456 MockWrite writes[] = { 457 MockWrite writes[] = {
457 MockWrite(SYNCHRONOUS, ping_out->data(), ping_out->length(), i + 2)}; 458 MockWrite(SYNCHRONOUS, ping_out->data(), ping_out->length(), i + 2)};
458 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, 459 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
459 arraysize(writes)); 460 arraysize(writes));
460 socket_factory_.AddSocketDataProvider(&socket_data); 461 socket_factory_.AddSocketDataProvider(&socket_data);
461 462
462 // Create connected socket. 463 // Create connected socket.
463 std::unique_ptr<DatagramClientSocket> new_socket = 464 std::unique_ptr<DatagramClientSocket> new_socket =
464 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, 465 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND,
465 base::Bind(&base::RandInt), 466 base::Bind(&base::RandInt),
466 &net_log_, NetLog::Source()); 467 &net_log_, NetLogSource());
467 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); 468 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk());
468 469
469 // Create reader and writer. 470 // Create reader and writer.
470 std::unique_ptr<QuicChromiumPacketReader> new_reader( 471 std::unique_ptr<QuicChromiumPacketReader> new_reader(
471 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), 472 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(),
472 kQuicYieldAfterPacketsRead, 473 kQuicYieldAfterPacketsRead,
473 QuicTime::Delta::FromMilliseconds( 474 QuicTime::Delta::FromMilliseconds(
474 kQuicYieldAfterDurationMilliseconds), 475 kQuicYieldAfterDurationMilliseconds),
475 bound_test_net_log_.bound())); 476 bound_test_net_log_.bound()));
476 std::unique_ptr<QuicChromiumPacketWriter> new_writer( 477 std::unique_ptr<QuicChromiumPacketWriter> new_writer(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 MockRead(ASYNC, ERR_IO_PENDING, 4), // pause reading 518 MockRead(ASYNC, ERR_IO_PENDING, 4), // pause reading
518 MockRead(ASYNC, ERR_NETWORK_CHANGED, 5)}; 519 MockRead(ASYNC, ERR_NETWORK_CHANGED, 5)};
519 SequencedSocketData new_socket_data(new_reads, arraysize(new_reads), writes, 520 SequencedSocketData new_socket_data(new_reads, arraysize(new_reads), writes,
520 arraysize(writes)); 521 arraysize(writes));
521 socket_factory_.AddSocketDataProvider(&new_socket_data); 522 socket_factory_.AddSocketDataProvider(&new_socket_data);
522 523
523 // Create connected socket. 524 // Create connected socket.
524 std::unique_ptr<DatagramClientSocket> new_socket = 525 std::unique_ptr<DatagramClientSocket> new_socket =
525 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, 526 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND,
526 base::Bind(&base::RandInt), 527 base::Bind(&base::RandInt),
527 &net_log_, NetLog::Source()); 528 &net_log_, NetLogSource());
528 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); 529 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk());
529 530
530 // Create reader and writer. 531 // Create reader and writer.
531 std::unique_ptr<QuicChromiumPacketReader> new_reader( 532 std::unique_ptr<QuicChromiumPacketReader> new_reader(
532 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), 533 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(),
533 kQuicYieldAfterPacketsRead, 534 kQuicYieldAfterPacketsRead,
534 QuicTime::Delta::FromMilliseconds( 535 QuicTime::Delta::FromMilliseconds(
535 kQuicYieldAfterDurationMilliseconds), 536 kQuicYieldAfterDurationMilliseconds),
536 bound_test_net_log_.bound())); 537 bound_test_net_log_.bound()));
537 std::unique_ptr<QuicChromiumPacketWriter> new_writer( 538 std::unique_ptr<QuicChromiumPacketWriter> new_writer(
(...skipping 20 matching lines...) Expand all
558 559
559 EXPECT_TRUE(socket_data_->AllReadDataConsumed()); 560 EXPECT_TRUE(socket_data_->AllReadDataConsumed());
560 EXPECT_TRUE(socket_data_->AllWriteDataConsumed()); 561 EXPECT_TRUE(socket_data_->AllWriteDataConsumed());
561 EXPECT_TRUE(new_socket_data.AllReadDataConsumed()); 562 EXPECT_TRUE(new_socket_data.AllReadDataConsumed());
562 EXPECT_TRUE(new_socket_data.AllWriteDataConsumed()); 563 EXPECT_TRUE(new_socket_data.AllWriteDataConsumed());
563 } 564 }
564 565
565 } // namespace 566 } // namespace
566 } // namespace test 567 } // namespace test
567 } // namespace net 568 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698