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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 | 67 |
67 // Minimum seconds that unclaimed pushed streams will be kept in memory. | 68 // Minimum seconds that unclaimed pushed streams will be kept in memory. |
68 const int kMinPushedStreamLifetimeSeconds = 300; | 69 const int kMinPushedStreamLifetimeSeconds = 300; |
69 | 70 |
70 // Default initial value for HTTP/2 SETTINGS. | 71 // Default initial value for HTTP/2 SETTINGS. |
71 const uint32_t kDefaultInitialHeaderTableSize = 4096; | 72 const uint32_t kDefaultInitialHeaderTableSize = 4096; |
72 const uint32_t kDefaultInitialEnablePush = 1; | 73 const uint32_t kDefaultInitialEnablePush = 1; |
73 const uint32_t kDefaultInitialInitialWindowSize = 65535; | 74 const uint32_t kDefaultInitialInitialWindowSize = 65535; |
74 const uint32_t kDefaultInitialMaxFrameSize = 16384; | 75 const uint32_t kDefaultInitialMaxFrameSize = 16384; |
75 | 76 |
77 // Experiment to close idle H2 sockets when SpdySession is initialized. | |
78 const base::Feature kCloseIdleH2SocketsEarlyExperiment{ | |
79 "CloseIdleH2SocketsEarly", base::FEATURE_DISABLED_BY_DEFAULT}; | |
80 | |
76 bool IsSpdySettingAtDefaultInitialValue(SpdySettingsIds setting_id, | 81 bool IsSpdySettingAtDefaultInitialValue(SpdySettingsIds setting_id, |
77 uint32_t value) { | 82 uint32_t value) { |
78 switch (setting_id) { | 83 switch (setting_id) { |
79 case SETTINGS_HEADER_TABLE_SIZE: | 84 case SETTINGS_HEADER_TABLE_SIZE: |
80 return value == kDefaultInitialHeaderTableSize; | 85 return value == kDefaultInitialHeaderTableSize; |
81 case SETTINGS_ENABLE_PUSH: | 86 case SETTINGS_ENABLE_PUSH: |
82 return value == kDefaultInitialEnablePush; | 87 return value == kDefaultInitialEnablePush; |
83 case SETTINGS_MAX_CONCURRENT_STREAMS: | 88 case SETTINGS_MAX_CONCURRENT_STREAMS: |
84 // There is no initial limit on the number of concurrent streams. | 89 // There is no initial limit on the number of concurrent streams. |
85 return false; | 90 return false; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 new_hostname, ssl_info.cert.get(), ssl_info.public_key_hashes)) { | 700 new_hostname, ssl_info.cert.get(), ssl_info.public_key_hashes)) { |
696 return false; | 701 return false; |
697 } | 702 } |
698 | 703 |
699 return true; | 704 return true; |
700 } | 705 } |
701 | 706 |
702 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, | 707 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, |
703 HttpServerProperties* http_server_properties, | 708 HttpServerProperties* http_server_properties, |
704 TransportSecurityState* transport_security_state, | 709 TransportSecurityState* transport_security_state, |
710 HttpNetworkSession* http_network_session, | |
705 bool enable_sending_initial_data, | 711 bool enable_sending_initial_data, |
706 bool enable_ping_based_connection_checking, | 712 bool enable_ping_based_connection_checking, |
707 size_t session_max_recv_window_size, | 713 size_t session_max_recv_window_size, |
708 const SettingsMap& initial_settings, | 714 const SettingsMap& initial_settings, |
709 TimeFunc time_func, | 715 TimeFunc time_func, |
710 ServerPushDelegate* push_delegate, | 716 ServerPushDelegate* push_delegate, |
711 ProxyDelegate* proxy_delegate, | 717 ProxyDelegate* proxy_delegate, |
712 NetLog* net_log) | 718 NetLog* net_log) |
713 : in_io_loop_(false), | 719 : in_io_loop_(false), |
714 spdy_session_key_(spdy_session_key), | 720 spdy_session_key_(spdy_session_key), |
715 pool_(NULL), | 721 pool_(NULL), |
716 http_server_properties_(http_server_properties), | 722 http_server_properties_(http_server_properties), |
717 transport_security_state_(transport_security_state), | 723 transport_security_state_(transport_security_state), |
724 http_network_session_(http_network_session), | |
718 read_buffer_(new IOBuffer(kReadBufferSize)), | 725 read_buffer_(new IOBuffer(kReadBufferSize)), |
719 stream_hi_water_mark_(kFirstStreamId), | 726 stream_hi_water_mark_(kFirstStreamId), |
720 last_accepted_push_stream_id_(0), | 727 last_accepted_push_stream_id_(0), |
721 unclaimed_pushed_streams_(this), | 728 unclaimed_pushed_streams_(this), |
722 push_delegate_(push_delegate), | 729 push_delegate_(push_delegate), |
723 num_pushed_streams_(0u), | 730 num_pushed_streams_(0u), |
724 num_active_pushed_streams_(0u), | 731 num_active_pushed_streams_(0u), |
725 bytes_pushed_count_(0u), | 732 bytes_pushed_count_(0u), |
726 bytes_pushed_and_unclaimed_count_(0u), | 733 bytes_pushed_and_unclaimed_count_(0u), |
727 in_flight_write_frame_type_(DATA), | 734 in_flight_write_frame_type_(DATA), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED, | 826 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED, |
820 base::Bind(&NetLogSpdyInitializedCallback, | 827 base::Bind(&NetLogSpdyInitializedCallback, |
821 connection_->socket()->NetLog().source())); | 828 connection_->socket()->NetLog().source())); |
822 | 829 |
823 DCHECK_EQ(availability_state_, STATE_AVAILABLE); | 830 DCHECK_EQ(availability_state_, STATE_AVAILABLE); |
824 connection_->AddHigherLayeredPool(this); | 831 connection_->AddHigherLayeredPool(this); |
825 if (enable_sending_initial_data_) | 832 if (enable_sending_initial_data_) |
826 SendInitialData(); | 833 SendInitialData(); |
827 pool_ = pool; | 834 pool_ = pool; |
828 | 835 |
836 if (base::FeatureList::IsEnabled(kCloseIdleH2SocketsEarlyExperiment)) { | |
837 // Close idle sockets in this group, since subsequent requests will go over | |
838 // this Http2 connection. | |
Bence
2017/02/08 00:18:52
s/'Http2'/'HTTP/2'/
xunjieli
2017/02/08 14:15:40
Done.
| |
839 http_network_session_->CloseIdleConnectionsInGroup( | |
840 connection_->group_name()); | |
841 } | |
842 | |
829 // Bootstrap the read loop. | 843 // Bootstrap the read loop. |
830 base::ThreadTaskRunnerHandle::Get()->PostTask( | 844 base::ThreadTaskRunnerHandle::Get()->PostTask( |
831 FROM_HERE, | 845 FROM_HERE, |
832 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), | 846 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), |
833 READ_STATE_DO_READ, OK)); | 847 READ_STATE_DO_READ, OK)); |
834 } | 848 } |
835 | 849 |
836 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { | 850 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
837 if (availability_state_ == STATE_DRAINING) | 851 if (availability_state_ == STATE_DRAINING) |
838 return false; | 852 return false; |
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3129 if (!queue->empty()) { | 3143 if (!queue->empty()) { |
3130 SpdyStreamId stream_id = queue->front(); | 3144 SpdyStreamId stream_id = queue->front(); |
3131 queue->pop_front(); | 3145 queue->pop_front(); |
3132 return stream_id; | 3146 return stream_id; |
3133 } | 3147 } |
3134 } | 3148 } |
3135 return 0; | 3149 return 0; |
3136 } | 3150 } |
3137 | 3151 |
3138 } // namespace net | 3152 } // namespace net |
OLD | NEW |