| OLD | NEW |
| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 public: | 307 public: |
| 308 BlockingWriter() : write_blocked_(false) {} | 308 BlockingWriter() : write_blocked_(false) {} |
| 309 | 309 |
| 310 virtual bool IsWriteBlocked() const OVERRIDE { return write_blocked_; } | 310 virtual bool IsWriteBlocked() const OVERRIDE { return write_blocked_; } |
| 311 virtual void SetWritable() OVERRIDE { write_blocked_ = false; } | 311 virtual void SetWritable() OVERRIDE { write_blocked_ = false; } |
| 312 | 312 |
| 313 virtual WriteResult WritePacket( | 313 virtual WriteResult WritePacket( |
| 314 const char* buffer, | 314 const char* buffer, |
| 315 size_t buf_len, | 315 size_t buf_len, |
| 316 const IPAddressNumber& self_client_address, | 316 const IPAddressNumber& self_client_address, |
| 317 const IPEndPoint& peer_client_address) OVERRIDE { | 317 const IPEndPoint& peer_client_address, |
| 318 base::Callback<void(WriteResult wr)> callback) OVERRIDE { |
| 318 if (write_blocked_) { | 319 if (write_blocked_) { |
| 319 return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN); | 320 return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN); |
| 320 } else { | 321 } else { |
| 321 return QuicPacketWriterWrapper::WritePacket( | 322 return QuicPacketWriterWrapper::WritePacket( |
| 322 buffer, buf_len, self_client_address, peer_client_address); | 323 buffer, buf_len, self_client_address, peer_client_address, callback); |
| 323 } | 324 } |
| 324 } | 325 } |
| 325 | 326 |
| 326 bool write_blocked_; | 327 bool write_blocked_; |
| 327 }; | 328 }; |
| 328 | 329 |
| 329 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest { | 330 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest { |
| 330 public: | 331 public: |
| 331 virtual void SetUp() { | 332 virtual void SetUp() { |
| 332 writer_ = new BlockingWriter; | 333 writer_ = new BlockingWriter; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // And we'll resume where we left off when we get another call. | 495 // And we'll resume where we left off when we get another call. |
| 495 EXPECT_CALL(*connection2(), OnCanWrite()); | 496 EXPECT_CALL(*connection2(), OnCanWrite()); |
| 496 dispatcher_.OnCanWrite(); | 497 dispatcher_.OnCanWrite(); |
| 497 EXPECT_FALSE(dispatcher_.HasPendingWrites()); | 498 EXPECT_FALSE(dispatcher_.HasPendingWrites()); |
| 498 } | 499 } |
| 499 | 500 |
| 500 } // namespace | 501 } // namespace |
| 501 } // namespace test | 502 } // namespace test |
| 502 } // namespace tools | 503 } // namespace tools |
| 503 } // namespace net | 504 } // namespace net |
| OLD | NEW |