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

Unified Diff: net/quic/test_tools/quic_stream_factory_peer.cc

Issue 1502453003: QUIC - Disable Preconnect when QUIC can be spoken to a server with 0RTT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test name Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_stream_factory_peer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/quic_stream_factory_peer.cc
diff --git a/net/quic/test_tools/quic_stream_factory_peer.cc b/net/quic/test_tools/quic_stream_factory_peer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7f002fb51370b96a59643744b7316c49609deb10
--- /dev/null
+++ b/net/quic/test_tools/quic_stream_factory_peer.cc
@@ -0,0 +1,165 @@
+// Copyright 2015 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/quic/test_tools/quic_stream_factory_peer.h"
+
+#include "net/quic/crypto/quic_crypto_client_config.h"
+#include "net/quic/quic_chromium_client_session.h"
+#include "net/quic/quic_clock.h"
+#include "net/quic/quic_http_stream.h"
+#include "net/quic/quic_stream_factory.h"
+
+using std::string;
+using std::vector;
+
+namespace net {
+namespace test {
+
+const QuicConfig* QuicStreamFactoryPeer::GetConfig(QuicStreamFactory* factory) {
+ return &factory->config_;
+}
+
+QuicCryptoClientConfig* QuicStreamFactoryPeer::GetCryptoConfig(
+ QuicStreamFactory* factory) {
+ return &factory->crypto_config_;
+}
+
+bool QuicStreamFactoryPeer::HasActiveSession(
+ QuicStreamFactory* factory,
+ const HostPortPair& host_port_pair) {
+ QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
+ return factory->HasActiveSession(server_id);
+}
+
+QuicChromiumClientSession* QuicStreamFactoryPeer::GetActiveSession(
+ QuicStreamFactory* factory,
+ const HostPortPair& host_port_pair) {
+ QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
+ DCHECK(factory->HasActiveSession(server_id));
+ return factory->active_sessions_[server_id];
+}
+
+scoped_ptr<QuicHttpStream> QuicStreamFactoryPeer::CreateFromSession(
+ QuicStreamFactory* factory,
+ QuicChromiumClientSession* session) {
+ return factory->CreateFromSession(session);
+}
+
+bool QuicStreamFactoryPeer::IsLiveSession(QuicStreamFactory* factory,
+ QuicChromiumClientSession* session) {
+ for (QuicStreamFactory::SessionIdMap::iterator it =
+ factory->all_sessions_.begin();
+ it != factory->all_sessions_.end(); ++it) {
+ if (it->first == session)
+ return true;
+ }
+ return false;
+}
+
+void QuicStreamFactoryPeer::SetTaskRunner(QuicStreamFactory* factory,
+ base::TaskRunner* task_runner) {
+ factory->task_runner_ = task_runner;
+}
+
+int QuicStreamFactoryPeer::GetNumberOfLossyConnections(
+ QuicStreamFactory* factory,
+ uint16 port) {
+ return factory->number_of_lossy_connections_[port];
+}
+
+bool QuicStreamFactoryPeer::IsQuicDisabled(QuicStreamFactory* factory,
+ uint16 port) {
+ return factory->IsQuicDisabled(port);
+}
+
+bool QuicStreamFactoryPeer::GetDelayTcpRace(QuicStreamFactory* factory) {
+ return factory->delay_tcp_race_;
+}
+
+void QuicStreamFactoryPeer::SetDelayTcpRace(QuicStreamFactory* factory,
+ bool delay_tcp_race) {
+ factory->delay_tcp_race_ = delay_tcp_race;
+}
+
+void QuicStreamFactoryPeer::SetYieldAfterPackets(QuicStreamFactory* factory,
+ int yield_after_packets) {
+ factory->yield_after_packets_ = yield_after_packets;
+}
+
+void QuicStreamFactoryPeer::SetYieldAfterDuration(
+ QuicStreamFactory* factory,
+ QuicTime::Delta yield_after_duration) {
+ factory->yield_after_duration_ = yield_after_duration;
+}
+
+size_t QuicStreamFactoryPeer::GetNumberOfActiveJobs(
+ QuicStreamFactory* factory,
+ const QuicServerId& server_id) {
+ return (factory->active_jobs_[server_id]).size();
+}
+
+int QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(
+ QuicStreamFactory* factory) {
+ return factory->num_timeouts_with_open_streams_;
+}
+
+int QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(
+ QuicStreamFactory* factory) {
+ return factory->num_public_resets_post_handshake_;
+}
+
+void QuicStreamFactoryPeer::MaybeInitialize(QuicStreamFactory* factory) {
+ factory->MaybeInitialize();
+}
+
+bool QuicStreamFactoryPeer::HasInitializedData(QuicStreamFactory* factory) {
+ return factory->has_initialized_data_;
+}
+
+bool QuicStreamFactoryPeer::SupportsQuicAtStartUp(QuicStreamFactory* factory,
+ HostPortPair host_port_pair) {
+ return ContainsKey(factory->quic_supported_servers_at_startup_,
+ host_port_pair);
+}
+
+bool QuicStreamFactoryPeer::CryptoConfigCacheIsEmpty(
+ QuicStreamFactory* factory,
+ QuicServerId& quic_server_id) {
+ return factory->CryptoConfigCacheIsEmpty(quic_server_id);
+}
+
+void QuicStreamFactoryPeer::CacheDummyServerConfig(
+ QuicStreamFactory* factory,
+ const QuicServerId& quic_server_id) {
+ // Minimum SCFG that passes config validation checks.
+ const char scfg[] = {// SCFG
+ 0x53, 0x43, 0x46, 0x47,
+ // num entries
+ 0x01, 0x00,
+ // padding
+ 0x00, 0x00,
+ // EXPY
+ 0x45, 0x58, 0x50, 0x59,
+ // EXPY end offset
+ 0x08, 0x00, 0x00, 0x00,
+ // Value
+ '1', '2', '3', '4', '5', '6', '7', '8'};
+
+ string server_config(reinterpret_cast<const char*>(&scfg), sizeof(scfg));
+ string source_address_token("test_source_address_token");
+ string signature("test_signature");
+ string test_cert("test_cert");
+ vector<string> certs;
+ certs.push_back(test_cert);
+
+ QuicCryptoClientConfig* crypto_config = &factory->crypto_config_;
+ QuicCryptoClientConfig::CachedState* cached =
+ crypto_config->LookupOrCreate(quic_server_id);
+ QuicClock clock;
+ cached->Initialize(server_config, source_address_token, certs, "", signature,
+ clock.WallNow());
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/test_tools/quic_stream_factory_peer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698