Chromium Code Reviews| 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/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
| 19 #include "base/profiler/scoped_tracker.h" | 19 #include "base/profiler/scoped_tracker.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "base/trace_event/memory_usage_estimator.h" | |
| 28 #include "base/trace_event/trace_event.h" | 29 #include "base/trace_event/trace_event.h" |
| 29 #include "base/values.h" | 30 #include "base/values.h" |
| 30 #include "crypto/ec_private_key.h" | 31 #include "crypto/ec_private_key.h" |
| 31 #include "crypto/ec_signature_creator.h" | 32 #include "crypto/ec_signature_creator.h" |
| 32 #include "net/base/proxy_delegate.h" | 33 #include "net/base/proxy_delegate.h" |
| 33 #include "net/cert/asn1_util.h" | 34 #include "net/cert/asn1_util.h" |
| 34 #include "net/cert/cert_verify_result.h" | 35 #include "net/cert/cert_verify_result.h" |
| 35 #include "net/cert/ct_policy_status.h" | 36 #include "net/cert/ct_policy_status.h" |
| 36 #include "net/http/http_log_util.h" | 37 #include "net/http/http_log_util.h" |
| 37 #include "net/http/http_network_session.h" | 38 #include "net/http/http_network_session.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 } | 553 } |
| 553 | 554 |
| 554 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() { | 555 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() { |
| 555 DCHECK(!session_); | 556 DCHECK(!session_); |
| 556 base::WeakPtr<SpdyStream> stream = stream_; | 557 base::WeakPtr<SpdyStream> stream = stream_; |
| 557 DCHECK(stream); | 558 DCHECK(stream); |
| 558 Reset(); | 559 Reset(); |
| 559 return stream; | 560 return stream; |
| 560 } | 561 } |
| 561 | 562 |
| 563 size_t SpdyStreamRequest::EstimateMemoryUsage() const { | |
| 564 return base::trace_event::EstimateItemMemoryUsage(url_); | |
| 565 } | |
| 566 | |
| 562 void SpdyStreamRequest::OnRequestCompleteSuccess( | 567 void SpdyStreamRequest::OnRequestCompleteSuccess( |
| 563 const base::WeakPtr<SpdyStream>& stream) { | 568 const base::WeakPtr<SpdyStream>& stream) { |
| 564 DCHECK(session_); | 569 DCHECK(session_); |
| 565 DCHECK(!stream_); | 570 DCHECK(!stream_); |
| 566 DCHECK(!callback_.is_null()); | 571 DCHECK(!callback_.is_null()); |
| 567 CompletionCallback callback = callback_; | 572 CompletionCallback callback = callback_; |
| 568 Reset(); | 573 Reset(); |
| 569 DCHECK(stream); | 574 DCHECK(stream); |
| 570 stream_ = stream; | 575 stream_ = stream; |
| 571 callback.Run(OK); | 576 callback.Run(OK); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 bool SpdySession::CloseOneIdleConnection() { | 1057 bool SpdySession::CloseOneIdleConnection() { |
| 1053 CHECK(!in_io_loop_); | 1058 CHECK(!in_io_loop_); |
| 1054 DCHECK(pool_); | 1059 DCHECK(pool_); |
| 1055 if (active_streams_.empty()) { | 1060 if (active_streams_.empty()) { |
| 1056 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); | 1061 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); |
| 1057 } | 1062 } |
| 1058 // Return false as the socket wasn't immediately closed. | 1063 // Return false as the socket wasn't immediately closed. |
| 1059 return false; | 1064 return false; |
| 1060 } | 1065 } |
| 1061 | 1066 |
| 1062 void SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats, | 1067 size_t SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats, |
| 1063 bool* is_session_active) const { | 1068 bool* is_session_active) const { |
| 1064 *is_session_active = is_active(); | 1069 *is_session_active = is_active(); |
| 1065 connection_->DumpMemoryStats(stats); | 1070 connection_->DumpMemoryStats(stats); |
| 1071 size_t memory_estimate = | |
| 1072 stats->total_size + kReadBufferSize + | |
| 1073 base::trace_event::EstimateMemoryUsage(spdy_session_key_) + | |
| 1074 base::trace_event::EstimateMemoryUsage(pooled_aliases_) + | |
| 1075 base::trace_event::EstimateMemoryUsage(active_streams_) + | |
| 1076 base::trace_event::EstimateMemoryUsage(created_streams_) + | |
| 1077 base::trace_event::EstimateMemoryUsage(write_queue_) + | |
| 1078 base::trace_event::EstimateMemoryUsage(initial_settings_); | |
| 1079 if (in_flight_write_) | |
| 1080 memory_estimate += base::trace_event::EstimateMemoryUsage(in_flight_write_); | |
| 1081 if (buffered_spdy_framer_) { | |
| 1082 memory_estimate += | |
| 1083 base::trace_event::EstimateMemoryUsage(buffered_spdy_framer_); | |
| 1084 } | |
| 1085 // TODO(xunjieli): crbug.com/669108. Track |pending_create_stream_queue_|, | |
|
Bence
2017/02/02 14:15:19
Nit: https://crbug.com/669108. For the convenienc
xunjieli
2017/02/02 14:53:42
Done.
| |
| 1086 // |stream_send_unstall_queue_| after std::deque is supported in | |
| 1087 // memory_usage_estimator.h. | |
| 1088 return memory_estimate; | |
| 1066 } | 1089 } |
| 1067 | 1090 |
| 1068 void SpdySession::EnqueueStreamWrite( | 1091 void SpdySession::EnqueueStreamWrite( |
| 1069 const base::WeakPtr<SpdyStream>& stream, | 1092 const base::WeakPtr<SpdyStream>& stream, |
| 1070 SpdyFrameType frame_type, | 1093 SpdyFrameType frame_type, |
| 1071 std::unique_ptr<SpdyBufferProducer> producer) { | 1094 std::unique_ptr<SpdyBufferProducer> producer) { |
| 1072 DCHECK(frame_type == HEADERS || frame_type == DATA); | 1095 DCHECK(frame_type == HEADERS || frame_type == DATA); |
| 1073 EnqueueWrite(stream->priority(), frame_type, std::move(producer), stream); | 1096 EnqueueWrite(stream->priority(), frame_type, std::move(producer), stream); |
| 1074 } | 1097 } |
| 1075 | 1098 |
| (...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3119 if (!queue->empty()) { | 3142 if (!queue->empty()) { |
| 3120 SpdyStreamId stream_id = queue->front(); | 3143 SpdyStreamId stream_id = queue->front(); |
| 3121 queue->pop_front(); | 3144 queue->pop_front(); |
| 3122 return stream_id; | 3145 return stream_id; |
| 3123 } | 3146 } |
| 3124 } | 3147 } |
| 3125 return 0; | 3148 return 0; |
| 3126 } | 3149 } |
| 3127 | 3150 |
| 3128 } // namespace net | 3151 } // namespace net |
| OLD | NEW |