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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/feature_list.h" |
14 #include "base/location.h" | 15 #include "base/location.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
17 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
18 #include "base/metrics/sparse_histogram.h" | 19 #include "base/metrics/sparse_histogram.h" |
19 #include "base/profiler/scoped_tracker.h" | 20 #include "base/profiler/scoped_tracker.h" |
20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
21 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 // Minimum seconds that unclaimed pushed streams will be kept in memory. | 69 // Minimum seconds that unclaimed pushed streams will be kept in memory. |
69 const int kMinPushedStreamLifetimeSeconds = 300; | 70 const int kMinPushedStreamLifetimeSeconds = 300; |
70 | 71 |
71 // Default initial value for HTTP/2 SETTINGS. | 72 // Default initial value for HTTP/2 SETTINGS. |
72 const uint32_t kDefaultInitialHeaderTableSize = 4096; | 73 const uint32_t kDefaultInitialHeaderTableSize = 4096; |
73 const uint32_t kDefaultInitialEnablePush = 1; | 74 const uint32_t kDefaultInitialEnablePush = 1; |
74 const uint32_t kDefaultInitialInitialWindowSize = 65535; | 75 const uint32_t kDefaultInitialInitialWindowSize = 65535; |
75 const uint32_t kDefaultInitialMaxFrameSize = 16384; | 76 const uint32_t kDefaultInitialMaxFrameSize = 16384; |
76 | 77 |
| 78 // Experiment to close idle H2 sockets when SpdySession is initialized. |
| 79 const base::Feature kCloseIdleH2SocketsEarlyExperiment{ |
| 80 "CloseIdleH2SocketsEarly", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 81 |
77 bool IsSpdySettingAtDefaultInitialValue(SpdySettingsIds setting_id, | 82 bool IsSpdySettingAtDefaultInitialValue(SpdySettingsIds setting_id, |
78 uint32_t value) { | 83 uint32_t value) { |
79 switch (setting_id) { | 84 switch (setting_id) { |
80 case SETTINGS_HEADER_TABLE_SIZE: | 85 case SETTINGS_HEADER_TABLE_SIZE: |
81 return value == kDefaultInitialHeaderTableSize; | 86 return value == kDefaultInitialHeaderTableSize; |
82 case SETTINGS_ENABLE_PUSH: | 87 case SETTINGS_ENABLE_PUSH: |
83 return value == kDefaultInitialEnablePush; | 88 return value == kDefaultInitialEnablePush; |
84 case SETTINGS_MAX_CONCURRENT_STREAMS: | 89 case SETTINGS_MAX_CONCURRENT_STREAMS: |
85 // There is no initial limit on the number of concurrent streams. | 90 // There is no initial limit on the number of concurrent streams. |
86 return false; | 91 return false; |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED, | 898 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED, |
894 base::Bind(&NetLogSpdyInitializedCallback, | 899 base::Bind(&NetLogSpdyInitializedCallback, |
895 connection_->socket()->NetLog().source())); | 900 connection_->socket()->NetLog().source())); |
896 | 901 |
897 DCHECK_EQ(availability_state_, STATE_AVAILABLE); | 902 DCHECK_EQ(availability_state_, STATE_AVAILABLE); |
898 connection_->AddHigherLayeredPool(this); | 903 connection_->AddHigherLayeredPool(this); |
899 if (enable_sending_initial_data_) | 904 if (enable_sending_initial_data_) |
900 SendInitialData(); | 905 SendInitialData(); |
901 pool_ = pool; | 906 pool_ = pool; |
902 | 907 |
| 908 if (base::FeatureList::IsEnabled(kCloseIdleH2SocketsEarlyExperiment)) { |
| 909 // Close idle sockets in this group, since subsequent requests will go over |
| 910 // this HTTP/2 connection. |
| 911 connection_->CloseIdleSocketsInGroup(); |
| 912 } |
| 913 |
903 // Bootstrap the read loop. | 914 // Bootstrap the read loop. |
904 base::ThreadTaskRunnerHandle::Get()->PostTask( | 915 base::ThreadTaskRunnerHandle::Get()->PostTask( |
905 FROM_HERE, | 916 FROM_HERE, |
906 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), | 917 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), |
907 READ_STATE_DO_READ, OK)); | 918 READ_STATE_DO_READ, OK)); |
908 } | 919 } |
909 | 920 |
910 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { | 921 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
911 if (availability_state_ == STATE_DRAINING) | 922 if (availability_state_ == STATE_DRAINING) |
912 return false; | 923 return false; |
(...skipping 2245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3158 if (!queue->empty()) { | 3169 if (!queue->empty()) { |
3159 SpdyStreamId stream_id = queue->front(); | 3170 SpdyStreamId stream_id = queue->front(); |
3160 queue->pop_front(); | 3171 queue->pop_front(); |
3161 return stream_id; | 3172 return stream_id; |
3162 } | 3173 } |
3163 } | 3174 } |
3164 return 0; | 3175 return 0; |
3165 } | 3176 } |
3166 | 3177 |
3167 } // namespace net | 3178 } // namespace net |
OLD | NEW |