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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 2678353003: Close idle H2 sockets when SpdySession is initialized. (Closed)
Patch Set: Self Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
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
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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 new_hostname, ssl_info.cert.get(), ssl_info.public_key_hashes)) { 710 new_hostname, ssl_info.cert.get(), ssl_info.public_key_hashes)) {
706 return false; 711 return false;
707 } 712 }
708 713
709 return true; 714 return true;
710 } 715 }
711 716
712 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, 717 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
713 HttpServerProperties* http_server_properties, 718 HttpServerProperties* http_server_properties,
714 TransportSecurityState* transport_security_state, 719 TransportSecurityState* transport_security_state,
720 HttpNetworkSession* http_network_session,
715 bool enable_sending_initial_data, 721 bool enable_sending_initial_data,
716 bool enable_ping_based_connection_checking, 722 bool enable_ping_based_connection_checking,
717 size_t session_max_recv_window_size, 723 size_t session_max_recv_window_size,
718 const SettingsMap& initial_settings, 724 const SettingsMap& initial_settings,
719 TimeFunc time_func, 725 TimeFunc time_func,
720 ServerPushDelegate* push_delegate, 726 ServerPushDelegate* push_delegate,
721 ProxyDelegate* proxy_delegate, 727 ProxyDelegate* proxy_delegate,
722 NetLog* net_log) 728 NetLog* net_log)
723 : in_io_loop_(false), 729 : in_io_loop_(false),
724 spdy_session_key_(spdy_session_key), 730 spdy_session_key_(spdy_session_key),
725 pool_(NULL), 731 pool_(NULL),
726 http_server_properties_(http_server_properties), 732 http_server_properties_(http_server_properties),
727 transport_security_state_(transport_security_state), 733 transport_security_state_(transport_security_state),
734 http_network_session_(http_network_session),
728 read_buffer_(new IOBuffer(kReadBufferSize)), 735 read_buffer_(new IOBuffer(kReadBufferSize)),
729 stream_hi_water_mark_(kFirstStreamId), 736 stream_hi_water_mark_(kFirstStreamId),
730 last_accepted_push_stream_id_(0), 737 last_accepted_push_stream_id_(0),
731 unclaimed_pushed_streams_(this), 738 unclaimed_pushed_streams_(this),
732 push_delegate_(push_delegate), 739 push_delegate_(push_delegate),
733 num_pushed_streams_(0u), 740 num_pushed_streams_(0u),
734 num_active_pushed_streams_(0u), 741 num_active_pushed_streams_(0u),
735 bytes_pushed_count_(0u), 742 bytes_pushed_count_(0u),
736 bytes_pushed_and_unclaimed_count_(0u), 743 bytes_pushed_and_unclaimed_count_(0u),
737 in_flight_write_frame_type_(DATA), 744 in_flight_write_frame_type_(DATA),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED, 890 net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED,
884 base::Bind(&NetLogSpdyInitializedCallback, 891 base::Bind(&NetLogSpdyInitializedCallback,
885 connection_->socket()->NetLog().source())); 892 connection_->socket()->NetLog().source()));
886 893
887 DCHECK_EQ(availability_state_, STATE_AVAILABLE); 894 DCHECK_EQ(availability_state_, STATE_AVAILABLE);
888 connection_->AddHigherLayeredPool(this); 895 connection_->AddHigherLayeredPool(this);
889 if (enable_sending_initial_data_) 896 if (enable_sending_initial_data_)
890 SendInitialData(); 897 SendInitialData();
891 pool_ = pool; 898 pool_ = pool;
892 899
900 if (base::FeatureList::IsEnabled(kCloseIdleH2SocketsEarlyExperiment)) {
901 // Close idle sockets in this group, since subsequent requests will go over
902 // this HTTP/2 connection.
903 http_network_session_->CloseIdleConnectionsInGroup(
904 connection_->group_name());
905 }
906
893 // Bootstrap the read loop. 907 // Bootstrap the read loop.
894 base::ThreadTaskRunnerHandle::Get()->PostTask( 908 base::ThreadTaskRunnerHandle::Get()->PostTask(
895 FROM_HERE, 909 FROM_HERE,
896 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), 910 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(),
897 READ_STATE_DO_READ, OK)); 911 READ_STATE_DO_READ, OK));
898 } 912 }
899 913
900 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { 914 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
901 if (availability_state_ == STATE_DRAINING) 915 if (availability_state_ == STATE_DRAINING)
902 return false; 916 return false;
(...skipping 2227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 if (!queue->empty()) { 3144 if (!queue->empty()) {
3131 SpdyStreamId stream_id = queue->front(); 3145 SpdyStreamId stream_id = queue->front();
3132 queue->pop_front(); 3146 queue->pop_front();
3133 return stream_id; 3147 return stream_id;
3134 } 3148 }
3135 } 3149 }
3136 return 0; 3150 return 0;
3137 } 3151 }
3138 3152
3139 } // namespace net 3153 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698