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

Side by Side Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 131743007: Remove WritePacket() from internal server's QuicDispatcher; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_packet_writer_wrapper.h » ('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/tools/quic/quic_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
(...skipping 24 matching lines...) Expand all
35 namespace net { 35 namespace net {
36 namespace tools { 36 namespace tools {
37 namespace test { 37 namespace test {
38 namespace { 38 namespace {
39 39
40 class TestDispatcher : public QuicDispatcher { 40 class TestDispatcher : public QuicDispatcher {
41 public: 41 public:
42 explicit TestDispatcher(const QuicConfig& config, 42 explicit TestDispatcher(const QuicConfig& config,
43 const QuicCryptoServerConfig& crypto_config, 43 const QuicCryptoServerConfig& crypto_config,
44 EpollServer* eps) 44 EpollServer* eps)
45 : QuicDispatcher(config, crypto_config, QuicSupportedVersions(), 1, eps) { 45 : QuicDispatcher(config, crypto_config, QuicSupportedVersions(), eps) {
46 } 46 }
47 47
48 MOCK_METHOD3(CreateQuicSession, QuicSession*( 48 MOCK_METHOD3(CreateQuicSession, QuicSession*(
49 QuicGuid guid, 49 QuicGuid guid,
50 const IPEndPoint& server_address, 50 const IPEndPoint& server_address,
51 const IPEndPoint& client_address)); 51 const IPEndPoint& client_address));
52 using QuicDispatcher::write_blocked_list; 52 using QuicDispatcher::write_blocked_list;
53 }; 53 };
54 54
55 // A Connection class which unregisters the session from the dispatcher 55 // A Connection class which unregisters the session from the dispatcher
56 // when sending connection close. 56 // when sending connection close.
57 // It'd be slightly more realistic to do this from the Session but it would 57 // It'd be slightly more realistic to do this from the Session but it would
58 // involve a lot more mocking. 58 // involve a lot more mocking.
59 class MockServerConnection : public MockConnection { 59 class MockServerConnection : public MockConnection {
60 public: 60 public:
61 MockServerConnection(QuicGuid guid, 61 MockServerConnection(QuicGuid guid,
62 QuicDispatcher* dispatcher) 62 QuicDispatcher* dispatcher)
63 : MockConnection(guid, true), 63 : MockConnection(guid, true),
64 dispatcher_(dispatcher) { 64 dispatcher_(dispatcher) {}
65 } 65
66 void UnregisterOnConnectionClosed() { 66 void UnregisterOnConnectionClosed() {
67 LOG(ERROR) << "Unregistering " << guid(); 67 LOG(ERROR) << "Unregistering " << guid();
68 dispatcher_->OnConnectionClosed(guid(), QUIC_NO_ERROR); 68 dispatcher_->OnConnectionClosed(guid(), QUIC_NO_ERROR);
69 } 69 }
70 private: 70 private:
71 QuicDispatcher* dispatcher_; 71 QuicDispatcher* dispatcher_;
72 }; 72 };
73 73
74 QuicSession* CreateSession(QuicDispatcher* dispatcher, 74 QuicSession* CreateSession(QuicDispatcher* dispatcher,
75 QuicGuid guid, 75 QuicGuid guid,
(...skipping 11 matching lines...) Expand all
87 } 87 }
88 88
89 class QuicDispatcherTest : public ::testing::Test { 89 class QuicDispatcherTest : public ::testing::Test {
90 public: 90 public:
91 QuicDispatcherTest() 91 QuicDispatcherTest()
92 : crypto_config_(QuicCryptoServerConfig::TESTING, 92 : crypto_config_(QuicCryptoServerConfig::TESTING,
93 QuicRandom::GetInstance()), 93 QuicRandom::GetInstance()),
94 dispatcher_(config_, crypto_config_, &eps_), 94 dispatcher_(config_, crypto_config_, &eps_),
95 session1_(NULL), 95 session1_(NULL),
96 session2_(NULL) { 96 session2_(NULL) {
97 dispatcher_.Initialize(1);
97 } 98 }
98 99
99 virtual ~QuicDispatcherTest() {} 100 virtual ~QuicDispatcherTest() {}
100 101
101 MockConnection* connection1() { 102 MockConnection* connection1() {
102 return reinterpret_cast<MockConnection*>(session1_->connection()); 103 return reinterpret_cast<MockConnection*>(session1_->connection());
103 } 104 }
104 105
105 MockConnection* connection2() { 106 MockConnection* connection2() {
106 return reinterpret_cast<MockConnection*>(session2_->connection()); 107 return reinterpret_cast<MockConnection*>(session2_->connection());
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 443
443 // And we'll resume where we left off when we get another call. 444 // And we'll resume where we left off when we get another call.
444 EXPECT_CALL(*connection2(), OnCanWrite()); 445 EXPECT_CALL(*connection2(), OnCanWrite());
445 dispatcher_.OnCanWrite(); 446 dispatcher_.OnCanWrite();
446 } 447 }
447 448
448 } // namespace 449 } // namespace
449 } // namespace test 450 } // namespace test
450 } // namespace tools 451 } // namespace tools
451 } // namespace net 452 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_packet_writer_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698