summaryrefslogtreecommitdiffstats
path: root/net/tools/quic
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 19:39:43 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 19:39:43 +0000
commit3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2 (patch)
tree034a554e79e1d254e4c15c20ad0d9347c8e7c9e3 /net/tools/quic
parent697b287ede25a3263473acc870a532ca863163bf (diff)
downloadchromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.zip
chromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.tar.gz
chromium_src-3aa9ca7d36a77ac1cf4077ed041b0c624dea8eb2.tar.bz2
Land Recent QUIC Changes.
Allow running the test server in secure mode. Merge internal change: 62164374 https://codereview.chromium.org/181413007/ Implement special behaviors (closing and timing out) in the test server. Testing only. Merge internal change: 62158630 https://codereview.chromium.org/177293008/ Moving a preexisting DCHECK to a new and more helpful dfatal. Merge internal change: 62089588 https://codereview.chromium.org/181463007/ PACKET_NBYTE_GUID -> PACKET_NBYTE_CONNECTION_ID GUID->ConnectionId QuicGuid->QuicConnectionId guid->connection_id except for the dos proto, which I'm leaving alone for now. renaming quic guid to connection id. no functional change. Merge internal change: 62087636 https://codereview.chromium.org/181483006/ QUIC-local change to extend per-connection stats. Extending QuicConnectionStats to add two Cubic-related stats. Merge internal change: 61977906 https://codereview.chromium.org/177843017/ Implement an early retransmit timer in QUIC's TcpLossAlgorithm to replace immediate loss and retransmission. Merge internal change: 61976680 https://codereview.chromium.org/182083002/ Add a time based loss detection algorithm to QUIC that loses packets after 1.25RTTs and at least one nack. Merge internal change: 61975778 https://codereview.chromium.org/182063002/ QUIC test cleanup to always use MockLossAlgorithm in QuicConnectionTest. Merge internal change: 61972606 https://codereview.chromium.org/180783003/ Minor optimizations to QuicUnackedPacketMap and QuicSentPacketManager to improve load testing. Merge internal change: 61961987 https://codereview.chromium.org/181433007/ Cleanup: Rename http_message_test_utils.{h,cc,_test.cc} to http_message.{h,cc,_test.cc} This is how it should be named (defines/tests class HTTPMessage), and it's confusingly similar to the unrelated http_message_utils.h n/a (test only) Merge internal change: 61955207 https://codereview.chromium.org/181703005/ Test-only change to QuicConnectionTest to use MockLossAlgorithm instead of specific details of the TCP loss detection algorithm. Merge internal change: 61953382 https://codereview.chromium.org/181693005/ Add mock methods for SendBlocked and SendWindowUpdate in QuicConnection (test only) Merge internal change: 61945606 https://codereview.chromium.org/181973002/ Add SendWindowUpdate and SendBlocked methods to QuicConnection. Not used yet. Merge internal change: 61915742 https://codereview.chromium.org/181413005/ Start using the loss timeout in QuicSentPacketManager and add a mock implementation of the LossDetectionInterface for testing. Merge internal change: 61903890 https://codereview.chromium.org/181723003/ R=rch@chromium.org Review URL: https://codereview.chromium.org/182523002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/quic')
-rw-r--r--net/tools/quic/end_to_end_test.cc2
-rw-r--r--net/tools/quic/quic_client.cc4
-rw-r--r--net/tools/quic/quic_client.h2
-rw-r--r--net/tools/quic/quic_dispatcher.cc58
-rw-r--r--net/tools/quic/quic_dispatcher.h13
-rw-r--r--net/tools/quic/quic_dispatcher_test.cc61
-rw-r--r--net/tools/quic/quic_in_memory_cache.cc12
-rw-r--r--net/tools/quic/quic_in_memory_cache.h16
-rw-r--r--net/tools/quic/quic_server.h6
-rw-r--r--net/tools/quic/quic_server_session.cc2
-rw-r--r--net/tools/quic/quic_server_session.h3
-rw-r--r--net/tools/quic/quic_server_test.cc4
-rw-r--r--net/tools/quic/quic_spdy_server_stream.cc11
-rw-r--r--net/tools/quic/quic_time_wait_list_manager.cc117
-rw-r--r--net/tools/quic/quic_time_wait_list_manager.h119
-rw-r--r--net/tools/quic/quic_time_wait_list_manager_test.cc222
-rw-r--r--net/tools/quic/test_tools/http_message.cc (renamed from net/tools/quic/test_tools/http_message_test_utils.cc)4
-rw-r--r--net/tools/quic/test_tools/http_message.h (renamed from net/tools/quic/test_tools/http_message_test_utils.h)8
-rw-r--r--net/tools/quic/test_tools/quic_test_client.cc21
-rw-r--r--net/tools/quic/test_tools/quic_test_client.h6
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.cc10
-rw-r--r--net/tools/quic/test_tools/quic_test_utils.h16
22 files changed, 404 insertions, 313 deletions
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index 2e08a50..6492a59 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -31,7 +31,7 @@
#include "net/tools/quic/quic_server.h"
#include "net/tools/quic/quic_socket_utils.h"
#include "net/tools/quic/quic_spdy_client_stream.h"
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
#include "net/tools/quic/test_tools/quic_client_peer.h"
#include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
index cdb15f0..5a6a51e 100644
--- a/net/tools/quic/quic_client.cc
+++ b/net/tools/quic/quic_client.cc
@@ -164,7 +164,7 @@ bool QuicClient::StartConnect() {
session_.reset(new QuicClientSession(
server_hostname_,
config_,
- new QuicConnection(GenerateGuid(), server_address_, helper_.get(),
+ new QuicConnection(GenerateConnectionId(), server_address_, helper_.get(),
writer_.get(), false, supported_versions_),
&crypto_config_));
return session_->CryptoConnect();
@@ -282,7 +282,7 @@ bool QuicClient::connected() const {
session_->connection()->connected();
}
-QuicGuid QuicClient::GenerateGuid() {
+QuicConnectionId QuicClient::GenerateConnectionId() {
return QuicRandom::GetInstance()->RandUint64();
}
diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h
index 0cd78e9..aec6679 100644
--- a/net/tools/quic/quic_client.h
+++ b/net/tools/quic/quic_client.h
@@ -168,7 +168,7 @@ class QuicClient : public EpollCallbackInterface,
}
protected:
- virtual QuicGuid GenerateGuid();
+ virtual QuicConnectionId GenerateConnectionId();
virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper();
virtual QuicPacketWriter* CreateQuicPacketWriter();
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 48c5766..92e5d70 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -183,13 +183,13 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
const QuicPacketPublicHeader& header) {
QuicSession* session = NULL;
- QuicGuid guid = header.guid;
- SessionMap::iterator it = session_map_.find(guid);
+ QuicConnectionId connection_id = header.connection_id;
+ SessionMap::iterator it = session_map_.find(connection_id);
if (it == session_map_.end()) {
if (header.reset_flag) {
return false;
}
- if (time_wait_list_manager_->IsGuidInTimeWait(guid)) {
+ if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
return HandlePacketForTimeWait(header);
}
@@ -197,13 +197,14 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// session for it. All initial packets for a new connection are required to
// have the flag set. Otherwise it may be a stray packet.
if (header.version_flag) {
- session = CreateQuicSession(guid, current_server_address_,
+ session = CreateQuicSession(connection_id, current_server_address_,
current_client_address_);
}
if (session == NULL) {
- DVLOG(1) << "Failed to create session for " << guid;
- // Add this guid fo the time-wait state, to safely reject future packets.
+ DVLOG(1) << "Failed to create session for " << connection_id;
+ // Add this connection_id fo the time-wait state, to safely reject future
+ // packets.
if (header.version_flag &&
!framer_.IsSupportedVersion(header.versions.front())) {
@@ -214,12 +215,13 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// Use the version in the packet if possible, otherwise assume the latest.
QuicVersion version = header.version_flag ? header.versions.front() :
supported_versions_.front();
- time_wait_list_manager_->AddGuidToTimeWait(guid, version, NULL);
- DCHECK(time_wait_list_manager_->IsGuidInTimeWait(guid));
+ time_wait_list_manager_->AddConnectionIdToTimeWait(
+ connection_id, version, NULL);
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
return HandlePacketForTimeWait(header);
}
- DVLOG(1) << "Created new session for " << guid;
- session_map_.insert(make_pair(guid, session));
+ DVLOG(1) << "Created new session for " << connection_id;
+ session_map_.insert(make_pair(connection_id, session));
} else {
session = it->second;
}
@@ -232,10 +234,11 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
}
void QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
- DCHECK(time_wait_list_manager_->IsGuidInTimeWait(header.public_header.guid));
+ DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(
+ header.public_header.connection_id));
time_wait_list_manager_->ProcessPacket(current_server_address_,
current_client_address_,
- header.public_header.guid,
+ header.public_header.connection_id,
header.packet_sequence_number);
}
@@ -244,9 +247,9 @@ void QuicDispatcher::CleanUpSession(SessionMap::iterator it) {
QuicEncryptedPacket* connection_close_packet =
connection->ReleaseConnectionClosePacket();
write_blocked_list_.erase(connection);
- time_wait_list_manager_->AddGuidToTimeWait(it->first,
- connection->version(),
- connection_close_packet);
+ time_wait_list_manager_->AddConnectionIdToTimeWait(it->first,
+ connection->version(),
+ connection_close_packet);
session_map_.erase(it);
}
@@ -290,16 +293,19 @@ void QuicDispatcher::Shutdown() {
DeleteSessions();
}
-void QuicDispatcher::OnConnectionClosed(QuicGuid guid, QuicErrorCode error) {
- SessionMap::iterator it = session_map_.find(guid);
+void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) {
+ SessionMap::iterator it = session_map_.find(connection_id);
if (it == session_map_.end()) {
- LOG(DFATAL) << "GUID " << guid << " does not exist in the session map. "
+ LOG(DFATAL) << "ConnectionId " << connection_id
+ << " does not exist in the session map. "
<< "Error: " << QuicUtils::ErrorToString(error);
LOG(DFATAL) << base::debug::StackTrace().ToString();
return;
}
- DLOG_IF(INFO, error != QUIC_NO_ERROR) << "Closing connection (" << guid
+ DLOG_IF(INFO, error != QUIC_NO_ERROR) << "Closing connection ("
+ << connection_id
<< ") due to error: "
<< QuicUtils::ErrorToString(error);
@@ -326,23 +332,23 @@ QuicPacketWriterWrapper* QuicDispatcher::CreateWriterWrapper(
}
QuicSession* QuicDispatcher::CreateQuicSession(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address) {
QuicServerSession* session = new QuicServerSession(
config_,
- CreateQuicConnection(guid, server_address, client_address),
+ CreateQuicConnection(connection_id, server_address, client_address),
this);
session->InitializeSession(crypto_config_);
return session;
}
QuicConnection* QuicDispatcher::CreateQuicConnection(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address) {
- return new QuicConnection(guid, client_address, helper_.get(), writer_.get(),
- true, supported_versions_);
+ return new QuicConnection(connection_id, client_address, helper_.get(),
+ writer_.get(), true, supported_versions_);
}
void QuicDispatcher::set_writer(QuicPacketWriter* writer) {
@@ -358,8 +364,8 @@ bool QuicDispatcher::HandlePacketForTimeWait(
// Switch the framer to the correct version, so that the sequence number can
// be parsed correctly.
- framer_.set_version(time_wait_list_manager_->GetQuicVersionFromGuid(
- header.guid));
+ framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId(
+ header.connection_id));
// Continue parsing the packet to extract the sequence number. Then
// send it to the time wait manager in OnUnathenticatedHeader.
diff --git a/net/tools/quic/quic_dispatcher.h b/net/tools/quic/quic_dispatcher.h
index f536ea3..504b27d 100644
--- a/net/tools/quic/quic_dispatcher.h
+++ b/net/tools/quic/quic_dispatcher.h
@@ -86,12 +86,13 @@ class QuicDispatcher : public QuicServerSessionVisitor {
// QuicServerSessionVisitor interface implementation:
// Ensure that the closed connection is cleaned up asynchronously.
- virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) OVERRIDE;
+ virtual void OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) OVERRIDE;
// Queues the blocked writer for later resumption.
virtual void OnWriteBlocked(QuicBlockedWriterInterface* writer) OVERRIDE;
- typedef base::hash_map<QuicGuid, QuicSession*> SessionMap;
+ typedef base::hash_map<QuicConnectionId, QuicSession*> SessionMap;
// Deletes all sessions on the closed session list and clears the list.
void DeleteSessions();
@@ -110,11 +111,11 @@ class QuicDispatcher : public QuicServerSessionVisitor {
virtual QuicPacketWriterWrapper* CreateWriterWrapper(
QuicPacketWriter* writer);
- virtual QuicSession* CreateQuicSession(QuicGuid guid,
+ virtual QuicSession* CreateQuicSession(QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address);
- QuicConnection* CreateQuicConnection(QuicGuid guid,
+ QuicConnection* CreateQuicConnection(QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address);
@@ -160,7 +161,7 @@ class QuicDispatcher : public QuicServerSessionVisitor {
void OnUnauthenticatedHeader(const QuicPacketHeader& header);
// Removes the session from the session map and write blocked list, and
- // adds the GUID to the time-wait list.
+ // adds the ConnectionId to the time-wait list.
void CleanUpSession(SessionMap::iterator it);
bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header);
@@ -174,7 +175,7 @@ class QuicDispatcher : public QuicServerSessionVisitor {
SessionMap session_map_;
- // Entity that manages guids in time wait state.
+ // Entity that manages connection_ids in time wait state.
scoped_ptr<QuicTimeWaitListManager> time_wait_list_manager_;
// An alarm which deletes closed sessions.
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
index 5ab7b29..e894e1b5 100644
--- a/net/tools/quic/quic_dispatcher_test.cc
+++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -47,7 +47,7 @@ class TestDispatcher : public QuicDispatcher {
}
MOCK_METHOD3(CreateQuicSession, QuicSession*(
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& server_address,
const IPEndPoint& client_address));
using QuicDispatcher::write_blocked_list;
@@ -59,24 +59,25 @@ class TestDispatcher : public QuicDispatcher {
// involve a lot more mocking.
class MockServerConnection : public MockConnection {
public:
- MockServerConnection(QuicGuid guid,
+ MockServerConnection(QuicConnectionId connection_id,
QuicDispatcher* dispatcher)
- : MockConnection(guid, true),
+ : MockConnection(connection_id, true),
dispatcher_(dispatcher) {}
void UnregisterOnConnectionClosed() {
- LOG(ERROR) << "Unregistering " << guid();
- dispatcher_->OnConnectionClosed(guid(), QUIC_NO_ERROR);
+ LOG(ERROR) << "Unregistering " << connection_id();
+ dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR);
}
private:
QuicDispatcher* dispatcher_;
};
QuicSession* CreateSession(QuicDispatcher* dispatcher,
- QuicGuid guid,
+ QuicConnectionId connection_id,
const IPEndPoint& addr,
MockSession** session) {
- MockServerConnection* connection = new MockServerConnection(guid, dispatcher);
+ MockServerConnection* connection =
+ new MockServerConnection(connection_id, dispatcher);
*session = new MockSession(connection);
ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
WithoutArgs(Invoke(
@@ -109,14 +110,14 @@ class QuicDispatcherTest : public ::testing::Test {
}
QuicEncryptedPacket* ConstructEncryptedPacket(
- QuicGuid guid,
+ QuicConnectionId connection_id,
bool version_flag,
bool reset_flag,
QuicPacketSequenceNumber sequence_number,
const string& data) {
QuicPacketHeader header;
- header.public_header.guid = guid;
- header.public_header.guid_length = PACKET_8BYTE_GUID;
+ header.public_header.connection_id = connection_id;
+ header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
header.public_header.version_flag = version_flag;
header.public_header.reset_flag = reset_flag;
header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
@@ -143,11 +144,11 @@ class QuicDispatcherTest : public ::testing::Test {
}
void ProcessPacket(IPEndPoint addr,
- QuicGuid guid,
+ QuicConnectionId connection_id,
bool has_version_flag,
const string& data) {
- scoped_ptr<QuicEncryptedPacket> packet(
- ConstructEncryptedPacket(guid, has_version_flag, false, 1, data));
+ scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
+ connection_id, has_version_flag, false, 1, data));
dispatcher_.ProcessPacket(IPEndPoint(), addr, *packet.get());
}
@@ -210,7 +211,7 @@ class MockTimeWaitListManager : public QuicTimeWaitListManager {
MOCK_METHOD4(ProcessPacket, void(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number));
};
@@ -223,15 +224,15 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
time_wait_list_manager);
// Create a new session.
IPEndPoint addr(net::test::Loopback4(), 1);
- QuicGuid guid = 1;
- EXPECT_CALL(dispatcher_, CreateQuicSession(guid, _, addr))
+ QuicConnectionId connection_id = 1;
+ EXPECT_CALL(dispatcher_, CreateQuicSession(connection_id, _, addr))
.WillOnce(testing::Return(CreateSession(
- &dispatcher_, guid, addr, &session1_)));
- ProcessPacket(addr, guid, true, "foo");
+ &dispatcher_, connection_id, addr, &session1_)));
+ ProcessPacket(addr, connection_id, true, "foo");
// Close the connection by sending public reset packet.
QuicPublicResetPacket packet;
- packet.public_header.guid = guid;
+ packet.public_header.connection_id = connection_id;
packet.public_header.reset_flag = true;
packet.public_header.version_flag = false;
packet.rejected_sequence_number = 19191;
@@ -248,12 +249,13 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
reinterpret_cast<MockConnection*>(session1_->connection()),
&MockConnection::ReallyProcessUdpPacket));
dispatcher_.ProcessPacket(IPEndPoint(), addr, *encrypted);
- EXPECT_TRUE(time_wait_list_manager->IsGuidInTimeWait(guid));
+ EXPECT_TRUE(time_wait_list_manager->IsConnectionIdInTimeWait(connection_id));
- // Dispatcher forwards subsequent packets for this guid to the time wait list
- // manager.
- EXPECT_CALL(*time_wait_list_manager, ProcessPacket(_, _, guid, _)).Times(1);
- ProcessPacket(addr, guid, true, "foo");
+ // Dispatcher forwards subsequent packets for this connection_id to the time
+ // wait list manager.
+ EXPECT_CALL(*time_wait_list_manager,
+ ProcessPacket(_, _, connection_id, _)).Times(1);
+ ProcessPacket(addr, connection_id, true, "foo");
}
TEST_F(QuicDispatcherTest, StrayPacketToTimeWaitListManager) {
@@ -265,13 +267,14 @@ TEST_F(QuicDispatcherTest, StrayPacketToTimeWaitListManager) {
time_wait_list_manager);
IPEndPoint addr(net::test::Loopback4(), 1);
- QuicGuid guid = 1;
- // Dispatcher forwards all packets for this guid to the time wait list
- // manager.
+ QuicConnectionId connection_id = 1;
+ // Dispatcher forwards all packets for this connection_id to the time wait
+ // list manager.
EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0);
- EXPECT_CALL(*time_wait_list_manager, ProcessPacket(_, _, guid, _)).Times(1);
+ EXPECT_CALL(*time_wait_list_manager,
+ ProcessPacket(_, _, connection_id, _)).Times(1);
string data = "foo";
- ProcessPacket(addr, guid, false, "foo");
+ ProcessPacket(addr, connection_id, false, "foo");
}
class BlockingWriter : public QuicPacketWriterWrapper {
diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc
index b3e08f8..af46ca3 100644
--- a/net/tools/quic/quic_in_memory_cache.cc
+++ b/net/tools/quic/quic_in_memory_cache.cc
@@ -110,6 +110,18 @@ void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
responses_[GetKey(request_headers)] = new_response;
}
+void QuicInMemoryCache::AddSpecialResponse(StringPiece method,
+ StringPiece path,
+ StringPiece version,
+ SpecialResponseType response_type) {
+ BalsaHeaders request_headers, response_headers;
+ request_headers.SetRequestFirstlineFromStringPieces(method,
+ path,
+ version);
+ AddResponse(request_headers, response_headers, "");
+ responses_[GetKey(request_headers)]->response_type_ = response_type;
+}
+
QuicInMemoryCache::QuicInMemoryCache() {
Initialize();
}
diff --git a/net/tools/quic/quic_in_memory_cache.h b/net/tools/quic/quic_in_memory_cache.h
index 3be25a6..be091d5 100644
--- a/net/tools/quic/quic_in_memory_cache.h
+++ b/net/tools/quic/quic_in_memory_cache.h
@@ -32,12 +32,19 @@ class QuicServer;
// `wget -p --save_headers <url>`
class QuicInMemoryCache {
public:
+ enum SpecialResponseType {
+ REGULAR_RESPONSE, // Send the headers and body like a server should.
+ CLOSE_CONNECTION, // Close the connection (sending the close packet).
+ IGNORE_REQUEST, // Do nothing, expect the client to time out.
+ };
+
// Container for response header/body pairs.
class Response {
public:
- Response() {}
+ Response() : response_type_(REGULAR_RESPONSE) {}
~Response() {}
+ const SpecialResponseType response_type() const { return response_type_; }
const BalsaHeaders& headers() const { return headers_; }
const base::StringPiece body() const { return base::StringPiece(body_); }
@@ -51,6 +58,7 @@ class QuicInMemoryCache {
body.CopyToString(&body_);
}
+ SpecialResponseType response_type_;
BalsaHeaders headers_;
std::string body_;
@@ -79,6 +87,12 @@ class QuicInMemoryCache {
const BalsaHeaders& response_headers,
base::StringPiece response_body);
+ // Simulate a special behavior at a particular path.
+ void AddSpecialResponse(base::StringPiece method,
+ base::StringPiece path,
+ base::StringPiece version,
+ SpecialResponseType response_type);
+
private:
typedef base::hash_map<std::string, Response*> ResponseMap;
friend struct DefaultSingletonTraits<QuicInMemoryCache>;
diff --git a/net/tools/quic/quic_server.h b/net/tools/quic/quic_server.h
index cc0f215..76204d4 100644
--- a/net/tools/quic/quic_server.h
+++ b/net/tools/quic/quic_server.h
@@ -68,6 +68,12 @@ class QuicServer : public EpollCallbackInterface {
crypto_config_.set_strike_register_no_startup_period();
}
+ // SetProofSource sets the ProofSource that will be used to verify the
+ // server's certificate, and takes ownership of |source|.
+ void SetProofSource(ProofSource* source) {
+ crypto_config_.SetProofSource(source);
+ }
+
bool overflow_supported() { return overflow_supported_; }
uint32 packets_dropped() { return packets_dropped_; }
diff --git a/net/tools/quic/quic_server_session.cc b/net/tools/quic/quic_server_session.cc
index cb9b146..1213495 100644
--- a/net/tools/quic/quic_server_session.cc
+++ b/net/tools/quic/quic_server_session.cc
@@ -44,7 +44,7 @@ void QuicServerSession::OnConnectionClosed(QuicErrorCode error,
crypto_stream_.get() != NULL) {
crypto_stream_->CancelOutstandingCallbacks();
}
- visitor_->OnConnectionClosed(connection()->guid(), error);
+ visitor_->OnConnectionClosed(connection()->connection_id(), error);
}
void QuicServerSession::OnWriteBlocked() {
diff --git a/net/tools/quic/quic_server_session.h b/net/tools/quic/quic_server_session.h
index 288cc68..ffd8b0a 100644
--- a/net/tools/quic/quic_server_session.h
+++ b/net/tools/quic/quic_server_session.h
@@ -38,7 +38,8 @@ class QuicServerSessionVisitor {
public:
virtual ~QuicServerSessionVisitor() {}
- virtual void OnConnectionClosed(QuicGuid guid, QuicErrorCode error) = 0;
+ virtual void OnConnectionClosed(QuicConnectionId connection_id,
+ QuicErrorCode error) = 0;
virtual void OnWriteBlocked(QuicBlockedWriterInterface* writer) = 0;
};
diff --git a/net/tools/quic/quic_server_test.cc b/net/tools/quic/quic_server_test.cc
index 833c25f..e2d7c4f 100644
--- a/net/tools/quic/quic_server_test.cc
+++ b/net/tools/quic/quic_server_test.cc
@@ -39,9 +39,9 @@ class QuicServerDispatchPacketTest : public ::testing::Test {
TEST_F(QuicServerDispatchPacketTest, DispatchPacket) {
unsigned char valid_packet[] = {
- // public flags (8 byte guid)
+ // public flags (8 byte connection_id)
0x3C,
- // guid
+ // connection_id
0x10, 0x32, 0x54, 0x76,
0x98, 0xBA, 0xDC, 0xFE,
// packet sequence number
diff --git a/net/tools/quic/quic_spdy_server_stream.cc b/net/tools/quic/quic_spdy_server_stream.cc
index bdae62f..f70987d 100644
--- a/net/tools/quic/quic_spdy_server_stream.cc
+++ b/net/tools/quic/quic_spdy_server_stream.cc
@@ -97,6 +97,17 @@ void QuicSpdyServerStream::SendResponse() {
return;
}
+ if (response->response_type() == QuicInMemoryCache::CLOSE_CONNECTION) {
+ DVLOG(1) << "Special response: closing connection.";
+ CloseConnection(QUIC_NO_ERROR);
+ return;
+ }
+
+ if (response->response_type() == QuicInMemoryCache::IGNORE_REQUEST) {
+ DVLOG(1) << "Special response: ignoring request.";
+ return;
+ }
+
DVLOG(1) << "Sending response for stream " << id();
SendHeadersAndBody(response->headers(), response->body());
}
diff --git a/net/tools/quic/quic_time_wait_list_manager.cc b/net/tools/quic/quic_time_wait_list_manager.cc
index b145e8a..780a473 100644
--- a/net/tools/quic/quic_time_wait_list_manager.cc
+++ b/net/tools/quic/quic_time_wait_list_manager.cc
@@ -27,23 +27,24 @@ namespace tools {
namespace {
-// Time period for which the guid should live in time wait state..
+// Time period for which the connection_id should live in time wait state..
const int kTimeWaitSeconds = 5;
} // namespace
// A very simple alarm that just informs the QuicTimeWaitListManager to clean
-// up old guids. This alarm should be unregistered and deleted before the
-// QuicTimeWaitListManager is deleted.
-class GuidCleanUpAlarm : public EpollAlarm {
+// up old connection_ids. This alarm should be unregistered and deleted before
+// the QuicTimeWaitListManager is deleted.
+class ConnectionIdCleanUpAlarm : public EpollAlarm {
public:
- explicit GuidCleanUpAlarm(QuicTimeWaitListManager* time_wait_list_manager)
+ explicit ConnectionIdCleanUpAlarm(
+ QuicTimeWaitListManager* time_wait_list_manager)
: time_wait_list_manager_(time_wait_list_manager) {
}
virtual int64 OnAlarm() OVERRIDE {
EpollAlarm::OnAlarm();
- time_wait_list_manager_->CleanUpOldGuids();
+ time_wait_list_manager_->CleanUpOldConnectionIds();
// Let the time wait manager register the alarm at appropriate time.
return 0;
}
@@ -55,7 +56,7 @@ class GuidCleanUpAlarm : public EpollAlarm {
// This class stores pending public reset packets to be sent to clients.
// server_address - server address on which a packet what was received for
-// a guid in time wait state.
+// a connection_id in time wait state.
// client_address - address of the client that sent that packet. Needed to send
// the public reset packet back to the client.
// packet - the pending public reset packet that is to be sent to the client.
@@ -89,43 +90,48 @@ QuicTimeWaitListManager::QuicTimeWaitListManager(
const QuicVersionVector& supported_versions)
: epoll_server_(epoll_server),
kTimeWaitPeriod_(QuicTime::Delta::FromSeconds(kTimeWaitSeconds)),
- guid_clean_up_alarm_(new GuidCleanUpAlarm(this)),
+ connection_id_clean_up_alarm_(new ConnectionIdCleanUpAlarm(this)),
clock_(epoll_server_),
writer_(writer),
visitor_(visitor) {
- SetGuidCleanUpAlarm();
+ SetConnectionIdCleanUpAlarm();
}
QuicTimeWaitListManager::~QuicTimeWaitListManager() {
- guid_clean_up_alarm_->UnregisterIfRegistered();
+ connection_id_clean_up_alarm_->UnregisterIfRegistered();
STLDeleteElements(&pending_packets_queue_);
- for (GuidMap::iterator it = guid_map_.begin(); it != guid_map_.end(); ++it) {
+ for (ConnectionIdMap::iterator it = connection_id_map_.begin();
+ it != connection_id_map_.end();
+ ++it) {
delete it->second.close_packet;
}
}
-void QuicTimeWaitListManager::AddGuidToTimeWait(
- QuicGuid guid,
+void QuicTimeWaitListManager::AddConnectionIdToTimeWait(
+ QuicConnectionId connection_id,
QuicVersion version,
QuicEncryptedPacket* close_packet) {
int num_packets = 0;
- GuidMap::iterator it = guid_map_.find(guid);
- if (it != guid_map_.end()) { // Replace record if it is reinserted.
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ if (it != connection_id_map_.end()) { // Replace record if it is reinserted.
num_packets = it->second.num_packets;
delete it->second.close_packet;
- guid_map_.erase(it);
+ connection_id_map_.erase(it);
}
- GuidData data(num_packets, version, clock_.ApproximateNow(), close_packet);
- guid_map_.insert(make_pair(guid, data));
+ ConnectionIdData data(num_packets, version, clock_.ApproximateNow(),
+ close_packet);
+ connection_id_map_.insert(make_pair(connection_id, data));
}
-bool QuicTimeWaitListManager::IsGuidInTimeWait(QuicGuid guid) const {
- return guid_map_.find(guid) != guid_map_.end();
+bool QuicTimeWaitListManager::IsConnectionIdInTimeWait(
+ QuicConnectionId connection_id) const {
+ return ContainsKey(connection_id_map_, connection_id);
}
-QuicVersion QuicTimeWaitListManager::GetQuicVersionFromGuid(QuicGuid guid) {
- GuidMap::iterator it = guid_map_.find(guid);
- DCHECK(it != guid_map_.end());
+QuicVersion QuicTimeWaitListManager::GetQuicVersionFromConnectionId(
+ QuicConnectionId connection_id) {
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ DCHECK(it != connection_id_map_.end());
return (it->second).version;
}
@@ -143,13 +149,13 @@ void QuicTimeWaitListManager::OnCanWrite() {
void QuicTimeWaitListManager::ProcessPacket(
const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
- DCHECK(IsGuidInTimeWait(guid));
+ DCHECK(IsConnectionIdInTimeWait(connection_id));
// TODO(satyamshekhar): Think about handling packets from different client
// addresses.
- GuidMap::iterator it = guid_map_.find(guid);
- DCHECK(it != guid_map_.end());
+ ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
+ DCHECK(it != connection_id_map_.end());
// Increment the received packet count.
++((it->second).num_packets);
if (!ShouldSendResponse((it->second).num_packets)) {
@@ -163,12 +169,16 @@ void QuicTimeWaitListManager::ProcessPacket(
// Takes ownership of the packet.
SendOrQueuePacket(queued_packet);
} else {
- SendPublicReset(server_address, client_address, guid, sequence_number);
+ SendPublicReset(server_address,
+ client_address,
+ connection_id,
+ sequence_number);
}
}
-// Returns true if the number of packets received for this guid is a power of 2
-// to throttle the number of public reset packets we send to a client.
+// Returns true if the number of packets received for this connection_id is a
+// power of 2 to throttle the number of public reset packets we send to a
+// client.
bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) {
return (received_packet_count & (received_packet_count - 1)) == 0;
}
@@ -176,14 +186,14 @@ bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) {
void QuicTimeWaitListManager::SendPublicReset(
const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber rejected_sequence_number) {
QuicPublicResetPacket packet;
- packet.public_header.guid = guid;
+ packet.public_header.connection_id = connection_id;
packet.public_header.reset_flag = true;
packet.public_header.version_flag = false;
packet.rejected_sequence_number = rejected_sequence_number;
- // TODO(satyamshekhar): generate a valid nonce for this guid.
+ // TODO(satyamshekhar): generate a valid nonce for this connection_id.
packet.nonce_proof = 1010101;
packet.client_address = client_address;
QueuedPacket* queued_packet = new QueuedPacket(
@@ -228,42 +238,43 @@ bool QuicTimeWaitListManager::WriteToWire(QueuedPacket* queued_packet) {
return true;
}
-void QuicTimeWaitListManager::SetGuidCleanUpAlarm() {
- guid_clean_up_alarm_->UnregisterIfRegistered();
+void QuicTimeWaitListManager::SetConnectionIdCleanUpAlarm() {
+ connection_id_clean_up_alarm_->UnregisterIfRegistered();
int64 next_alarm_interval;
- if (!guid_map_.empty()) {
- QuicTime oldest_guid = guid_map_.begin()->second.time_added;
+ if (!connection_id_map_.empty()) {
+ QuicTime oldest_connection_id =
+ connection_id_map_.begin()->second.time_added;
QuicTime now = clock_.ApproximateNow();
- if (now.Subtract(oldest_guid) < kTimeWaitPeriod_) {
- next_alarm_interval = oldest_guid.Add(kTimeWaitPeriod_)
- .Subtract(now)
- .ToMicroseconds();
+ if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
+ next_alarm_interval = oldest_connection_id.Add(kTimeWaitPeriod_)
+ .Subtract(now)
+ .ToMicroseconds();
} else {
- LOG(ERROR) << "GUID lingered for longer than kTimeWaitPeriod";
+ LOG(ERROR) << "ConnectionId lingered for longer than kTimeWaitPeriod";
next_alarm_interval = 0;
}
} else {
- // No guids added so none will expire before kTimeWaitPeriod_.
+ // No connection_ids added so none will expire before kTimeWaitPeriod_.
next_alarm_interval = kTimeWaitPeriod_.ToMicroseconds();
}
- epoll_server_->RegisterAlarmApproximateDelta(next_alarm_interval,
- guid_clean_up_alarm_.get());
+ epoll_server_->RegisterAlarmApproximateDelta(
+ next_alarm_interval, connection_id_clean_up_alarm_.get());
}
-void QuicTimeWaitListManager::CleanUpOldGuids() {
+void QuicTimeWaitListManager::CleanUpOldConnectionIds() {
QuicTime now = clock_.ApproximateNow();
- while (!guid_map_.empty()) {
- GuidMap::iterator it = guid_map_.begin();
- QuicTime oldest_guid = it->second.time_added;
- if (now.Subtract(oldest_guid) < kTimeWaitPeriod_) {
+ while (!connection_id_map_.empty()) {
+ ConnectionIdMap::iterator it = connection_id_map_.begin();
+ QuicTime oldest_connection_id = it->second.time_added;
+ if (now.Subtract(oldest_connection_id) < kTimeWaitPeriod_) {
break;
}
- // This guid has lived its age, retire it now.
+ // This connection_id has lived its age, retire it now.
delete it->second.close_packet;
- guid_map_.erase(it);
+ connection_id_map_.erase(it);
}
- SetGuidCleanUpAlarm();
+ SetConnectionIdCleanUpAlarm();
}
} // namespace tools
diff --git a/net/tools/quic/quic_time_wait_list_manager.h b/net/tools/quic/quic_time_wait_list_manager.h
index 4654045..3b29123 100644
--- a/net/tools/quic/quic_time_wait_list_manager.h
+++ b/net/tools/quic/quic_time_wait_list_manager.h
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Handles packets for guids in time wait state by discarding the packet and
-// sending the clients a public reset packet with exponential backoff.
+// Handles packets for connection_ids in time wait state by discarding the
+// packet and sending the clients a public reset packet with exponential
+// backoff.
#ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
#define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
@@ -24,21 +25,22 @@
namespace net {
namespace tools {
-class GuidCleanUpAlarm;
+class ConnectionIdCleanUpAlarm;
class QuicServerSessionVisitor;
namespace test {
class QuicTimeWaitListManagerPeer;
} // namespace test
-// Maintains a list of all guids that have been recently closed. A guid lives in
-// this state for kTimeWaitPeriod. All packets received for guids in this state
-// are handed over to the QuicTimeWaitListManager by the QuicDispatcher.
-// Decides whether to send a public reset packet, a copy of the previously sent
-// connection close packet, or nothing to the client which sent a packet
-// with the guid in time wait state. After the guid expires its time wait
-// period, a new connection/session will be created if a packet is received
-// for this guid.
+// Maintains a list of all connection_ids that have been recently closed. A
+// connection_id lives in this state for kTimeWaitPeriod. All packets received
+// for connection_ids in this state are handed over to the
+// QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a
+// public reset packet, a copy of the previously sent connection close packet,
+// or nothing to the client which sent a packet with the connection_id in time
+// wait state. After the connection_id expires its time wait period, a new
+// connection/session will be created if a packet is received for this
+// connection_id.
class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
public:
// writer - the entity that writes to the socket. (Owned by the dispatcher)
@@ -50,28 +52,29 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
const QuicVersionVector& supported_versions);
virtual ~QuicTimeWaitListManager();
- // Adds the given guid to time wait state for kTimeWaitPeriod. Henceforth,
- // any packet bearing this guid should not be processed while the guid remains
- // in this list. If a non-NULL |close_packet| is provided, it is sent again
- // when packets are received for added guids. If NULL, a public reset packet
- // is sent with the specified |version|. DCHECKs that guid is not already on
- // the list.
- void AddGuidToTimeWait(QuicGuid guid,
- QuicVersion version,
- QuicEncryptedPacket* close_packet); // Owned.
-
- // Returns true if the guid is in time wait state, false otherwise. Packets
- // received for this guid should not lead to creation of new QuicSessions.
- bool IsGuidInTimeWait(QuicGuid guid) const;
-
- // Called when a packet is received for a guid that is in time wait state.
- // Sends a public reset packet to the client which sent this guid. Sending
- // of the public reset packet is throttled by using exponential back off.
- // DCHECKs for the guid to be in time wait state.
- // virtual to override in tests.
+ // Adds the given connection_id to time wait state for kTimeWaitPeriod.
+ // Henceforth, any packet bearing this connection_id should not be processed
+ // while the connection_id remains in this list. If a non-NULL |close_packet|
+ // is provided, it is sent again when packets are received for added
+ // connection_ids. If NULL, a public reset packet is sent with the specified
+ // |version|. DCHECKs that connection_id is not already on the list.
+ void AddConnectionIdToTimeWait(QuicConnectionId connection_id,
+ QuicVersion version,
+ QuicEncryptedPacket* close_packet); // Owned.
+
+ // Returns true if the connection_id is in time wait state, false otherwise.
+ // Packets received for this connection_id should not lead to creation of new
+ // QuicSessions.
+ bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) const;
+
+ // Called when a packet is received for a connection_id that is in time wait
+ // state. Sends a public reset packet to the client which sent this
+ // connection_id. Sending of the public reset packet is throttled by using
+ // exponential back off. DCHECKs for the connection_id to be in time wait
+ // state. virtual to override in tests.
virtual void ProcessPacket(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number);
// Called by the dispatcher when the underlying socket becomes writable again,
@@ -79,12 +82,13 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
// send because the underlying socket was write blocked.
virtual void OnCanWrite() OVERRIDE;
- // Used to delete guid entries that have outlived their time wait period.
- void CleanUpOldGuids();
+ // Used to delete connection_id entries that have outlived their time wait
+ // period.
+ void CleanUpOldConnectionIds();
- // Given a GUID that exists in the time wait list, returns the QuicVersion
- // associated with it.
- QuicVersion GetQuicVersionFromGuid(QuicGuid guid);
+ // Given a ConnectionId that exists in the time wait list, returns the
+ // QuicVersion associated with it.
+ QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id);
private:
friend class test::QuicTimeWaitListManagerPeer;
@@ -92,14 +96,14 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
// Internal structure to store pending public reset packets.
class QueuedPacket;
- // Decides if a packet should be sent for this guid based on the number of
- // received packets.
+ // Decides if a packet should be sent for this connection_id based on the
+ // number of received packets.
bool ShouldSendResponse(int received_packet_count);
// Creates a public reset packet and sends it or queues it to be sent later.
void SendPublicReset(const IPEndPoint& server_address,
const IPEndPoint& client_address,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber rejected_sequence_number);
// Either sends the packet and deletes it or makes pending_packets_queue_ the
@@ -113,15 +117,16 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
bool WriteToWire(QueuedPacket* packet);
// Register the alarm with the epoll server to wake up at appropriate time.
- void SetGuidCleanUpAlarm();
-
- // A map from a recently closed guid to the number of packets received after
- // the termination of the connection bound to the guid.
- struct GuidData {
- GuidData(int num_packets_,
- QuicVersion version_,
- QuicTime time_added_,
- QuicEncryptedPacket* close_packet)
+ void SetConnectionIdCleanUpAlarm();
+
+ // A map from a recently closed connection_id to the number of packets
+ // received after the termination of the connection bound to the
+ // connection_id.
+ struct ConnectionIdData {
+ ConnectionIdData(int num_packets_,
+ QuicVersion version_,
+ QuicTime time_added_,
+ QuicEncryptedPacket* close_packet)
: num_packets(num_packets_),
version(version_),
time_added(time_added_),
@@ -132,24 +137,24 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
QuicEncryptedPacket* close_packet;
};
- // linked_hash_map allows lookup by Guid and traversal in add order.
- typedef linked_hash_map<QuicGuid, GuidData> GuidMap;
- GuidMap guid_map_;
+ // linked_hash_map allows lookup by ConnectionId and traversal in add order.
+ typedef linked_hash_map<QuicConnectionId, ConnectionIdData> ConnectionIdMap;
+ ConnectionIdMap connection_id_map_;
// Pending public reset packets that need to be sent out to the client
// when we are given a chance to write by the dispatcher.
std::deque<QueuedPacket*> pending_packets_queue_;
- // Used to schedule alarms to delete old guids which have been in the list for
- // too long.
+ // Used to schedule alarms to delete old connection_ids which have been in the
+ // list for too long.
EpollServer* epoll_server_;
- // Time period for which guids should remain in time wait state.
+ // Time period for which connection_ids should remain in time wait state.
const QuicTime::Delta kTimeWaitPeriod_;
- // Alarm registered with the epoll server to clean up guids that have out
- // lived their duration in time wait state.
- scoped_ptr<GuidCleanUpAlarm> guid_clean_up_alarm_;
+ // Alarm registered with the epoll server to clean up connection_ids that have
+ // out lived their duration in time wait state.
+ scoped_ptr<ConnectionIdCleanUpAlarm> connection_id_clean_up_alarm_;
// Clock to efficiently measure approximate time from the epoll server.
QuicEpollClock clock_;
diff --git a/net/tools/quic/quic_time_wait_list_manager_test.cc b/net/tools/quic/quic_time_wait_list_manager_test.cc
index 9aac8b3..8d440f9 100644
--- a/net/tools/quic/quic_time_wait_list_manager_test.cc
+++ b/net/tools/quic/quic_time_wait_list_manager_test.cc
@@ -50,9 +50,10 @@ class QuicTimeWaitListManagerPeer {
return manager->kTimeWaitPeriod_;
}
- static QuicVersion GetQuicVersionFromGuid(QuicTimeWaitListManager* manager,
- QuicGuid guid) {
- return manager->GetQuicVersionFromGuid(guid);
+ static QuicVersion GetQuicVersionFromConnectionId(
+ QuicTimeWaitListManager* manager,
+ QuicConnectionId connection_id) {
+ return manager->GetQuicVersionFromConnectionId(connection_id);
}
};
@@ -70,7 +71,7 @@ class QuicTimeWaitListManagerTest : public testing::Test {
: time_wait_list_manager_(&writer_, &visitor_,
&epoll_server_, QuicSupportedVersions()),
framer_(QuicSupportedVersions(), QuicTime::Zero(), true),
- guid_(45),
+ connection_id_(45),
client_address_(net::test::TestPeerIPAddress(), kTestPort),
writer_is_blocked_(false) {}
@@ -83,34 +84,36 @@ class QuicTimeWaitListManagerTest : public testing::Test {
.WillRepeatedly(Return(false));
}
- void AddGuid(QuicGuid guid) {
- AddGuid(guid, net::test::QuicVersionMax(), NULL);
+ void AddConnectionId(QuicConnectionId connection_id) {
+ AddConnectionId(connection_id, net::test::QuicVersionMax(), NULL);
}
- void AddGuid(QuicGuid guid,
- QuicVersion version,
- QuicEncryptedPacket* packet) {
- time_wait_list_manager_.AddGuidToTimeWait(guid, version, packet);
+ void AddConnectionId(QuicConnectionId connection_id,
+ QuicVersion version,
+ QuicEncryptedPacket* packet) {
+ time_wait_list_manager_.AddConnectionIdToTimeWait(
+ connection_id, version, packet);
}
- bool IsGuidInTimeWait(QuicGuid guid) {
- return time_wait_list_manager_.IsGuidInTimeWait(guid);
+ bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) {
+ return time_wait_list_manager_.IsConnectionIdInTimeWait(connection_id);
}
- void ProcessPacket(QuicGuid guid, QuicPacketSequenceNumber sequence_number) {
+ void ProcessPacket(QuicConnectionId connection_id,
+ QuicPacketSequenceNumber sequence_number) {
time_wait_list_manager_.ProcessPacket(server_address_,
client_address_,
- guid,
+ connection_id,
sequence_number);
}
QuicEncryptedPacket* ConstructEncryptedPacket(
EncryptionLevel level,
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
QuicPacketHeader header;
- header.public_header.guid = guid;
- header.public_header.guid_length = PACKET_8BYTE_GUID;
+ header.public_header.connection_id = connection_id;
+ header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
header.public_header.version_flag = false;
header.public_header.reset_flag = false;
header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
@@ -139,7 +142,7 @@ class QuicTimeWaitListManagerTest : public testing::Test {
StrictMock<MockQuicServerSessionVisitor> visitor_;
QuicTimeWaitListManager time_wait_list_manager_;
QuicFramer framer_;
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
IPEndPoint server_address_;
IPEndPoint client_address_;
bool writer_is_blocked_;
@@ -148,9 +151,9 @@ class QuicTimeWaitListManagerTest : public testing::Test {
class ValidatePublicResetPacketPredicate
: public MatcherInterface<const std::tr1::tuple<const char*, int> > {
public:
- explicit ValidatePublicResetPacketPredicate(QuicGuid guid,
+ explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id,
QuicPacketSequenceNumber number)
- : guid_(guid), sequence_number_(number) {
+ : connection_id_(connection_id), sequence_number_(number) {
}
virtual bool MatchAndExplain(
@@ -165,7 +168,7 @@ class ValidatePublicResetPacketPredicate
std::tr1::get<1>(packet_buffer));
framer.ProcessPacket(encrypted);
QuicPublicResetPacket packet = visitor.public_reset_packet();
- return guid_ == packet.public_header.guid &&
+ return connection_id_ == packet.public_header.connection_id &&
packet.public_header.reset_flag && !packet.public_header.version_flag &&
sequence_number_ == packet.rejected_sequence_number &&
net::test::TestPeerIPAddress() == packet.client_address.address() &&
@@ -177,60 +180,61 @@ class ValidatePublicResetPacketPredicate
virtual void DescribeNegationTo(::std::ostream* os) const { }
private:
- QuicGuid guid_;
+ QuicConnectionId connection_id_;
QuicPacketSequenceNumber sequence_number_;
};
Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq(
- QuicGuid guid,
+ QuicConnectionId connection_id,
QuicPacketSequenceNumber sequence_number) {
- return MakeMatcher(new ValidatePublicResetPacketPredicate(guid,
+ return MakeMatcher(new ValidatePublicResetPacketPredicate(connection_id,
sequence_number));
}
-TEST_F(QuicTimeWaitListManagerTest, CheckGuidInTimeWait) {
- EXPECT_FALSE(IsGuidInTimeWait(guid_));
- AddGuid(guid_);
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+TEST_F(QuicTimeWaitListManagerTest, CheckConnectionIdInTimeWait) {
+ EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
+ AddConnectionId(connection_id_);
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
}
TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) {
size_t kConnectionCloseLength = 100;
- AddGuid(guid_,
- net::test::QuicVersionMax(),
- new QuicEncryptedPacket(
- new char[kConnectionCloseLength], kConnectionCloseLength, true));
+ AddConnectionId(
+ connection_id_,
+ net::test::QuicVersionMax(),
+ new QuicEncryptedPacket(
+ new char[kConnectionCloseLength], kConnectionCloseLength, true));
const int kRandomSequenceNumber = 1;
EXPECT_CALL(writer_, WritePacket(_, kConnectionCloseLength,
server_address_.address(),
client_address_))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
}
TEST_F(QuicTimeWaitListManagerTest, SendPublicReset) {
- AddGuid(guid_);
+ AddConnectionId(connection_id_);
const int kRandomSequenceNumber = 1;
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid_,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id_,
kRandomSequenceNumber)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
}
TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) {
- AddGuid(guid_);
+ AddConnectionId(connection_id_);
for (int sequence_number = 1; sequence_number < 101; ++sequence_number) {
if ((sequence_number & (sequence_number - 1)) == 0) {
EXPECT_CALL(writer_, WritePacket(_, _, _, _))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
}
- ProcessPacket(guid_, sequence_number);
+ ProcessPacket(connection_id_, sequence_number);
// Send public reset with exponential back off.
if ((sequence_number & (sequence_number - 1)) == 0) {
EXPECT_TRUE(QuicTimeWaitListManagerPeer::ShouldSendResponse(
@@ -242,94 +246,103 @@ TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) {
}
}
-TEST_F(QuicTimeWaitListManagerTest, CleanUpOldGuids) {
- const int kGuidCount = 100;
- const int kOldGuidCount = 31;
+TEST_F(QuicTimeWaitListManagerTest, CleanUpOldConnectionIds) {
+ const int kConnectionIdCount = 100;
+ const int kOldConnectionIdCount = 31;
- // Add guids such that their expiry time is kTimeWaitPeriod_.
+ // Add connection_ids such that their expiry time is kTimeWaitPeriod_.
epoll_server_.set_now_in_usec(0);
- for (int guid = 1; guid <= kOldGuidCount; ++guid) {
- AddGuid(guid);
+ for (int connection_id = 1;
+ connection_id <= kOldConnectionIdCount;
+ ++connection_id) {
+ AddConnectionId(connection_id);
}
- // Add remaining guids such that their add time is 2 * kTimeWaitPeriod.
+ // Add remaining connection_ids such that their add time is
+ // 2 * kTimeWaitPeriod.
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
epoll_server_.set_now_in_usec(time_wait_period.ToMicroseconds());
- for (int guid = kOldGuidCount + 1; guid <= kGuidCount; ++guid) {
- AddGuid(guid);
+ for (int connection_id = kOldConnectionIdCount + 1;
+ connection_id <= kConnectionIdCount;
+ ++connection_id) {
+ AddConnectionId(connection_id);
}
QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39);
// Now set the current time as time_wait_period + offset usecs.
epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds());
- // After all the old guids are cleaned up, check the next alarm interval.
+ // After all the old connection_ids are cleaned up, check the next alarm
+ // interval.
int64 next_alarm_time = epoll_server_.ApproximateNowInUsec() +
time_wait_period.Subtract(offset).ToMicroseconds();
EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _));
- time_wait_list_manager_.CleanUpOldGuids();
- for (int guid = 1; guid <= kGuidCount; ++guid) {
- EXPECT_EQ(guid > kOldGuidCount, IsGuidInTimeWait(guid))
- << "kOldGuidCount: " << kOldGuidCount
- << " guid: " << guid;
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ for (int connection_id = 1;
+ connection_id <= kConnectionIdCount;
+ ++connection_id) {
+ EXPECT_EQ(connection_id > kOldConnectionIdCount,
+ IsConnectionIdInTimeWait(connection_id))
+ << "kOldConnectionIdCount: " << kOldConnectionIdCount
+ << " connection_id: " << connection_id;
}
}
TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
- QuicGuid guid = 1;
- AddGuid(guid);
+ QuicConnectionId connection_id = 1;
+ AddConnectionId(connection_id);
QuicPacketSequenceNumber sequence_number = 234;
- scoped_ptr<QuicEncryptedPacket> packet(
- ConstructEncryptedPacket(ENCRYPTION_NONE, guid, sequence_number));
+ scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
+ ENCRYPTION_NONE, connection_id, sequence_number));
// Let first write through.
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// write block for the next packet.
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(DoAll(
Assign(&writer_is_blocked_, true),
Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN))));
EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// 3rd packet. No public reset should be sent;
- ProcessPacket(guid, sequence_number);
+ ProcessPacket(connection_id, sequence_number);
// write packet should not be called since we are write blocked but the
// should be queued.
- QuicGuid other_guid = 2;
- AddGuid(other_guid);
+ QuicConnectionId other_connection_id = 2;
+ AddConnectionId(other_connection_id);
QuicPacketSequenceNumber other_sequence_number = 23423;
scoped_ptr<QuicEncryptedPacket> other_packet(
ConstructEncryptedPacket(
- ENCRYPTION_NONE, other_guid, other_sequence_number));
+ ENCRYPTION_NONE, other_connection_id, other_sequence_number));
EXPECT_CALL(writer_, WritePacket(_, _, _, _))
.Times(0);
EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
- ProcessPacket(other_guid, other_sequence_number);
+ ProcessPacket(other_connection_id, other_sequence_number);
// Now expect all the write blocked public reset packets to be sent again.
writer_is_blocked_ = false;
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(guid,
+ .With(Args<0, 1>(PublicResetPacketEq(connection_id,
sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
EXPECT_CALL(writer_, WritePacket(_, _,
server_address_.address(),
client_address_))
- .With(Args<0, 1>(PublicResetPacketEq(other_guid,
+ .With(Args<0, 1>(PublicResetPacketEq(other_connection_id,
other_sequence_number)))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK,
other_packet->length())));
@@ -337,36 +350,37 @@ TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
}
TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) {
- const int kGuid1 = 123;
- const int kGuid2 = 456;
- const int kGuid3 = 789;
+ const int kConnectionId1 = 123;
+ const int kConnectionId2 = 456;
+ const int kConnectionId3 = 789;
- AddGuid(kGuid1, net::test::QuicVersionMin(), NULL);
- AddGuid(kGuid2, net::test::QuicVersionMax(), NULL);
- AddGuid(kGuid3, net::test::QuicVersionMax(), NULL);
+ AddConnectionId(kConnectionId1, net::test::QuicVersionMin(), NULL);
+ AddConnectionId(kConnectionId2, net::test::QuicVersionMax(), NULL);
+ AddConnectionId(kConnectionId3, net::test::QuicVersionMax(), NULL);
EXPECT_EQ(net::test::QuicVersionMin(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid1));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId1));
EXPECT_EQ(net::test::QuicVersionMax(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid2));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId2));
EXPECT_EQ(net::test::QuicVersionMax(),
- QuicTimeWaitListManagerPeer::GetQuicVersionFromGuid(
- &time_wait_list_manager_, kGuid3));
+ QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
+ &time_wait_list_manager_, kConnectionId3));
}
-TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
- // Add guids such that their expiry time is kTimeWaitPeriod_.
+TEST_F(QuicTimeWaitListManagerTest, AddConnectionIdTwice) {
+ // Add connection_ids such that their expiry time is kTimeWaitPeriod_.
epoll_server_.set_now_in_usec(0);
- AddGuid(guid_);
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+ AddConnectionId(connection_id_);
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
size_t kConnectionCloseLength = 100;
- AddGuid(guid_,
- net::test::QuicVersionMax(),
- new QuicEncryptedPacket(
- new char[kConnectionCloseLength], kConnectionCloseLength, true));
- EXPECT_TRUE(IsGuidInTimeWait(guid_));
+ AddConnectionId(
+ connection_id_,
+ net::test::QuicVersionMax(),
+ new QuicEncryptedPacket(
+ new char[kConnectionCloseLength], kConnectionCloseLength, true));
+ EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
EXPECT_CALL(writer_, WritePacket(_,
kConnectionCloseLength,
@@ -375,7 +389,7 @@ TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
const int kRandomSequenceNumber = 1;
- ProcessPacket(guid_, kRandomSequenceNumber);
+ ProcessPacket(connection_id_, kRandomSequenceNumber);
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
@@ -383,30 +397,30 @@ TEST_F(QuicTimeWaitListManagerTest, AddGuidTwice) {
QuicTime::Delta offset = QuicTime::Delta::FromMicroseconds(39);
// Now set the current time as time_wait_period + offset usecs.
epoll_server_.set_now_in_usec(time_wait_period.Add(offset).ToMicroseconds());
- // After the guids are cleaned up, check the next alarm interval.
+ // After the connection_ids are cleaned up, check the next alarm interval.
int64 next_alarm_time = epoll_server_.ApproximateNowInUsec() +
time_wait_period.ToMicroseconds();
EXPECT_CALL(epoll_server_, RegisterAlarm(next_alarm_time, _));
- time_wait_list_manager_.CleanUpOldGuids();
- EXPECT_FALSE(IsGuidInTimeWait(guid_));
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
}
-TEST_F(QuicTimeWaitListManagerTest, GuidsOrderedByTime) {
- // Simple randomization: the values of guids are swapped based on the current
- // seconds on the clock. If the container is broken, the test will be 50%
- // flaky.
+TEST_F(QuicTimeWaitListManagerTest, ConnectionIdsOrderedByTime) {
+ // Simple randomization: the values of connection_ids are swapped based on the
+ // current seconds on the clock. If the container is broken, the test will be
+ // 50% flaky.
int odd_second = static_cast<int>(epoll_server_.ApproximateNowInUsec()) % 2;
EXPECT_TRUE(odd_second == 0 || odd_second == 1);
- const QuicGuid kGuid1 = odd_second;
- const QuicGuid kGuid2 = 1 - odd_second;
+ const QuicConnectionId kConnectionId1 = odd_second;
+ const QuicConnectionId kConnectionId2 = 1 - odd_second;
// 1 will hash lower than 2, but we add it later. They should come out in the
// add order, not hash order.
epoll_server_.set_now_in_usec(0);
- AddGuid(kGuid1);
+ AddConnectionId(kConnectionId1);
epoll_server_.set_now_in_usec(10);
- AddGuid(kGuid2);
+ AddConnectionId(kConnectionId2);
const QuicTime::Delta time_wait_period =
QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_);
@@ -414,9 +428,9 @@ TEST_F(QuicTimeWaitListManagerTest, GuidsOrderedByTime) {
EXPECT_CALL(epoll_server_, RegisterAlarm(_, _));
- time_wait_list_manager_.CleanUpOldGuids();
- EXPECT_FALSE(IsGuidInTimeWait(kGuid1));
- EXPECT_TRUE(IsGuidInTimeWait(kGuid2));
+ time_wait_list_manager_.CleanUpOldConnectionIds();
+ EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1));
+ EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2));
}
} // namespace
} // namespace test
diff --git a/net/tools/quic/test_tools/http_message_test_utils.cc b/net/tools/quic/test_tools/http_message.cc
index 70eb592..9bd3cff 100644
--- a/net/tools/quic/test_tools/http_message_test_utils.cc
+++ b/net/tools/quic/test_tools/http_message.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include <vector>
diff --git a/net/tools/quic/test_tools/http_message_test_utils.h b/net/tools/quic/test_tools/http_message.h
index fefdb49..6b63daf 100644
--- a/net/tools/quic/test_tools/http_message_test_utils.h
+++ b/net/tools/quic/test_tools/http_message.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
-#define NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
+#ifndef NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
+#define NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
#include <string>
#include <vector>
@@ -130,4 +130,4 @@ class HTTPMessage {
} // namespace tools
} // namespace net
-#endif // NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_TEST_UTILS_H_
+#endif // NET_TOOLS_QUIC_TEST_TOOLS_TEST_TOOLS_HTTP_MESSAGE_H_
diff --git a/net/tools/quic/test_tools/quic_test_client.cc b/net/tools/quic/test_tools/quic_test_client.cc
index aac75ab..8cfeefb 100644
--- a/net/tools/quic/test_tools/quic_test_client.cc
+++ b/net/tools/quic/test_tools/quic_test_client.cc
@@ -15,7 +15,7 @@
#include "net/tools/quic/quic_epoll_connection_helper.h"
#include "net/tools/quic/quic_packet_writer_wrapper.h"
#include "net/tools/quic/quic_spdy_client_stream.h"
-#include "net/tools/quic/test_tools/http_message_test_utils.h"
+#include "net/tools/quic/test_tools/http_message.h"
#include "net/tools/quic/test_tools/quic_client_peer.h"
#include "url/gurl.h"
@@ -102,7 +102,7 @@ class MockableQuicClient : public QuicClient {
const string& server_hostname,
const QuicVersionVector& supported_versions)
: QuicClient(server_address, server_hostname, supported_versions, false),
- override_guid_(0),
+ override_connection_id_(0),
test_writer_(NULL) {}
MockableQuicClient(IPEndPoint server_address,
@@ -110,7 +110,7 @@ class MockableQuicClient : public QuicClient {
const QuicConfig& config,
const QuicVersionVector& supported_versions)
: QuicClient(server_address, server_hostname, config, supported_versions),
- override_guid_(0),
+ override_connection_id_(0),
test_writer_(NULL) {}
virtual ~MockableQuicClient() {
@@ -128,17 +128,20 @@ class MockableQuicClient : public QuicClient {
return test_writer_;
}
- virtual QuicGuid GenerateGuid() OVERRIDE {
- return override_guid_ ? override_guid_ : QuicClient::GenerateGuid();
+ virtual QuicConnectionId GenerateConnectionId() OVERRIDE {
+ return override_connection_id_ ? override_connection_id_
+ : QuicClient::GenerateConnectionId();
}
// Takes ownership of writer.
void UseWriter(QuicPacketWriterWrapper* writer) { test_writer_ = writer; }
- void UseGuid(QuicGuid guid) { override_guid_ = guid; }
+ void UseConnectionId(QuicConnectionId connection_id) {
+ override_connection_id_ = connection_id;
+ }
private:
- QuicGuid override_guid_; // GUID to use, if nonzero
+ QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero
QuicPacketWriterWrapper* test_writer_;
};
@@ -445,9 +448,9 @@ void QuicTestClient::UseWriter(QuicPacketWriterWrapper* writer) {
client_->UseWriter(writer);
}
-void QuicTestClient::UseGuid(QuicGuid guid) {
+void QuicTestClient::UseConnectionId(QuicConnectionId connection_id) {
DCHECK(!connected());
- client_->UseGuid(guid);
+ client_->UseConnectionId(connection_id);
}
void QuicTestClient::WaitForWriteToFlush() {
diff --git a/net/tools/quic/test_tools/quic_test_client.h b/net/tools/quic/test_tools/quic_test_client.h
index b750cbff..fd1f4c4 100644
--- a/net/tools/quic/test_tools/quic_test_client.h
+++ b/net/tools/quic/test_tools/quic_test_client.h
@@ -89,9 +89,9 @@ class QuicTestClient : public QuicDataStream::Visitor {
// Configures client_ to take ownership of and use the writer.
// Must be called before initial connect.
void UseWriter(QuicPacketWriterWrapper* writer);
- // If the given GUID is nonzero, configures client_ to use a specific GUID
- // instead of a random one.
- void UseGuid(QuicGuid guid);
+ // If the given ConnectionId is nonzero, configures client_ to use a specific
+ // ConnectionId instead of a random one.
+ void UseConnectionId(QuicConnectionId connection_id);
// Returns NULL if the maximum number of streams have already been created.
QuicSpdyClientStream* GetOrCreateStream();
diff --git a/net/tools/quic/test_tools/quic_test_utils.cc b/net/tools/quic/test_tools/quic_test_utils.cc
index 9b82b9d..9ae1a3d 100644
--- a/net/tools/quic/test_tools/quic_test_utils.cc
+++ b/net/tools/quic/test_tools/quic_test_utils.cc
@@ -18,7 +18,7 @@ namespace tools {
namespace test {
MockConnection::MockConnection(bool is_server)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -29,7 +29,7 @@ MockConnection::MockConnection(bool is_server)
MockConnection::MockConnection(IPEndPoint address,
bool is_server)
- : QuicConnection(kTestGuid, address,
+ : QuicConnection(kTestConnectionId, address,
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
is_server, QuicSupportedVersions()),
@@ -37,9 +37,9 @@ MockConnection::MockConnection(IPEndPoint address,
helper_(helper()) {
}
-MockConnection::MockConnection(QuicGuid guid,
+MockConnection::MockConnection(QuicConnectionId connection_id,
bool is_server)
- : QuicConnection(guid,
+ : QuicConnection(connection_id,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
@@ -50,7 +50,7 @@ MockConnection::MockConnection(QuicGuid guid,
MockConnection::MockConnection(bool is_server,
const QuicVersionVector& supported_versions)
- : QuicConnection(kTestGuid,
+ : QuicConnection(kTestConnectionId,
IPEndPoint(net::test::Loopback4(), kTestPort),
new testing::NiceMock<MockHelper>(),
new testing::NiceMock<MockPacketWriter>(),
diff --git a/net/tools/quic/test_tools/quic_test_utils.h b/net/tools/quic/test_tools/quic_test_utils.h
index e2f9c57..da8c269 100644
--- a/net/tools/quic/test_tools/quic_test_utils.h
+++ b/net/tools/quic/test_tools/quic_test_utils.h
@@ -26,7 +26,7 @@ class IPEndPoint;
namespace tools {
namespace test {
-static const QuicGuid kTestGuid = 42;
+static const QuicConnectionId kTestConnectionId = 42;
static const int kTestPort = 123;
// Simple random number generator used to compute random numbers suitable
@@ -48,16 +48,16 @@ class SimpleRandom {
class MockConnection : public QuicConnection {
public:
- // Uses a MockHelper, GUID of 42, and 127.0.0.1:123.
+ // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
explicit MockConnection(bool is_server);
- // Uses a MockHelper, GUID of 42.
+ // Uses a MockHelper, ConnectionId of 42.
MockConnection(IPEndPoint address, bool is_server);
// Uses a MockHelper, and 127.0.0.1:123
- MockConnection(QuicGuid guid, bool is_server);
+ MockConnection(QuicConnectionId connection_id, bool is_server);
- // Uses a Mock helper, GUID of 42, and 127.0.0.1:123.
+ // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123.
MockConnection(bool is_server, const QuicVersionVector& supported_versions);
virtual ~MockConnection();
@@ -79,6 +79,9 @@ class MockConnection : public QuicConnection {
MOCK_METHOD3(SendGoAway, void(QuicErrorCode error,
QuicStreamId last_good_stream_id,
const std::string& reason));
+ MOCK_METHOD1(SendBlocked, void(QuicStreamId id));
+ MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id,
+ QuicStreamOffset byte_offset));
MOCK_METHOD0(OnCanWrite, void());
MOCK_CONST_METHOD0(HasPendingWrites, bool());
@@ -133,7 +136,8 @@ class MockQuicServerSessionVisitor : public QuicServerSessionVisitor {
public:
MockQuicServerSessionVisitor();
virtual ~MockQuicServerSessionVisitor();
- MOCK_METHOD2(OnConnectionClosed, void(QuicGuid guid, QuicErrorCode error));
+ MOCK_METHOD2(OnConnectionClosed, void(QuicConnectionId connection_id,
+ QuicErrorCode error));
MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer));
};