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

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

Issue 468373002: Patch set 2 of Daniel Ziegler's CL Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Suggested changes. Created 6 years, 4 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_per_connection_packet_writer.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 30 matching lines...) Expand all
41 namespace { 41 namespace {
42 42
43 class TestDispatcher : public QuicDispatcher { 43 class TestDispatcher : public QuicDispatcher {
44 public: 44 public:
45 explicit TestDispatcher(const QuicConfig& config, 45 explicit TestDispatcher(const QuicConfig& config,
46 const QuicCryptoServerConfig& crypto_config, 46 const QuicCryptoServerConfig& crypto_config,
47 EpollServer* eps) 47 EpollServer* eps)
48 : QuicDispatcher(config, 48 : QuicDispatcher(config,
49 crypto_config, 49 crypto_config,
50 QuicSupportedVersions(), 50 QuicSupportedVersions(),
51 new QuicDispatcher::DefaultPacketWriterFactory(),
51 eps) { 52 eps) {
52 } 53 }
53 54
54 MOCK_METHOD3(CreateQuicSession, QuicSession*( 55 MOCK_METHOD3(CreateQuicSession, QuicSession*(
55 QuicConnectionId connection_id, 56 QuicConnectionId connection_id,
56 const IPEndPoint& server_address, 57 const IPEndPoint& server_address,
57 const IPEndPoint& client_address)); 58 const IPEndPoint& client_address));
58 59
59 using QuicDispatcher::current_server_address; 60 using QuicDispatcher::current_server_address;
60 using QuicDispatcher::current_client_address; 61 using QuicDispatcher::current_client_address;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 BlockingWriter() : write_blocked_(false) {} 265 BlockingWriter() : write_blocked_(false) {}
265 266
266 virtual bool IsWriteBlocked() const OVERRIDE { return write_blocked_; } 267 virtual bool IsWriteBlocked() const OVERRIDE { return write_blocked_; }
267 virtual void SetWritable() OVERRIDE { write_blocked_ = false; } 268 virtual void SetWritable() OVERRIDE { write_blocked_ = false; }
268 269
269 virtual WriteResult WritePacket( 270 virtual WriteResult WritePacket(
270 const char* buffer, 271 const char* buffer,
271 size_t buf_len, 272 size_t buf_len,
272 const IPAddressNumber& self_client_address, 273 const IPAddressNumber& self_client_address,
273 const IPEndPoint& peer_client_address) OVERRIDE { 274 const IPEndPoint& peer_client_address) OVERRIDE {
274 if (write_blocked_) { 275 // It would be quite possible to actually implement this method here with
275 return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN); 276 // the fake blocked status, but it would be significantly more work in
276 } else { 277 // Chromium, and since it's not called anyway, don't bother.
277 return QuicPacketWriterWrapper::WritePacket( 278 LOG(DFATAL) << "Not supported";
278 buffer, buf_len, self_client_address, peer_client_address); 279 return WriteResult();
279 }
280 } 280 }
281 281
282 bool write_blocked_; 282 bool write_blocked_;
283 }; 283 };
284 284
285 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest { 285 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest {
286 public: 286 public:
287 virtual void SetUp() { 287 virtual void SetUp() {
288 writer_ = new BlockingWriter; 288 writer_ = new BlockingWriter;
289 QuicDispatcherPeer::SetPacketWriterFactory(&dispatcher_,
290 new TestWriterFactory());
289 QuicDispatcherPeer::UseWriter(&dispatcher_, writer_); 291 QuicDispatcherPeer::UseWriter(&dispatcher_, writer_);
290 292
291 IPEndPoint client_address(net::test::Loopback4(), 1); 293 IPEndPoint client_address(net::test::Loopback4(), 1);
292 294
293 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address)) 295 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address))
294 .WillOnce(testing::Return(CreateSession( 296 .WillOnce(testing::Return(CreateSession(
295 &dispatcher_, 1, client_address, &session1_))); 297 &dispatcher_, 1, client_address, &session1_)));
296 ProcessPacket(client_address, 1, true, "foo"); 298 ProcessPacket(client_address, 1, true, "foo");
297 299
298 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address)) 300 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address))
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // And we'll resume where we left off when we get another call. 452 // And we'll resume where we left off when we get another call.
451 EXPECT_CALL(*connection2(), OnCanWrite()); 453 EXPECT_CALL(*connection2(), OnCanWrite());
452 dispatcher_.OnCanWrite(); 454 dispatcher_.OnCanWrite();
453 EXPECT_FALSE(dispatcher_.HasPendingWrites()); 455 EXPECT_FALSE(dispatcher_.HasPendingWrites());
454 } 456 }
455 457
456 } // namespace 458 } // namespace
457 } // namespace test 459 } // namespace test
458 } // namespace tools 460 } // namespace tools
459 } // namespace net 461 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_per_connection_packet_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698