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

Unified Diff: net/spdy/spdy_session.cc

Issue 2600973002: Implement HTTP/2 settings field trial parameters. (Closed)
Patch Set: Created 4 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
Index: net/spdy/spdy_session.cc
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 1fd628378b47822982837fac059febfcef8ad356..e5c00d351c8d74e9de0c662cdfed4ebbe6f7f545 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -655,7 +655,7 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
bool enable_sending_initial_data,
bool enable_ping_based_connection_checking,
size_t session_max_recv_window_size,
- size_t stream_max_recv_window_size,
+ const SettingsMap& settings,
TimeFunc time_func,
ServerPushDelegate* push_delegate,
ProxyDelegate* proxy_delegate,
@@ -681,8 +681,10 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
read_state_(READ_STATE_DO_READ),
write_state_(WRITE_STATE_IDLE),
error_on_close_(OK),
+ settings_(settings),
max_concurrent_streams_(kInitialMaxConcurrentStreams),
- max_concurrent_pushed_streams_(kMaxConcurrentPushedStreams),
+ max_concurrent_pushed_streams_(
+ settings.at(SETTINGS_MAX_CONCURRENT_STREAMS)),
streams_initiated_count_(0),
streams_pushed_count_(0),
streams_pushed_and_claimed_count_(0),
@@ -697,7 +699,8 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
session_recv_window_size_(0),
session_unacked_recv_window_bytes_(0),
stream_initial_send_window_size_(kDefaultInitialWindowSize),
- stream_max_recv_window_size_(stream_max_recv_window_size),
+ max_header_table_size_(settings.at(SETTINGS_HEADER_TABLE_SIZE)),
+ stream_max_recv_window_size_(settings.at(SETTINGS_INITIAL_WINDOW_SIZE)),
net_log_(
NetLogWithSource::Make(net_log, NetLogSourceType::HTTP2_SESSION)),
enable_sending_initial_data_(enable_sending_initial_data),
@@ -714,6 +717,11 @@ SpdySession::SpdySession(const SpdySessionKey& spdy_session_key,
base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair()));
next_unclaimed_push_stream_sweep_time_ = time_func_() +
base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds);
+
+ DCHECK(settings_.find(SETTINGS_HEADER_TABLE_SIZE) != settings_.end());
Ryan Hamilton 2016/12/27 22:32:43 Consider base::ContainsKey(settings_, SETTINGS_foo
Bence 2016/12/28 00:53:24 Done.
+ DCHECK(settings_.find(SETTINGS_MAX_CONCURRENT_STREAMS) != settings_.end());
+ DCHECK(settings_.find(SETTINGS_INITIAL_WINDOW_SIZE) != settings_.end());
+
// TODO(mbelshe): consider randomization of the stream_hi_water_mark.
}
@@ -755,7 +763,7 @@ void SpdySession::InitializeWithSocket(
buffered_spdy_framer_.reset(new BufferedSpdyFramer());
buffered_spdy_framer_->set_visitor(this);
buffered_spdy_framer_->set_debug_visitor(this);
- buffered_spdy_framer_->UpdateHeaderDecoderTableSize(kMaxHeaderTableSize);
+ buffered_spdy_framer_->UpdateHeaderDecoderTableSize(max_header_table_size_);
net_log_.AddEvent(NetLogEventType::HTTP2_SESSION_INITIALIZED,
base::Bind(&NetLogSpdyInitializedCallback,
@@ -2646,12 +2654,35 @@ void SpdySession::SendInitialData() {
std::move(connection_header_prefix_frame));
// First, notify the server about the settings they should use when
- // communicating with us.
+ // communicating with us. Only send settings that have a value different from
+ // the protocol default value.
SettingsMap settings_map;
- settings_map[SETTINGS_HEADER_TABLE_SIZE] = kMaxHeaderTableSize;
- settings_map[SETTINGS_MAX_CONCURRENT_STREAMS] = kMaxConcurrentPushedStreams;
- if (stream_max_recv_window_size_ != kDefaultInitialWindowSize) {
- settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = stream_max_recv_window_size_;
+ for (auto setting : settings_) {
+ switch (setting.first) {
+ case SETTINGS_HEADER_TABLE_SIZE:
+ if (setting.second == 4096)
Ryan Hamilton 2016/12/27 22:32:43 Can we define these magic numbers somewhere?
Bence 2016/12/28 00:53:24 Done.
+ continue;
+ break;
+ case SETTINGS_ENABLE_PUSH:
+ if (setting.second == 1)
+ continue;
+ break;
+ case SETTINGS_MAX_CONCURRENT_STREAMS:
+ break;
+ case SETTINGS_INITIAL_WINDOW_SIZE:
+ if (setting.second == 65535)
+ continue;
+ break;
+ case SETTINGS_MAX_FRAME_SIZE:
+ if (setting.second == 16384)
+ continue;
+ break;
+ case SETTINGS_MAX_HEADER_LIST_SIZE:
+ break;
+ default:
+ break;
+ }
+ settings_map.insert(setting);
}
SendSettings(settings_map);

Powered by Google App Engine
This is Rietveld 408576698