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

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

Issue 2665283003: Improve memory estimate of SpdySessionPool in net/ MemoryDumpProvider. (Closed)
Patch Set: rebased 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_key.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 28 matching lines...) Expand all
39 #include "net/http/http_util.h" 39 #include "net/http/http_util.h"
40 #include "net/http/transport_security_state.h" 40 #include "net/http/transport_security_state.h"
41 #include "net/log/net_log.h" 41 #include "net/log/net_log.h"
42 #include "net/log/net_log_capture_mode.h" 42 #include "net/log/net_log_capture_mode.h"
43 #include "net/log/net_log_event_type.h" 43 #include "net/log/net_log_event_type.h"
44 #include "net/log/net_log_source.h" 44 #include "net/log/net_log_source.h"
45 #include "net/log/net_log_source_type.h" 45 #include "net/log/net_log_source_type.h"
46 #include "net/log/net_log_with_source.h" 46 #include "net/log/net_log_with_source.h"
47 #include "net/proxy/proxy_server.h" 47 #include "net/proxy/proxy_server.h"
48 #include "net/socket/ssl_client_socket.h" 48 #include "net/socket/ssl_client_socket.h"
49 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
49 #include "net/spdy/spdy_buffer_producer.h" 50 #include "net/spdy/spdy_buffer_producer.h"
50 #include "net/spdy/spdy_frame_builder.h" 51 #include "net/spdy/spdy_frame_builder.h"
51 #include "net/spdy/spdy_http_utils.h" 52 #include "net/spdy/spdy_http_utils.h"
52 #include "net/spdy/spdy_protocol.h" 53 #include "net/spdy/spdy_protocol.h"
53 #include "net/spdy/spdy_session_pool.h" 54 #include "net/spdy/spdy_session_pool.h"
54 #include "net/spdy/spdy_stream.h" 55 #include "net/spdy/spdy_stream.h"
55 #include "net/ssl/channel_id_service.h" 56 #include "net/ssl/channel_id_service.h"
56 #include "net/ssl/ssl_cipher_suite_names.h" 57 #include "net/ssl/ssl_cipher_suite_names.h"
57 #include "net/ssl/ssl_connection_status_flags.h" 58 #include "net/ssl/ssl_connection_status_flags.h"
58 59
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 576 }
576 577
577 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() { 578 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() {
578 DCHECK(!session_); 579 DCHECK(!session_);
579 base::WeakPtr<SpdyStream> stream = stream_; 580 base::WeakPtr<SpdyStream> stream = stream_;
580 DCHECK(stream); 581 DCHECK(stream);
581 Reset(); 582 Reset();
582 return stream; 583 return stream;
583 } 584 }
584 585
586 size_t SpdyStreamRequest::EstimateMemoryUsage() const {
587 return base::trace_event::EstimateItemMemoryUsage(url_);
588 }
589
585 void SpdyStreamRequest::OnRequestCompleteSuccess( 590 void SpdyStreamRequest::OnRequestCompleteSuccess(
586 const base::WeakPtr<SpdyStream>& stream) { 591 const base::WeakPtr<SpdyStream>& stream) {
587 DCHECK(session_); 592 DCHECK(session_);
588 DCHECK(!stream_); 593 DCHECK(!stream_);
589 DCHECK(!callback_.is_null()); 594 DCHECK(!callback_.is_null());
590 CompletionCallback callback = callback_; 595 CompletionCallback callback = callback_;
591 Reset(); 596 Reset();
592 DCHECK(stream); 597 DCHECK(stream);
593 stream_ = stream; 598 stream_ = stream;
594 callback.Run(OK); 599 callback.Run(OK);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 spdy_session_->pool_->RegisterUnclaimedPushedStream( 658 spdy_session_->pool_->RegisterUnclaimedPushedStream(
654 url, spdy_session_->GetWeakPtr()); 659 url, spdy_session_->GetWeakPtr());
655 } 660 }
656 return streams_.insert( 661 return streams_.insert(
657 position, 662 position,
658 std::make_pair( 663 std::make_pair(
659 url, SpdySession::UnclaimedPushedStreamContainer::PushedStreamInfo( 664 url, SpdySession::UnclaimedPushedStreamContainer::PushedStreamInfo(
660 stream_id, creation_time))); 665 stream_id, creation_time)));
661 } 666 }
662 667
668 size_t SpdySession::UnclaimedPushedStreamContainer::EstimateMemoryUsage()
669 const {
670 return SpdyEstimateMemoryUsage(streams_);
671 }
672
663 // static 673 // static
664 bool SpdySession::CanPool(TransportSecurityState* transport_security_state, 674 bool SpdySession::CanPool(TransportSecurityState* transport_security_state,
665 const SSLInfo& ssl_info, 675 const SSLInfo& ssl_info,
666 const std::string& old_hostname, 676 const std::string& old_hostname,
667 const std::string& new_hostname) { 677 const std::string& new_hostname) {
668 // Pooling is prohibited if the server cert is not valid for the new domain, 678 // Pooling is prohibited if the server cert is not valid for the new domain,
669 // and for connections on which client certs were sent. It is also prohibited 679 // and for connections on which client certs were sent. It is also prohibited
670 // when channel ID was sent if the hosts are from different eTLDs+1. 680 // when channel ID was sent if the hosts are from different eTLDs+1.
671 if (IsCertStatusError(ssl_info.cert_status)) 681 if (IsCertStatusError(ssl_info.cert_status))
672 return false; 682 return false;
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 bool SpdySession::CloseOneIdleConnection() { 1352 bool SpdySession::CloseOneIdleConnection() {
1343 CHECK(!in_io_loop_); 1353 CHECK(!in_io_loop_);
1344 DCHECK(pool_); 1354 DCHECK(pool_);
1345 if (active_streams_.empty()) { 1355 if (active_streams_.empty()) {
1346 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); 1356 DoDrainSession(ERR_CONNECTION_CLOSED, "Closing idle connection.");
1347 } 1357 }
1348 // Return false as the socket wasn't immediately closed. 1358 // Return false as the socket wasn't immediately closed.
1349 return false; 1359 return false;
1350 } 1360 }
1351 1361
1352 void SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats, 1362 size_t SpdySession::DumpMemoryStats(StreamSocket::SocketMemoryStats* stats,
1353 bool* is_session_active) const { 1363 bool* is_session_active) const {
1364 // TODO(xunjieli): Include |pending_create_stream_queues_| when WeakPtr is
1365 // supported in memory_usage_estimator.h.
1354 *is_session_active = is_active(); 1366 *is_session_active = is_active();
1355 connection_->DumpMemoryStats(stats); 1367 connection_->DumpMemoryStats(stats);
1368
1369 // |connection_| is estimated in stats->total_size. |read_buffer_| is
1370 // estimated in kReadBufferSize. TODO(xunjieli): Make them use EMU().
1371 return stats->total_size + kReadBufferSize +
1372 SpdyEstimateMemoryUsage(spdy_session_key_) +
1373 SpdyEstimateMemoryUsage(pooled_aliases_) +
1374 SpdyEstimateMemoryUsage(active_streams_) +
1375 SpdyEstimateMemoryUsage(unclaimed_pushed_streams_) +
1376 SpdyEstimateMemoryUsage(created_streams_) +
1377 SpdyEstimateMemoryUsage(write_queue_) +
1378 SpdyEstimateMemoryUsage(in_flight_write_) +
1379 SpdyEstimateMemoryUsage(buffered_spdy_framer_) +
1380 SpdyEstimateMemoryUsage(initial_settings_) +
1381 SpdyEstimateMemoryUsage(stream_send_unstall_queue_) +
1382 SpdyEstimateMemoryUsage(priority_dependency_state_);
1356 } 1383 }
1357 1384
1358 // {,Try}CreateStream() can be called with |in_io_loop_| set if a stream is 1385 // {,Try}CreateStream() can be called with |in_io_loop_| set if a stream is
1359 // being created in response to another being closed due to received data. 1386 // being created in response to another being closed due to received data.
1360 1387
1361 int SpdySession::TryCreateStream( 1388 int SpdySession::TryCreateStream(
1362 const base::WeakPtr<SpdyStreamRequest>& request, 1389 const base::WeakPtr<SpdyStreamRequest>& request,
1363 base::WeakPtr<SpdyStream>* stream) { 1390 base::WeakPtr<SpdyStream>* stream) {
1364 DCHECK(request); 1391 DCHECK(request);
1365 1392
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 if (!queue->empty()) { 3157 if (!queue->empty()) {
3131 SpdyStreamId stream_id = queue->front(); 3158 SpdyStreamId stream_id = queue->front();
3132 queue->pop_front(); 3159 queue->pop_front();
3133 return stream_id; 3160 return stream_id;
3134 } 3161 }
3135 } 3162 }
3136 return 0; 3163 return 0;
3137 } 3164 }
3138 3165
3139 } // namespace net 3166 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698