Add IS_TIZEN_DA to fix build break in standard build.
[platform/framework/web/chromium-efl.git] / net / quic / quic_context.cc
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/quic_context.h"
6
7 #include "base/containers/contains.h"
8 #include "net/quic/platform/impl/quic_chromium_clock.h"
9 #include "net/quic/quic_chromium_connection_helper.h"
10 #include "net/ssl/cert_compression.h"
11 #include "net/ssl/ssl_key_logger.h"
12 #include "net/third_party/quiche/src/quiche/quic/core/crypto/crypto_protocol.h"
13 #include "net/third_party/quiche/src/quiche/quic/core/crypto/quic_random.h"
14 #include "net/third_party/quiche/src/quiche/quic/core/quic_constants.h"
15
16 namespace net {
17
18 namespace {
19
20 // The maximum receive window sizes for QUIC sessions and streams.
21 const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024;  // 15 MB
22 const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024;    // 6 MB
23
24 // Set the maximum number of undecryptable packets the connection will store.
25 const int32_t kMaxUndecryptablePackets = 100;
26
27 }  // namespace
28
29 QuicParams::QuicParams() = default;
30
31 QuicParams::QuicParams(const QuicParams& other) = default;
32
33 QuicParams::~QuicParams() = default;
34
35 QuicContext::QuicContext()
36     : QuicContext(std::make_unique<QuicChromiumConnectionHelper>(
37           quic::QuicChromiumClock::GetInstance(),
38           quic::QuicRandom::GetInstance())) {}
39
40 QuicContext::QuicContext(
41     std::unique_ptr<quic::QuicConnectionHelperInterface> helper)
42     : helper_(std::move(helper)) {}
43
44 QuicContext::~QuicContext() = default;
45
46 quic::QuicConfig InitializeQuicConfig(const QuicParams& params) {
47   DCHECK_GT(params.idle_connection_timeout, base::TimeDelta());
48   quic::QuicConfig config;
49   config.SetIdleNetworkTimeout(
50       quic::QuicTime::Delta::FromMicroseconds(
51           params.idle_connection_timeout.InMicroseconds()));
52   config.set_max_time_before_crypto_handshake(
53       quic::QuicTime::Delta::FromMicroseconds(
54           params.max_time_before_crypto_handshake.InMicroseconds()));
55   config.set_max_idle_time_before_crypto_handshake(
56       quic::QuicTime::Delta::FromMicroseconds(
57           params.max_idle_time_before_crypto_handshake.InMicroseconds()));
58   quic::QuicTagVector copt_to_send = params.connection_options;
59   config.SetConnectionOptionsToSend(copt_to_send);
60   config.SetClientConnectionOptions(params.client_connection_options);
61   config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
62   config.SetInitialSessionFlowControlWindowToSend(
63       kQuicSessionMaxRecvWindowSize);
64   config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize);
65   config.SetBytesForConnectionIdToSend(0);
66   return config;
67 }
68
69 void ConfigureQuicCryptoClientConfig(
70     quic::QuicCryptoClientConfig& crypto_config) {
71   if (SSLKeyLoggerManager::IsActive()) {
72     SSL_CTX_set_keylog_callback(crypto_config.ssl_ctx(),
73                                 SSLKeyLoggerManager::KeyLogCallback);
74   }
75   ConfigureCertificateCompression(crypto_config.ssl_ctx());
76 }
77
78 }  // namespace net