Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index 4c4900f5d8fd937612fa522491050cdc4459a867..aa3df1167bb6580336a4b274f851becf78eb6783 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -60,7 +60,8 @@ scoped_ptr<base::ListValue> SpdyHeaderBlockToListValue( |
net::NetLog::LogLevel log_level) { |
scoped_ptr<base::ListValue> headers_list(new base::ListValue()); |
for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
- it != headers.end(); ++it) { |
+ it != headers.end(); |
+ ++it) { |
headers_list->AppendString( |
it->first + ": " + |
ElideHeaderValueForNetLog(log_level, it->first, it->second)); |
@@ -84,14 +85,13 @@ base::Value* NetLogSpdySynStreamSentCallback(const SpdyHeaderBlock* headers, |
return dict; |
} |
-base::Value* NetLogSpdySynStreamReceivedCallback( |
- const SpdyHeaderBlock* headers, |
- bool fin, |
- bool unidirectional, |
- SpdyPriority spdy_priority, |
- SpdyStreamId stream_id, |
- SpdyStreamId associated_stream, |
- NetLog::LogLevel log_level) { |
+base::Value* NetLogSpdySynStreamReceivedCallback(const SpdyHeaderBlock* headers, |
+ bool fin, |
+ bool unidirectional, |
+ SpdyPriority spdy_priority, |
+ SpdyStreamId stream_id, |
+ SpdyStreamId associated_stream, |
+ NetLog::LogLevel log_level) { |
base::DictionaryValue* dict = new base::DictionaryValue(); |
dict->Set("headers", |
SpdyHeaderBlockToListValue(*headers, log_level).release()); |
@@ -158,7 +158,8 @@ base::Value* NetLogSpdySendSettingsCallback(const SettingsMap* settings, |
base::DictionaryValue* dict = new base::DictionaryValue(); |
base::ListValue* settings_list = new base::ListValue(); |
for (SettingsMap::const_iterator it = settings->begin(); |
- it != settings->end(); ++it) { |
+ it != settings->end(); |
+ ++it) { |
const SpdySettingsIds id = it->first; |
const SpdySettingsFlags flags = it->second.first; |
const uint32 value = it->second.second; |
@@ -228,8 +229,7 @@ base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, |
SpdyGoAwayStatus status, |
NetLog::LogLevel /* log_level */) { |
base::DictionaryValue* dict = new base::DictionaryValue(); |
- dict->SetInteger("last_accepted_stream_id", |
- static_cast<int>(last_stream_id)); |
+ dict->SetInteger("last_accepted_stream_id", static_cast<int>(last_stream_id)); |
dict->SetInteger("active_streams", active_streams); |
dict->SetInteger("unclaimed_streams", unclaimed_streams); |
dict->SetInteger("status", static_cast<int>(status)); |
@@ -238,7 +238,8 @@ base::Value* NetLogSpdyGoAwayCallback(SpdyStreamId last_stream_id, |
// Helper function to return the total size of an array of objects |
// with .size() member functions. |
-template <typename T, size_t N> size_t GetTotalSize(const T (&arr)[N]) { |
+template <typename T, size_t N> |
+size_t GetTotalSize(const T (&arr)[N]) { |
size_t total_size = 0; |
for (size_t i = 0; i < N; ++i) { |
total_size += arr[i].size(); |
@@ -269,7 +270,7 @@ const size_t kMaxConcurrentStreamLimit = 256; |
SpdyProtocolErrorDetails MapFramerErrorToProtocolError( |
SpdyFramer::SpdyError err) { |
- switch(err) { |
+ switch (err) { |
case SpdyFramer::SPDY_NO_ERROR: |
return SPDY_ERROR_NO_ERROR; |
case SpdyFramer::SPDY_INVALID_CONTROL_FRAME: |
@@ -302,7 +303,7 @@ SpdyProtocolErrorDetails MapFramerErrorToProtocolError( |
SpdyProtocolErrorDetails MapRstStreamStatusToProtocolError( |
SpdyRstStreamStatus status) { |
- switch(status) { |
+ switch (status) { |
case RST_STREAM_PROTOCOL_ERROR: |
return STATUS_CODE_PROTOCOL_ERROR; |
case RST_STREAM_INVALID_STREAM: |
@@ -345,13 +346,12 @@ SpdyStreamRequest::~SpdyStreamRequest() { |
CancelRequest(); |
} |
-int SpdyStreamRequest::StartRequest( |
- SpdyStreamType type, |
- const base::WeakPtr<SpdySession>& session, |
- const GURL& url, |
- RequestPriority priority, |
- const BoundNetLog& net_log, |
- const CompletionCallback& callback) { |
+int SpdyStreamRequest::StartRequest(SpdyStreamType type, |
+ const base::WeakPtr<SpdySession>& session, |
+ const GURL& url, |
+ RequestPriority priority, |
+ const BoundNetLog& net_log, |
+ const CompletionCallback& callback) { |
DCHECK(session); |
DCHECK(!session_); |
DCHECK(!stream_); |
@@ -422,24 +422,27 @@ void SpdyStreamRequest::Reset() { |
} |
SpdySession::ActiveStreamInfo::ActiveStreamInfo() |
- : stream(NULL), |
- waiting_for_syn_reply(false) {} |
+ : stream(NULL), waiting_for_syn_reply(false) { |
+} |
SpdySession::ActiveStreamInfo::ActiveStreamInfo(SpdyStream* stream) |
: stream(stream), |
- waiting_for_syn_reply(stream->type() != SPDY_PUSH_STREAM) {} |
+ waiting_for_syn_reply(stream->type() != SPDY_PUSH_STREAM) { |
+} |
-SpdySession::ActiveStreamInfo::~ActiveStreamInfo() {} |
+SpdySession::ActiveStreamInfo::~ActiveStreamInfo() { |
+} |
-SpdySession::PushedStreamInfo::PushedStreamInfo() : stream_id(0) {} |
+SpdySession::PushedStreamInfo::PushedStreamInfo() : stream_id(0) { |
+} |
-SpdySession::PushedStreamInfo::PushedStreamInfo( |
- SpdyStreamId stream_id, |
- base::TimeTicks creation_time) |
- : stream_id(stream_id), |
- creation_time(creation_time) {} |
+SpdySession::PushedStreamInfo::PushedStreamInfo(SpdyStreamId stream_id, |
+ base::TimeTicks creation_time) |
+ : stream_id(stream_id), creation_time(creation_time) { |
+} |
-SpdySession::PushedStreamInfo::~PushedStreamInfo() {} |
+SpdySession::PushedStreamInfo::~PushedStreamInfo() { |
+} |
SpdySession::SpdySession( |
const SpdySessionKey& spdy_session_key, |
@@ -470,12 +473,12 @@ SpdySession::SpdySession( |
read_state_(READ_STATE_DO_READ), |
write_state_(WRITE_STATE_IDLE), |
error_on_close_(OK), |
- max_concurrent_streams_(initial_max_concurrent_streams == 0 ? |
- kInitialMaxConcurrentStreams : |
- initial_max_concurrent_streams), |
- max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 ? |
- kMaxConcurrentStreamLimit : |
- max_concurrent_streams_limit), |
+ max_concurrent_streams_(initial_max_concurrent_streams == 0 |
+ ? kInitialMaxConcurrentStreams |
+ : initial_max_concurrent_streams), |
+ max_concurrent_streams_limit_(max_concurrent_streams_limit == 0 |
+ ? kMaxConcurrentStreamLimit |
+ : max_concurrent_streams_limit), |
streams_initiated_count_(0), |
streams_pushed_count_(0), |
streams_pushed_and_claimed_count_(0), |
@@ -492,9 +495,9 @@ SpdySession::SpdySession( |
send_connection_header_prefix_(false), |
flow_control_state_(FLOW_CONTROL_NONE), |
stream_initial_send_window_size_(kSpdyStreamInitialWindowSize), |
- stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 ? |
- kDefaultInitialRecvWindowSize : |
- stream_initial_recv_window_size), |
+ stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 |
+ ? kDefaultInitialRecvWindowSize |
+ : stream_initial_recv_window_size), |
session_send_window_size_(0), |
session_recv_window_size_(0), |
session_unacked_recv_window_bytes_(0), |
@@ -507,8 +510,7 @@ SpdySession::SpdySession( |
protocol_(default_protocol), |
connection_at_risk_of_loss_time_( |
base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), |
- hung_interval_( |
- base::TimeDelta::FromSeconds(kHungIntervalSeconds)), |
+ hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), |
trusted_spdy_proxy_(trusted_spdy_proxy), |
time_func_(time_func) { |
DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); |
@@ -517,7 +519,8 @@ SpdySession::SpdySession( |
net_log_.BeginEvent( |
NetLog::TYPE_SPDY_SESSION, |
base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair())); |
- next_unclaimed_push_stream_sweep_time_ = time_func_() + |
+ next_unclaimed_push_stream_sweep_time_ = |
+ time_func_() + |
base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); |
// TODO(mbelshe): consider randomization of the stream_hi_water_mark. |
} |
@@ -583,9 +586,8 @@ void SpdySession::InitializeWithSocket( |
flow_control_state_ = FLOW_CONTROL_NONE; |
} |
- buffered_spdy_framer_.reset( |
- new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), |
- enable_compression_)); |
+ buffered_spdy_framer_.reset(new BufferedSpdyFramer( |
+ NextProtoToSpdyMajorVersion(protocol_), enable_compression_)); |
buffered_spdy_framer_->set_visitor(this); |
buffered_spdy_framer_->set_debug_visitor(this); |
UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol_, kProtoMaximumVersion); |
@@ -606,10 +608,11 @@ void SpdySession::InitializeWithSocket( |
pool_ = pool; |
// Bootstrap the read loop. |
- base::MessageLoop::current()->PostTask( |
- FROM_HERE, |
- base::Bind(&SpdySession::PumpReadLoop, |
- weak_factory_.GetWeakPtr(), READ_STATE_DO_READ, OK)); |
+ base::MessageLoop::current()->PostTask(FROM_HERE, |
+ base::Bind(&SpdySession::PumpReadLoop, |
+ weak_factory_.GetWeakPtr(), |
+ READ_STATE_DO_READ, |
+ OK)); |
} |
bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
@@ -623,21 +626,20 @@ bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
bool was_npn_negotiated; |
NextProto protocol_negotiated = kProtoUnknown; |
if (!GetSSLInfo(&ssl_info, &was_npn_negotiated, &protocol_negotiated)) |
- return true; // This is not a secure session, so all domains are okay. |
+ return true; // This is not a secure session, so all domains are okay. |
bool unused = false; |
- return |
- !ssl_info.client_cert_sent && |
- (!ssl_info.channel_id_sent || |
- (ServerBoundCertService::GetDomainForHost(domain) == |
- ServerBoundCertService::GetDomainForHost(host_port_pair().host()))) && |
- ssl_info.cert->VerifyNameMatch(domain, &unused); |
-} |
- |
-int SpdySession::GetPushStream( |
- const GURL& url, |
- base::WeakPtr<SpdyStream>* stream, |
- const BoundNetLog& stream_net_log) { |
+ return !ssl_info.client_cert_sent && |
+ (!ssl_info.channel_id_sent || |
+ (ServerBoundCertService::GetDomainForHost(domain) == |
+ ServerBoundCertService::GetDomainForHost( |
+ host_port_pair().host()))) && |
+ ssl_info.cert->VerifyNameMatch(domain, &unused); |
+} |
+ |
+int SpdySession::GetPushStream(const GURL& url, |
+ base::WeakPtr<SpdyStream>* stream, |
+ const BoundNetLog& stream_net_log) { |
CHECK(!in_io_loop_); |
stream->reset(); |
@@ -744,7 +746,9 @@ int SpdySession::CreateStream(const SpdyStreamRequest& request, |
} |
scoped_ptr<SpdyStream> new_stream( |
- new SpdyStream(request.type(), GetWeakPtr(), request.url(), |
+ new SpdyStream(request.type(), |
+ GetWeakPtr(), |
+ request.url(), |
request.priority(), |
stream_initial_send_window_size_, |
stream_initial_recv_window_size_, |
@@ -753,8 +757,7 @@ int SpdySession::CreateStream(const SpdyStreamRequest& request, |
InsertCreatedStream(new_stream.Pass()); |
UMA_HISTOGRAM_CUSTOM_COUNTS( |
- "Net.SpdyPriorityCount", |
- static_cast<int>(request.priority()), 0, 10, 11); |
+ "Net.SpdyPriorityCount", static_cast<int>(request.priority()), 0, 10, 11); |
return OK; |
} |
@@ -772,14 +775,12 @@ void SpdySession::CancelStreamRequest( |
if (priority == i) |
continue; |
PendingStreamRequestQueue* queue = &pending_create_stream_queues_[i]; |
- DCHECK(std::find_if(queue->begin(), |
- queue->end(), |
- RequestEquals(request)) == queue->end()); |
+ DCHECK(std::find_if(queue->begin(), queue->end(), RequestEquals(request)) == |
+ queue->end()); |
} |
#endif |
- PendingStreamRequestQueue* queue = |
- &pending_create_stream_queues_[priority]; |
+ PendingStreamRequestQueue* queue = &pending_create_stream_queues_[priority]; |
// Remove |request| from |queue| while preserving the order of the |
// other elements. |
PendingStreamRequestQueue::iterator it = |
@@ -819,7 +820,8 @@ void SpdySession::ProcessPendingStreamRequests() { |
(active_streams_.size() + created_streams_.size()); |
} |
for (size_t i = 0; |
- max_requests_to_process == 0 || i < max_requests_to_process; ++i) { |
+ max_requests_to_process == 0 || i < max_requests_to_process; |
+ ++i) { |
base::WeakPtr<SpdyStreamRequest> pending_request = |
GetNextPendingStreamRequest(); |
if (!pending_request) |
@@ -861,14 +863,11 @@ bool SpdySession::CloseOneIdleConnection() { |
return true; |
} |
-void SpdySession::EnqueueStreamWrite( |
- const base::WeakPtr<SpdyStream>& stream, |
- SpdyFrameType frame_type, |
- scoped_ptr<SpdyBufferProducer> producer) { |
- DCHECK(frame_type == HEADERS || |
- frame_type == DATA || |
- frame_type == CREDENTIAL || |
- frame_type == SYN_STREAM); |
+void SpdySession::EnqueueStreamWrite(const base::WeakPtr<SpdyStream>& stream, |
+ SpdyFrameType frame_type, |
+ scoped_ptr<SpdyBufferProducer> producer) { |
+ DCHECK(frame_type == HEADERS || frame_type == DATA || |
+ frame_type == CREDENTIAL || frame_type == SYN_STREAM); |
EnqueueWrite(stream->priority(), frame_type, producer.Pass(), stream); |
} |
@@ -886,22 +885,21 @@ scoped_ptr<SpdyFrame> SpdySession::CreateSynStream( |
DCHECK(buffered_spdy_framer_.get()); |
SpdyPriority spdy_priority = |
ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()); |
- scoped_ptr<SpdyFrame> syn_frame( |
- buffered_spdy_framer_->CreateSynStream(stream_id, 0, spdy_priority, flags, |
- &headers)); |
+ scoped_ptr<SpdyFrame> syn_frame(buffered_spdy_framer_->CreateSynStream( |
+ stream_id, 0, spdy_priority, flags, &headers)); |
base::StatsCounter spdy_requests("spdy.requests"); |
spdy_requests.Increment(); |
streams_initiated_count_++; |
if (net_log().IsLogging()) { |
- net_log().AddEvent( |
- NetLog::TYPE_SPDY_SESSION_SYN_STREAM, |
- base::Bind(&NetLogSpdySynStreamSentCallback, &headers, |
- (flags & CONTROL_FLAG_FIN) != 0, |
- (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, |
- spdy_priority, |
- stream_id)); |
+ net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_SYN_STREAM, |
+ base::Bind(&NetLogSpdySynStreamSentCallback, |
+ &headers, |
+ (flags & CONTROL_FLAG_FIN) != 0, |
+ (flags & CONTROL_FLAG_UNIDIRECTIONAL) != 0, |
+ spdy_priority, |
+ stream_id)); |
} |
return syn_frame.Pass(); |
@@ -928,9 +926,8 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, |
int effective_len = std::min(len, kMaxSpdyFrameChunkSize); |
- bool send_stalled_by_stream = |
- (flow_control_state_ >= FLOW_CONTROL_STREAM) && |
- (stream->send_window_size() <= 0); |
+ bool send_stalled_by_stream = (flow_control_state_ >= FLOW_CONTROL_STREAM) && |
+ (stream->send_window_size() <= 0); |
bool send_stalled_by_session = IsSendStalled(); |
// NOTE: There's an enum of the same name in histograms.xml. |
@@ -953,15 +950,13 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, |
} |
if (flow_control_state_ == FLOW_CONTROL_STREAM) { |
- UMA_HISTOGRAM_ENUMERATION( |
- "Net.SpdyFrameStreamFlowControlState", |
- frame_flow_control_state, |
- SEND_STALLED_BY_STREAM + 1); |
+ UMA_HISTOGRAM_ENUMERATION("Net.SpdyFrameStreamFlowControlState", |
+ frame_flow_control_state, |
+ SEND_STALLED_BY_STREAM + 1); |
} else if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
- UMA_HISTOGRAM_ENUMERATION( |
- "Net.SpdyFrameStreamAndSessionFlowControlState", |
- frame_flow_control_state, |
- SEND_STALLED_BY_STREAM_AND_SESSION + 1); |
+ UMA_HISTOGRAM_ENUMERATION("Net.SpdyFrameStreamAndSessionFlowControlState", |
+ frame_flow_control_state, |
+ SEND_STALLED_BY_STREAM_AND_SESSION + 1); |
} |
// Obey send window size of the stream if stream flow control is |
@@ -1004,10 +999,11 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, |
flags = static_cast<SpdyDataFlags>(flags & ~DATA_FLAG_FIN); |
if (net_log().IsLogging()) { |
- net_log().AddEvent( |
- NetLog::TYPE_SPDY_SESSION_SEND_DATA, |
- base::Bind(&NetLogSpdyDataCallback, stream_id, effective_len, |
- (flags & DATA_FLAG_FIN) != 0)); |
+ net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_SEND_DATA, |
+ base::Bind(&NetLogSpdyDataCallback, |
+ stream_id, |
+ effective_len, |
+ (flags & DATA_FLAG_FIN) != 0)); |
} |
// Send PrefacePing for DATA_FRAMEs with nonzero payload size. |
@@ -1016,10 +1012,8 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id, |
// TODO(mbelshe): reduce memory copies here. |
DCHECK(buffered_spdy_framer_.get()); |
- scoped_ptr<SpdyFrame> frame( |
- buffered_spdy_framer_->CreateDataFrame( |
- stream_id, data->data(), |
- static_cast<uint32>(effective_len), flags)); |
+ scoped_ptr<SpdyFrame> frame(buffered_spdy_framer_->CreateDataFrame( |
+ stream_id, data->data(), static_cast<uint32>(effective_len), flags)); |
scoped_ptr<SpdyBuffer> data_buffer(new SpdyBuffer(frame.Pass())); |
@@ -1046,8 +1040,8 @@ void SpdySession::CloseActiveStream(SpdyStreamId stream_id, int status) { |
CloseActiveStreamIterator(it, status); |
} |
-void SpdySession::CloseCreatedStream( |
- const base::WeakPtr<SpdyStream>& stream, int status) { |
+void SpdySession::CloseCreatedStream(const base::WeakPtr<SpdyStream>& stream, |
+ int status) { |
DCHECK_EQ(stream->stream_id(), 0u); |
CreatedStreamSet::iterator it = created_streams_.find(stream.get()); |
@@ -1217,7 +1211,9 @@ int SpdySession::DoReadLoop(ReadState expected_read_state, int result) { |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
base::Bind(&SpdySession::PumpReadLoop, |
- weak_factory_.GetWeakPtr(), READ_STATE_DO_READ, OK)); |
+ weak_factory_.GetWeakPtr(), |
+ READ_STATE_DO_READ, |
+ OK)); |
result = ERR_IO_PENDING; |
break; |
} |
@@ -1236,11 +1232,11 @@ int SpdySession::DoRead() { |
CHECK(connection_); |
CHECK(connection_->socket()); |
read_state_ = READ_STATE_DO_READ_COMPLETE; |
- return connection_->socket()->Read( |
- read_buffer_.get(), |
- kReadBufferSize, |
- base::Bind(&SpdySession::PumpReadLoop, |
- weak_factory_.GetWeakPtr(), READ_STATE_DO_READ_COMPLETE)); |
+ return connection_->socket()->Read(read_buffer_.get(), |
+ kReadBufferSize, |
+ base::Bind(&SpdySession::PumpReadLoop, |
+ weak_factory_.GetWeakPtr(), |
+ READ_STATE_DO_READ_COMPLETE)); |
} |
int SpdySession::DoReadComplete(int result) { |
@@ -1253,7 +1249,10 @@ int SpdySession::DoReadComplete(int result) { |
if (result == 0) { |
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySession.BytesRead.EOF", |
- total_bytes_received_, 1, 100000000, 50); |
+ total_bytes_received_, |
+ 1, |
+ 100000000, |
+ 50); |
CloseSessionResult close_session_result = |
DoCloseSession(ERR_CONNECTION_CLOSED, "Connection closed"); |
DCHECK_EQ(close_session_result, SESSION_CLOSED_BUT_NOT_REMOVED); |
@@ -1381,8 +1380,7 @@ int SpdySession::DoWrite() { |
if (frame_type == SYN_STREAM) { |
CHECK(stream.get()); |
CHECK_EQ(stream->stream_id(), 0u); |
- scoped_ptr<SpdyStream> owned_stream = |
- ActivateCreatedStream(stream.get()); |
+ scoped_ptr<SpdyStream> owned_stream = ActivateCreatedStream(stream.get()); |
InsertActivatedStream(owned_stream.Pass()); |
} |
@@ -1409,7 +1407,8 @@ int SpdySession::DoWrite() { |
write_io_buffer.get(), |
in_flight_write_->GetRemainingSize(), |
base::Bind(&SpdySession::PumpWriteLoop, |
- weak_factory_.GetWeakPtr(), WRITE_STATE_DO_WRITE_COMPLETE)); |
+ weak_factory_.GetWeakPtr(), |
+ WRITE_STATE_DO_WRITE_COMPLETE)); |
} |
int SpdySession::DoWriteComplete(int result) { |
@@ -1436,8 +1435,7 @@ int SpdySession::DoWriteComplete(int result) { |
// It should not be possible to have written more bytes than our |
// in_flight_write_. |
- DCHECK_LE(static_cast<size_t>(result), |
- in_flight_write_->GetRemainingSize()); |
+ DCHECK_LE(static_cast<size_t>(result), in_flight_write_->GetRemainingSize()); |
if (result > 0) { |
in_flight_write_->Consume(static_cast<size_t>(result)); |
@@ -1449,8 +1447,7 @@ int SpdySession::DoWriteComplete(int result) { |
if (in_flight_write_stream_.get()) { |
DCHECK_GT(in_flight_write_frame_size_, 0u); |
in_flight_write_stream_->OnFrameWriteComplete( |
- in_flight_write_frame_type_, |
- in_flight_write_frame_size_); |
+ in_flight_write_frame_type_, in_flight_write_frame_size_); |
} |
// Cleanup the write which just completed. |
@@ -1553,7 +1550,10 @@ SpdySession::CloseSessionResult SpdySession::DoCloseSession( |
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SpdySession.ClosedOnError", -err); |
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySession.BytesRead.OtherErrors", |
- total_bytes_received_, 1, 100000000, 50); |
+ total_bytes_received_, |
+ 1, |
+ 100000000, |
+ 50); |
CHECK(pool_); |
if (availability_state_ != STATE_GOING_AWAY) |
@@ -1585,8 +1585,8 @@ void SpdySession::RemoveFromPool() { |
void SpdySession::LogAbandonedStream(SpdyStream* stream, Error status) { |
DCHECK(stream); |
- std::string description = base::StringPrintf( |
- "ABANDONED (stream_id=%d): ", stream->stream_id()) + |
+ std::string description = |
+ base::StringPrintf("ABANDONED (stream_id=%d): ", stream->stream_id()) + |
stream->url().spec(); |
stream->LogStreamError(status, description); |
// We don't increment the streams abandoned counter here. If the |
@@ -1604,7 +1604,7 @@ void SpdySession::LogAbandonedActiveStream(ActiveStreamMap::const_iterator it, |
abandoned_streams.Increment(); |
if (it->second.stream->type() == SPDY_PUSH_STREAM && |
unclaimed_pushed_streams_.find(it->second.stream->url()) != |
- unclaimed_pushed_streams_.end()) { |
+ unclaimed_pushed_streams_.end()) { |
base::StatsCounter abandoned_push_streams("spdy.abandoned_push_streams"); |
abandoned_push_streams.Increment(); |
} |
@@ -1641,11 +1641,11 @@ base::Value* SpdySession::GetInfoAsValue() const { |
dict->SetString("host_port_pair", host_port_pair().ToString()); |
if (!pooled_aliases_.empty()) { |
base::ListValue* alias_list = new base::ListValue(); |
- for (std::set<SpdySessionKey>::const_iterator it = |
- pooled_aliases_.begin(); |
- it != pooled_aliases_.end(); it++) { |
- alias_list->Append(new base::StringValue( |
- it->host_port_pair().ToString())); |
+ for (std::set<SpdySessionKey>::const_iterator it = pooled_aliases_.begin(); |
+ it != pooled_aliases_.end(); |
+ it++) { |
+ alias_list->Append( |
+ new base::StringValue(it->host_port_pair().ToString())); |
} |
dict->Set("aliases", alias_list); |
} |
@@ -1668,7 +1668,7 @@ base::Value* SpdySession::GetInfoAsValue() const { |
dict->SetInteger("streams_initiated_count", streams_initiated_count_); |
dict->SetInteger("streams_pushed_count", streams_pushed_count_); |
dict->SetInteger("streams_pushed_and_claimed_count", |
- streams_pushed_and_claimed_count_); |
+ streams_pushed_and_claimed_count_); |
dict->SetInteger("streams_abandoned_count", streams_abandoned_count_); |
DCHECK(buffered_spdy_framer_.get()); |
dict->SetInteger("frames_received", buffered_spdy_framer_->frames_received()); |
@@ -1685,7 +1685,7 @@ base::Value* SpdySession::GetInfoAsValue() const { |
bool SpdySession::IsReused() const { |
return buffered_spdy_framer_->frames_received() > 0 || |
- connection_->reuse_type() == ClientSocketHandle::UNUSED_IDLE; |
+ connection_->reuse_type() == ClientSocketHandle::UNUSED_IDLE; |
} |
bool SpdySession::GetLoadTimingInfo(SpdyStreamId stream_id, |
@@ -1721,16 +1721,13 @@ int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
void SpdySession::EnqueueSessionWrite(RequestPriority priority, |
SpdyFrameType frame_type, |
scoped_ptr<SpdyFrame> frame) { |
- DCHECK(frame_type == RST_STREAM || |
- frame_type == SETTINGS || |
- frame_type == WINDOW_UPDATE || |
- frame_type == PING); |
- EnqueueWrite( |
- priority, frame_type, |
- scoped_ptr<SpdyBufferProducer>( |
- new SimpleBufferProducer( |
- scoped_ptr<SpdyBuffer>(new SpdyBuffer(frame.Pass())))), |
- base::WeakPtr<SpdyStream>()); |
+ DCHECK(frame_type == RST_STREAM || frame_type == SETTINGS || |
+ frame_type == WINDOW_UPDATE || frame_type == PING); |
+ EnqueueWrite(priority, |
+ frame_type, |
+ scoped_ptr<SpdyBufferProducer>(new SimpleBufferProducer( |
+ scoped_ptr<SpdyBuffer>(new SpdyBuffer(frame.Pass())))), |
+ base::WeakPtr<SpdyStream>()); |
} |
void SpdySession::EnqueueWrite(RequestPriority priority, |
@@ -1749,7 +1746,9 @@ void SpdySession::EnqueueWrite(RequestPriority priority, |
base::MessageLoop::current()->PostTask( |
FROM_HERE, |
base::Bind(&SpdySession::PumpWriteLoop, |
- weak_factory_.GetWeakPtr(), WRITE_STATE_DO_WRITE, OK)); |
+ weak_factory_.GetWeakPtr(), |
+ WRITE_STATE_DO_WRITE, |
+ OK)); |
} |
} |
@@ -1771,9 +1770,8 @@ scoped_ptr<SpdyStream> SpdySession::ActivateCreatedStream(SpdyStream* stream) { |
void SpdySession::InsertActivatedStream(scoped_ptr<SpdyStream> stream) { |
SpdyStreamId stream_id = stream->stream_id(); |
CHECK_NE(stream_id, 0u); |
- std::pair<ActiveStreamMap::iterator, bool> result = |
- active_streams_.insert( |
- std::make_pair(stream_id, ActiveStreamInfo(stream.get()))); |
+ std::pair<ActiveStreamMap::iterator, bool> result = active_streams_.insert( |
+ std::make_pair(stream_id, ActiveStreamInfo(stream.get()))); |
CHECK(result.second); |
ignore_result(stream.release()); |
} |
@@ -1840,8 +1838,7 @@ bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, |
return connection_->socket()->GetSSLInfo(ssl_info); |
} |
-bool SpdySession::GetSSLCertRequestInfo( |
- SSLCertRequestInfo* cert_request_info) { |
+bool SpdySession::GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) { |
if (!is_secure_) |
return false; |
GetSSLClientSocket()->GetSSLCertRequestInfo(cert_request_info); |
@@ -1855,8 +1852,8 @@ void SpdySession::OnError(SpdyFramer::SpdyError error_code) { |
return; |
RecordProtocolErrorHistogram(MapFramerErrorToProtocolError(error_code)); |
- std::string description = base::StringPrintf( |
- "SPDY_ERROR error_code: %d.", error_code); |
+ std::string description = |
+ base::StringPrintf("SPDY_ERROR error_code: %d.", error_code); |
CloseSessionResult result = |
DoCloseSession(ERR_SPDY_PROTOCOL_ERROR, description); |
DCHECK_EQ(result, SESSION_CLOSED_BUT_NOT_REMOVED); |
@@ -1939,9 +1936,8 @@ void SpdySession::OnStreamFrameData(SpdyStreamId stream_id, |
if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
DecreaseRecvWindowSize(static_cast<int32>(len)); |
- buffer->AddConsumeCallback( |
- base::Bind(&SpdySession::OnReadBufferConsumed, |
- weak_factory_.GetWeakPtr())); |
+ buffer->AddConsumeCallback(base::Bind(&SpdySession::OnReadBufferConsumed, |
+ weak_factory_.GetWeakPtr())); |
} |
} else { |
DCHECK_EQ(len, 0u); |
@@ -1980,14 +1976,12 @@ void SpdySession::OnSettings(bool clear_persisted) { |
if (net_log_.IsLogging()) { |
net_log_.AddEvent( |
NetLog::TYPE_SPDY_SESSION_RECV_SETTINGS, |
- base::Bind(&NetLogSpdySettingsCallback, host_port_pair(), |
- clear_persisted)); |
+ base::Bind( |
+ &NetLogSpdySettingsCallback, host_port_pair(), clear_persisted)); |
} |
} |
-void SpdySession::OnSetting(SpdySettingsIds id, |
- uint8 flags, |
- uint32 value) { |
+void SpdySession::OnSetting(SpdySettingsIds id, uint8 flags, uint32 value) { |
CHECK(in_io_loop_); |
if (availability_state_ == STATE_CLOSED) |
@@ -1995,24 +1989,21 @@ void SpdySession::OnSetting(SpdySettingsIds id, |
HandleSetting(id, value); |
http_server_properties_->SetSpdySetting( |
- host_port_pair(), |
- id, |
- static_cast<SpdySettingsFlags>(flags), |
- value); |
+ host_port_pair(), id, static_cast<SpdySettingsFlags>(flags), value); |
received_settings_ = true; |
// Log the setting. |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_RECV_SETTING, |
- base::Bind(&NetLogSpdySettingCallback, |
- id, static_cast<SpdySettingsFlags>(flags), value)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_RECV_SETTING, |
+ base::Bind(&NetLogSpdySettingCallback, |
+ id, |
+ static_cast<SpdySettingsFlags>(flags), |
+ value)); |
} |
-void SpdySession::OnSendCompressedFrame( |
- SpdyStreamId stream_id, |
- SpdyFrameType type, |
- size_t payload_len, |
- size_t frame_len) { |
+void SpdySession::OnSendCompressedFrame(SpdyStreamId stream_id, |
+ SpdyFrameType type, |
+ size_t payload_len, |
+ size_t frame_len) { |
if (type != SYN_STREAM) |
return; |
@@ -2028,10 +2019,9 @@ void SpdySession::OnSendCompressedFrame( |
} |
} |
-void SpdySession::OnReceiveCompressedFrame( |
- SpdyStreamId stream_id, |
- SpdyFrameType type, |
- size_t frame_len) { |
+void SpdySession::OnReceiveCompressedFrame(SpdyStreamId stream_id, |
+ SpdyFrameType type, |
+ size_t frame_len) { |
last_compressed_frame_len_ = frame_len; |
} |
@@ -2067,11 +2057,14 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
base::TimeTicks recv_first_byte_time = time_func_(); |
if (net_log_.IsLogging()) { |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM, |
- base::Bind(&NetLogSpdySynStreamReceivedCallback, |
- &headers, fin, unidirectional, priority, |
- stream_id, associated_stream_id)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM, |
+ base::Bind(&NetLogSpdySynStreamReceivedCallback, |
+ &headers, |
+ fin, |
+ unidirectional, |
+ priority, |
+ stream_id, |
+ associated_stream_id)); |
} |
// Server-initiated streams should have even sequence numbers. |
@@ -2091,7 +2084,8 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
if (availability_state_ == STATE_GOING_AWAY) { |
// TODO(akalin): This behavior isn't in the SPDY spec, although it |
// probably should be. |
- EnqueueResetStreamFrame(stream_id, request_priority, |
+ EnqueueResetStreamFrame(stream_id, |
+ request_priority, |
RST_STREAM_REFUSED_STREAM, |
"OnSyn received when going away"); |
return; |
@@ -2103,9 +2097,10 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
if (associated_stream_id == 0 && GetProtocolVersion() < SPDY4) { |
std::string description = base::StringPrintf( |
"Received invalid OnSyn associated stream id %d for stream %d", |
- associated_stream_id, stream_id); |
- EnqueueResetStreamFrame(stream_id, request_priority, |
- RST_STREAM_REFUSED_STREAM, description); |
+ associated_stream_id, |
+ stream_id); |
+ EnqueueResetStreamFrame( |
+ stream_id, request_priority, RST_STREAM_REFUSED_STREAM, description); |
return; |
} |
@@ -2116,9 +2111,10 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
// Verify that the response had a URL for us. |
GURL gurl = GetUrlFromHeaderBlock(headers, GetProtocolVersion(), true); |
if (!gurl.is_valid()) { |
- EnqueueResetStreamFrame( |
- stream_id, request_priority, RST_STREAM_PROTOCOL_ERROR, |
- "Pushed stream url was invalid: " + gurl.spec()); |
+ EnqueueResetStreamFrame(stream_id, |
+ request_priority, |
+ RST_STREAM_PROTOCOL_ERROR, |
+ "Pushed stream url was invalid: " + gurl.spec()); |
return; |
} |
@@ -2128,10 +2124,11 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
// TODO(jgraettinger): (See PUSH_PROMISE comment above). |
if (GetProtocolVersion() < SPDY4 && associated_it == active_streams_.end()) { |
EnqueueResetStreamFrame( |
- stream_id, request_priority, RST_STREAM_INVALID_STREAM, |
- base::StringPrintf( |
- "Received OnSyn with inactive associated stream %d", |
- associated_stream_id)); |
+ stream_id, |
+ request_priority, |
+ RST_STREAM_INVALID_STREAM, |
+ base::StringPrintf("Received OnSyn with inactive associated stream %d", |
+ associated_stream_id)); |
return; |
} |
@@ -2142,20 +2139,22 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
// Disallow pushing of HTTPS content. |
if (gurl.SchemeIs("https")) { |
EnqueueResetStreamFrame( |
- stream_id, request_priority, RST_STREAM_REFUSED_STREAM, |
- base::StringPrintf( |
- "Rejected push of Cross Origin HTTPS content %d", |
- associated_stream_id)); |
+ stream_id, |
+ request_priority, |
+ RST_STREAM_REFUSED_STREAM, |
+ base::StringPrintf("Rejected push of Cross Origin HTTPS content %d", |
+ associated_stream_id)); |
} |
} else if (GetProtocolVersion() < SPDY4) { |
// TODO(jgraettinger): (See PUSH_PROMISE comment above). |
GURL associated_url(associated_it->second.stream->GetUrlFromHeaders()); |
if (associated_url.GetOrigin() != gurl.GetOrigin()) { |
EnqueueResetStreamFrame( |
- stream_id, request_priority, RST_STREAM_REFUSED_STREAM, |
- base::StringPrintf( |
- "Rejected Cross Origin Push Stream %d", |
- associated_stream_id)); |
+ stream_id, |
+ request_priority, |
+ RST_STREAM_REFUSED_STREAM, |
+ base::StringPrintf("Rejected Cross Origin Push Stream %d", |
+ associated_stream_id)); |
return; |
} |
} |
@@ -2166,18 +2165,20 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
if (pushed_it != unclaimed_pushed_streams_.end() && |
pushed_it->first == gurl) { |
EnqueueResetStreamFrame( |
- stream_id, request_priority, RST_STREAM_PROTOCOL_ERROR, |
- "Received duplicate pushed stream with url: " + |
- gurl.spec()); |
+ stream_id, |
+ request_priority, |
+ RST_STREAM_PROTOCOL_ERROR, |
+ "Received duplicate pushed stream with url: " + gurl.spec()); |
return; |
} |
- scoped_ptr<SpdyStream> stream( |
- new SpdyStream(SPDY_PUSH_STREAM, GetWeakPtr(), gurl, |
- request_priority, |
- stream_initial_send_window_size_, |
- stream_initial_recv_window_size_, |
- net_log_)); |
+ scoped_ptr<SpdyStream> stream(new SpdyStream(SPDY_PUSH_STREAM, |
+ GetWeakPtr(), |
+ gurl, |
+ request_priority, |
+ stream_initial_send_window_size_, |
+ stream_initial_recv_window_size_, |
+ net_log_)); |
stream->set_stream_id(stream_id); |
stream->IncrementRawReceivedBytes(last_compressed_frame_len_); |
last_compressed_frame_len_ = 0; |
@@ -2198,9 +2199,10 @@ void SpdySession::OnSynStream(SpdyStreamId stream_id, |
} |
// Parse the headers. |
- if (OnInitialResponseHeadersReceived( |
- headers, response_time, |
- recv_first_byte_time, active_it->second.stream) != OK) |
+ if (OnInitialResponseHeadersReceived(headers, |
+ response_time, |
+ recv_first_byte_time, |
+ active_it->second.stream) != OK) |
return; |
base::StatsCounter push_requests("spdy.pushed_streams"); |
@@ -2216,18 +2218,21 @@ void SpdySession::DeleteExpiredPushedStreams() { |
return; |
// Gather old streams to delete. |
- base::TimeTicks minimum_freshness = time_func_() - |
+ base::TimeTicks minimum_freshness = |
+ time_func_() - |
base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); |
std::vector<SpdyStreamId> streams_to_close; |
for (PushedStreamMap::iterator it = unclaimed_pushed_streams_.begin(); |
- it != unclaimed_pushed_streams_.end(); ++it) { |
+ it != unclaimed_pushed_streams_.end(); |
+ ++it) { |
if (minimum_freshness > it->second.creation_time) |
streams_to_close.push_back(it->second.stream_id); |
} |
for (std::vector<SpdyStreamId>::const_iterator to_close_it = |
streams_to_close.begin(); |
- to_close_it != streams_to_close.end(); ++to_close_it) { |
+ to_close_it != streams_to_close.end(); |
+ ++to_close_it) { |
ActiveStreamMap::iterator active_it = active_streams_.find(*to_close_it); |
if (active_it == active_streams_.end()) |
continue; |
@@ -2239,7 +2244,8 @@ void SpdySession::DeleteExpiredPushedStreams() { |
active_it, RST_STREAM_REFUSED_STREAM, "Stream not claimed."); |
} |
- next_unclaimed_push_stream_sweep_time_ = time_func_() + |
+ next_unclaimed_push_stream_sweep_time_ = |
+ time_func_() + |
base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); |
} |
@@ -2255,10 +2261,11 @@ void SpdySession::OnSynReply(SpdyStreamId stream_id, |
base::TimeTicks recv_first_byte_time = time_func_(); |
if (net_log().IsLogging()) { |
- net_log().AddEvent( |
- NetLog::TYPE_SPDY_SESSION_SYN_REPLY, |
- base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, |
- &headers, fin, stream_id)); |
+ net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_SYN_REPLY, |
+ base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, |
+ &headers, |
+ fin, |
+ stream_id)); |
} |
ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
@@ -2274,15 +2281,13 @@ void SpdySession::OnSynReply(SpdyStreamId stream_id, |
last_compressed_frame_len_ = 0; |
if (GetProtocolVersion() >= SPDY4) { |
- const std::string& error = |
- "SPDY4 wasn't expecting SYN_REPLY."; |
+ const std::string& error = "SPDY4 wasn't expecting SYN_REPLY."; |
stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); |
ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); |
return; |
} |
if (!it->second.waiting_for_syn_reply) { |
- const std::string& error = |
- "Received duplicate SYN_REPLY for stream."; |
+ const std::string& error = "Received duplicate SYN_REPLY for stream."; |
stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); |
ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); |
return; |
@@ -2302,10 +2307,11 @@ void SpdySession::OnHeaders(SpdyStreamId stream_id, |
return; |
if (net_log().IsLogging()) { |
- net_log().AddEvent( |
- NetLog::TYPE_SPDY_SESSION_RECV_HEADERS, |
- base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, |
- &headers, fin, stream_id)); |
+ net_log().AddEvent(NetLog::TYPE_SPDY_SESSION_RECV_HEADERS, |
+ base::Bind(&NetLogSpdySynReplyOrHeadersReceivedCallback, |
+ &headers, |
+ fin, |
+ stream_id)); |
} |
ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
@@ -2323,8 +2329,7 @@ void SpdySession::OnHeaders(SpdyStreamId stream_id, |
if (it->second.waiting_for_syn_reply) { |
if (GetProtocolVersion() < SPDY4) { |
- const std::string& error = |
- "Was expecting SYN_REPLY, not HEADERS."; |
+ const std::string& error = "Was expecting SYN_REPLY, not HEADERS."; |
stream->LogStreamError(ERR_SPDY_PROTOCOL_ERROR, error); |
ResetStreamIterator(it, RST_STREAM_PROTOCOL_ERROR, error); |
return; |
@@ -2354,8 +2359,7 @@ void SpdySession::OnRstStream(SpdyStreamId stream_id, |
std::string description; |
net_log().AddEvent( |
NetLog::TYPE_SPDY_SESSION_RST_STREAM, |
- base::Bind(&NetLogSpdyRstCallback, |
- stream_id, status, &description)); |
+ base::Bind(&NetLogSpdyRstCallback, stream_id, status, &description)); |
ActiveStreamMap::iterator it = active_streams_.find(stream_id); |
if (it == active_streams_.end()) { |
@@ -2390,11 +2394,11 @@ void SpdySession::OnGoAway(SpdyStreamId last_accepted_stream_id, |
return; |
net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_GOAWAY, |
- base::Bind(&NetLogSpdyGoAwayCallback, |
- last_accepted_stream_id, |
- active_streams_.size(), |
- unclaimed_pushed_streams_.size(), |
- status)); |
+ base::Bind(&NetLogSpdyGoAwayCallback, |
+ last_accepted_stream_id, |
+ active_streams_.size(), |
+ unclaimed_pushed_streams_.size(), |
+ status)); |
MakeUnavailable(); |
StartGoingAway(last_accepted_stream_id, ERR_ABORTED); |
// This is to handle the case when we already don't have any active |
@@ -2449,8 +2453,8 @@ void SpdySession::OnWindowUpdate(SpdyStreamId stream_id, |
DCHECK_LE(delta_window_size, static_cast<uint32>(kint32max)); |
net_log_.AddEvent( |
NetLog::TYPE_SPDY_SESSION_RECEIVED_WINDOW_UPDATE_FRAME, |
- base::Bind(&NetLogSpdyWindowUpdateFrameCallback, |
- stream_id, delta_window_size)); |
+ base::Bind( |
+ &NetLogSpdyWindowUpdateFrameCallback, stream_id, delta_window_size)); |
if (stream_id == kSessionFlowControlStreamId) { |
// WINDOW_UPDATE for the session. |
@@ -2466,7 +2470,7 @@ void SpdySession::OnWindowUpdate(SpdyStreamId stream_id, |
CloseSessionResult result = DoCloseSession( |
ERR_SPDY_PROTOCOL_ERROR, |
"Received WINDOW_UPDATE with an invalid delta_window_size " + |
- base::UintToString(delta_window_size)); |
+ base::UintToString(delta_window_size)); |
DCHECK_EQ(result, SESSION_CLOSED_BUT_NOT_REMOVED); |
return; |
} |
@@ -2497,7 +2501,8 @@ void SpdySession::OnWindowUpdate(SpdyStreamId stream_id, |
RST_STREAM_FLOW_CONTROL_ERROR, |
base::StringPrintf( |
"Received WINDOW_UPDATE with an invalid " |
- "delta_window_size %ud", delta_window_size)); |
+ "delta_window_size %ud", |
+ delta_window_size)); |
return; |
} |
@@ -2533,8 +2538,8 @@ void SpdySession::SendInitialData() { |
kHttp2ConnectionHeaderPrefixSize, |
false /* take_ownership */)); |
// Count the prefix as part of the subsequent SETTINGS frame. |
- EnqueueSessionWrite(HIGHEST, SETTINGS, |
- connection_header_prefix_frame.Pass()); |
+ EnqueueSessionWrite( |
+ HIGHEST, SETTINGS, connection_header_prefix_frame.Pass()); |
} |
// First, notify the server about the settings they should use when |
@@ -2546,9 +2551,8 @@ void SpdySession::SendInitialData() { |
SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); |
if (flow_control_state_ >= FLOW_CONTROL_STREAM && |
stream_initial_recv_window_size_ != kSpdyStreamInitialWindowSize) { |
- settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = |
- SettingsFlagsAndValue(SETTINGS_FLAG_NONE, |
- stream_initial_recv_window_size_); |
+ settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = SettingsFlagsAndValue( |
+ SETTINGS_FLAG_NONE, stream_initial_recv_window_size_); |
} |
SendSettings(settings_map); |
@@ -2561,8 +2565,8 @@ void SpdySession::SendInitialData() { |
// This condition implies that |kDefaultInitialRecvWindowSize| - |
// |session_recv_window_size_| doesn't overflow. |
DCHECK_GT(session_recv_window_size_, 0); |
- IncreaseRecvWindowSize( |
- kDefaultInitialRecvWindowSize - session_recv_window_size_); |
+ IncreaseRecvWindowSize(kDefaultInitialRecvWindowSize - |
+ session_recv_window_size_); |
} |
// Finally, notify the server about the settings they have |
@@ -2579,7 +2583,8 @@ void SpdySession::SendInitialData() { |
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100); |
for (SettingsMap::const_iterator it = server_settings_map.begin(); |
- it != server_settings_map.end(); ++it) { |
+ it != server_settings_map.end(); |
+ ++it) { |
const SpdySettingsIds new_id = it->first; |
const uint32 new_val = it->second.second; |
HandleSetting(new_id, new_val); |
@@ -2588,13 +2593,11 @@ void SpdySession::SendInitialData() { |
SendSettings(server_settings_map); |
} |
- |
void SpdySession::SendSettings(const SettingsMap& settings) { |
DCHECK_NE(availability_state_, STATE_CLOSED); |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, |
- base::Bind(&NetLogSpdySendSettingsCallback, &settings)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, |
+ base::Bind(&NetLogSpdySendSettingsCallback, &settings)); |
// Create the SETTINGS frame and send it. |
DCHECK(buffered_spdy_framer_.get()); |
@@ -2607,8 +2610,8 @@ void SpdySession::SendSettings(const SettingsMap& settings) { |
void SpdySession::HandleSetting(uint32 id, uint32 value) { |
switch (id) { |
case SETTINGS_MAX_CONCURRENT_STREAMS: |
- max_concurrent_streams_ = std::min(static_cast<size_t>(value), |
- kMaxConcurrentStreamLimit); |
+ max_concurrent_streams_ = |
+ std::min(static_cast<size_t>(value), kMaxConcurrentStreamLimit); |
ProcessPendingStreamRequests(); |
break; |
case SETTINGS_INITIAL_WINDOW_SIZE: { |
@@ -2641,12 +2644,14 @@ void SpdySession::HandleSetting(uint32 id, uint32 value) { |
void SpdySession::UpdateStreamsSendWindowSize(int32 delta_window_size) { |
DCHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM); |
for (ActiveStreamMap::iterator it = active_streams_.begin(); |
- it != active_streams_.end(); ++it) { |
+ it != active_streams_.end(); |
+ ++it) { |
it->second.stream->AdjustSendWindowSize(delta_window_size); |
} |
for (CreatedStreamSet::const_iterator it = created_streams_.begin(); |
- it != created_streams_.end(); it++) { |
+ it != created_streams_.end(); |
+ it++) { |
(*it)->AdjustSendWindowSize(delta_window_size); |
} |
} |
@@ -2679,8 +2684,8 @@ void SpdySession::SendWindowUpdateFrame(SpdyStreamId stream_id, |
net_log_.AddEvent( |
NetLog::TYPE_SPDY_SESSION_SENT_WINDOW_UPDATE_FRAME, |
- base::Bind(&NetLogSpdyWindowUpdateFrameCallback, |
- stream_id, delta_window_size)); |
+ base::Bind( |
+ &NetLogSpdyWindowUpdateFrameCallback, stream_id, delta_window_size)); |
DCHECK(buffered_spdy_framer_.get()); |
scoped_ptr<SpdyFrame> window_update_frame( |
@@ -2714,8 +2719,10 @@ void SpdySession::PlanToCheckPingStatus() { |
check_ping_status_pending_ = true; |
base::MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |
- base::Bind(&SpdySession::CheckPingStatus, weak_factory_.GetWeakPtr(), |
- time_func_()), hung_interval_); |
+ base::Bind(&SpdySession::CheckPingStatus, |
+ weak_factory_.GetWeakPtr(), |
+ time_func_()), |
+ hung_interval_); |
} |
void SpdySession::CheckPingStatus(base::TimeTicks last_check_time) { |
@@ -2745,8 +2752,8 @@ void SpdySession::CheckPingStatus(base::TimeTicks last_check_time) { |
// Check the status of connection after a delay. |
base::MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |
- base::Bind(&SpdySession::CheckPingStatus, weak_factory_.GetWeakPtr(), |
- now), |
+ base::Bind( |
+ &SpdySession::CheckPingStatus, weak_factory_.GetWeakPtr(), now), |
delay); |
} |
@@ -2756,36 +2763,37 @@ void SpdySession::RecordPingRTTHistogram(base::TimeDelta duration) { |
void SpdySession::RecordProtocolErrorHistogram( |
SpdyProtocolErrorDetails details) { |
- UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionErrorDetails2", details, |
- NUM_SPDY_PROTOCOL_ERROR_DETAILS); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.SpdySessionErrorDetails2", details, NUM_SPDY_PROTOCOL_ERROR_DETAILS); |
if (EndsWith(host_port_pair().host(), "google.com", false)) { |
- UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionErrorDetails_Google2", details, |
+ UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionErrorDetails_Google2", |
+ details, |
NUM_SPDY_PROTOCOL_ERROR_DETAILS); |
} |
} |
void SpdySession::RecordHistograms() { |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsPerSession", |
- streams_initiated_count_, |
- 0, 300, 50); |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsPushedPerSession", |
- streams_pushed_count_, |
- 0, 300, 50); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdyStreamsPerSession", streams_initiated_count_, 0, 300, 50); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdyStreamsPushedPerSession", streams_pushed_count_, 0, 300, 50); |
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsPushedAndClaimedPerSession", |
streams_pushed_and_claimed_count_, |
- 0, 300, 50); |
+ 0, |
+ 300, |
+ 50); |
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsAbandonedPerSession", |
streams_abandoned_count_, |
- 0, 300, 50); |
- UMA_HISTOGRAM_ENUMERATION("Net.SpdySettingsSent", |
- sent_settings_ ? 1 : 0, 2); |
- UMA_HISTOGRAM_ENUMERATION("Net.SpdySettingsReceived", |
- received_settings_ ? 1 : 0, 2); |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamStallsPerSession", |
- stalled_streams_, |
- 0, 300, 50); |
- UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionsWithStalls", |
- stalled_streams_ > 0 ? 1 : 0, 2); |
+ 0, |
+ 300, |
+ 50); |
+ UMA_HISTOGRAM_ENUMERATION("Net.SpdySettingsSent", sent_settings_ ? 1 : 0, 2); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.SpdySettingsReceived", received_settings_ ? 1 : 0, 2); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdyStreamStallsPerSession", stalled_streams_, 0, 300, 50); |
+ UMA_HISTOGRAM_ENUMERATION( |
+ "Net.SpdySessionsWithStalls", stalled_streams_ > 0 ? 1 : 0, 2); |
if (received_settings_) { |
// Enumerate the saved settings, and set histograms for it. |
@@ -2800,32 +2808,30 @@ void SpdySession::RecordHistograms() { |
case SETTINGS_CURRENT_CWND: |
// Record several different histograms to see if cwnd converges |
// for larger volumes of data being sent. |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", |
- val, 1, 200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd", val, 1, 200, 100); |
if (total_bytes_received_ > 10 * 1024) { |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd10K", |
- val, 1, 200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdySettingsCwnd10K", val, 1, 200, 100); |
if (total_bytes_received_ > 25 * 1024) { |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd25K", |
- val, 1, 200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdySettingsCwnd25K", val, 1, 200, 100); |
if (total_bytes_received_ > 50 * 1024) { |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd50K", |
- val, 1, 200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdySettingsCwnd50K", val, 1, 200, 100); |
if (total_bytes_received_ > 100 * 1024) { |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwnd100K", |
- val, 1, 200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdySettingsCwnd100K", val, 1, 200, 100); |
} |
} |
} |
} |
break; |
case SETTINGS_ROUND_TRIP_TIME: |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT", |
- val, 1, 1200, 100); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRTT", val, 1, 1200, 100); |
break; |
case SETTINGS_DOWNLOAD_RETRANS_RATE: |
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsRetransRate", |
- val, 1, 100, 50); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS( |
+ "Net.SpdySettingsRetransRate", val, 1, 100, 50); |
break; |
default: |
break; |
@@ -2901,19 +2907,19 @@ void SpdySession::IncreaseSendWindowSize(int32 delta_window_size) { |
CloseSessionResult result = DoCloseSession( |
ERR_SPDY_PROTOCOL_ERROR, |
"Received WINDOW_UPDATE [delta: " + |
- base::IntToString(delta_window_size) + |
- "] for session overflows session_send_window_size_ [current: " + |
- base::IntToString(session_send_window_size_) + "]"); |
+ base::IntToString(delta_window_size) + |
+ "] for session overflows session_send_window_size_ [current: " + |
+ base::IntToString(session_send_window_size_) + "]"); |
DCHECK_NE(result, SESSION_ALREADY_CLOSED); |
return; |
} |
session_send_window_size_ += delta_window_size; |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
- base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
- delta_window_size, session_send_window_size_)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
+ base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
+ delta_window_size, |
+ session_send_window_size_)); |
DCHECK(!IsSendStalled()); |
ResumeSendStalledStreams(); |
@@ -2934,10 +2940,10 @@ void SpdySession::DecreaseSendWindowSize(int32 delta_window_size) { |
session_send_window_size_ -= delta_window_size; |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
- base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
- -delta_window_size, session_send_window_size_)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_UPDATE_SEND_WINDOW, |
+ base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
+ -delta_window_size, |
+ session_send_window_size_)); |
} |
void SpdySession::OnReadBufferConsumed( |
@@ -2966,10 +2972,10 @@ void SpdySession::IncreaseRecvWindowSize(int32 delta_window_size) { |
DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); |
session_recv_window_size_ += delta_window_size; |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, |
- base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
- delta_window_size, session_recv_window_size_)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, |
+ base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
+ delta_window_size, |
+ session_recv_window_size_)); |
session_unacked_recv_window_bytes_ += delta_window_size; |
if (session_unacked_recv_window_bytes_ > kSpdySessionInitialWindowSize / 2) { |
@@ -3000,10 +3006,10 @@ void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { |
} |
session_recv_window_size_ -= delta_window_size; |
- net_log_.AddEvent( |
- NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, |
- base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
- -delta_window_size, session_recv_window_size_)); |
+ net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, |
+ base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
+ -delta_window_size, |
+ session_recv_window_size_)); |
} |
void SpdySession::QueueSendStalledStream(const SpdyStream& stream) { |