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

Side by Side Diff: net/quic/chromium/quic_stream_factory.cc

Issue 2807493002: Track STL containers in QuicStreamFactory::DumpMemoryStats (Closed)
Patch Set: address zhongyi@ comment Created 3 years, 8 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/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_test.cc » ('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/quic/chromium/quic_stream_factory.h" 5 #include "net/quic/chromium/quic_stream_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "net/socket/udp_client_socket.h" 60 #include "net/socket/udp_client_socket.h"
61 #include "net/ssl/token_binding.h" 61 #include "net/ssl/token_binding.h"
62 #include "third_party/boringssl/src/include/openssl/aead.h" 62 #include "third_party/boringssl/src/include/openssl/aead.h"
63 #include "url/gurl.h" 63 #include "url/gurl.h"
64 #include "url/url_constants.h" 64 #include "url/url_constants.h"
65 65
66 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; 66 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle;
67 67
68 namespace net { 68 namespace net {
69 69
70 // Returns the estimate of dynamically allocated memory of an IPEndPoint in
71 // bytes. Used in tracking IPAliasMap.
72 size_t EstimateMemoryUsage(const IPEndPoint& end_point) {
73 return 0;
74 }
75
70 namespace { 76 namespace {
71 77
72 enum CreateSessionFailure { 78 enum CreateSessionFailure {
73 CREATION_ERROR_CONNECTING_SOCKET, 79 CREATION_ERROR_CONNECTING_SOCKET,
74 CREATION_ERROR_SETTING_RECEIVE_BUFFER, 80 CREATION_ERROR_SETTING_RECEIVE_BUFFER,
75 CREATION_ERROR_SETTING_SEND_BUFFER, 81 CREATION_ERROR_SETTING_SEND_BUFFER,
76 CREATION_ERROR_SETTING_DO_NOT_FRAGMENT, 82 CREATION_ERROR_SETTING_DO_NOT_FRAGMENT,
77 CREATION_ERROR_MAX 83 CREATION_ERROR_MAX
78 }; 84 };
79 85
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 289
284 void OnComplete() { 290 void OnComplete() {
285 UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime", 291 UMA_HISTOGRAM_TIMES("Net.QuicSession.CertVerifierJob.CompleteTime",
286 base::TimeTicks::Now() - start_time_); 292 base::TimeTicks::Now() - start_time_);
287 if (!callback_.is_null()) 293 if (!callback_.is_null())
288 base::ResetAndReturn(&callback_).Run(OK); 294 base::ResetAndReturn(&callback_).Run(OK);
289 } 295 }
290 296
291 const QuicServerId& server_id() const { return server_id_; } 297 const QuicServerId& server_id() const { return server_id_; }
292 298
299 size_t EstimateMemoryUsage() const {
300 // TODO(xunjieli): crbug.com/669108. Track |verify_context_| and
301 // |verify_details_|.
302 return base::trace_event::EstimateMemoryUsage(verify_error_details_);
303 }
304
293 private: 305 private:
294 const QuicServerId server_id_; 306 const QuicServerId server_id_;
295 ProofVerifierCallbackImpl* verify_callback_; 307 ProofVerifierCallbackImpl* verify_callback_;
296 std::unique_ptr<ProofVerifyContext> verify_context_; 308 std::unique_ptr<ProofVerifyContext> verify_context_;
297 std::unique_ptr<ProofVerifyDetails> verify_details_; 309 std::unique_ptr<ProofVerifyDetails> verify_details_;
298 std::string verify_error_details_; 310 std::string verify_error_details_;
299 const base::TimeTicks start_time_; 311 const base::TimeTicks start_time_;
300 const NetLogWithSource net_log_; 312 const NetLogWithSource net_log_;
301 CompletionCallback callback_; 313 CompletionCallback callback_;
302 base::WeakPtrFactory<CertVerifierJob> weak_factory_; 314 base::WeakPtrFactory<CertVerifierJob> weak_factory_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 void RunAuxilaryJob(); 352 void RunAuxilaryJob();
341 353
342 void Cancel(); 354 void Cancel();
343 355
344 void CancelWaitForDataReadyCallback(); 356 void CancelWaitForDataReadyCallback();
345 357
346 const QuicSessionKey& key() const { return key_; } 358 const QuicSessionKey& key() const { return key_; }
347 359
348 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 360 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
349 361
362 // Returns the estimate of dynamically allocated memory in bytes.
363 size_t EstimateMemoryUsage() const;
364
350 private: 365 private:
351 enum IoState { 366 enum IoState {
352 STATE_NONE, 367 STATE_NONE,
353 STATE_RESOLVE_HOST, 368 STATE_RESOLVE_HOST,
354 STATE_RESOLVE_HOST_COMPLETE, 369 STATE_RESOLVE_HOST_COMPLETE,
355 STATE_LOAD_SERVER_INFO, 370 STATE_LOAD_SERVER_INFO,
356 STATE_LOAD_SERVER_INFO_COMPLETE, 371 STATE_LOAD_SERVER_INFO_COMPLETE,
357 STATE_CONNECT, 372 STATE_CONNECT,
358 STATE_CONNECT_COMPLETE, 373 STATE_CONNECT_COMPLETE,
359 }; 374 };
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 501 }
487 502
488 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { 503 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() {
489 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. 504 // If we are waiting for WaitForDataReadyCallback, then cancel the callback.
490 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) 505 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE)
491 return; 506 return;
492 server_info_->CancelWaitForDataReadyCallback(); 507 server_info_->CancelWaitForDataReadyCallback();
493 OnIOComplete(OK); 508 OnIOComplete(OK);
494 } 509 }
495 510
511 size_t QuicStreamFactory::Job::EstimateMemoryUsage() const {
512 return base::trace_event::EstimateMemoryUsage(key_) +
513 base::trace_event::EstimateMemoryUsage(server_info_);
514 }
515
496 int QuicStreamFactory::Job::DoResolveHost() { 516 int QuicStreamFactory::Job::DoResolveHost() {
497 dns_resolution_start_time_ = base::TimeTicks::Now(); 517 dns_resolution_start_time_ = base::TimeTicks::Now();
498 // Start loading the data now, and wait for it after we resolve the host. 518 // Start loading the data now, and wait for it after we resolve the host.
499 if (server_info_) 519 if (server_info_)
500 server_info_->Start(); 520 server_info_->Start();
501 521
502 io_state_ = STATE_RESOLVE_HOST_COMPLETE; 522 io_state_ = STATE_RESOLVE_HOST_COMPLETE;
503 return host_resolver_->Resolve( 523 return host_resolver_->Resolve(
504 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, 524 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY,
505 &address_list_, 525 &address_list_,
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 } 937 }
918 938
919 void QuicStreamFactory::set_quic_server_info_factory( 939 void QuicStreamFactory::set_quic_server_info_factory(
920 QuicServerInfoFactory* quic_server_info_factory) { 940 QuicServerInfoFactory* quic_server_info_factory) {
921 quic_server_info_factory_.reset(quic_server_info_factory); 941 quic_server_info_factory_.reset(quic_server_info_factory);
922 } 942 }
923 943
924 void QuicStreamFactory::DumpMemoryStats( 944 void QuicStreamFactory::DumpMemoryStats(
925 base::trace_event::ProcessMemoryDump* pmd, 945 base::trace_event::ProcessMemoryDump* pmd,
926 const std::string& parent_absolute_name) const { 946 const std::string& parent_absolute_name) const {
927 if (all_sessions_.empty()) 947 if (all_sessions_.empty() && active_jobs_.empty())
928 return; 948 return;
929 base::trace_event::MemoryAllocatorDump* factory_dump = 949 base::trace_event::MemoryAllocatorDump* factory_dump =
930 pmd->CreateAllocatorDump(parent_absolute_name + "/quic_stream_factory"); 950 pmd->CreateAllocatorDump(parent_absolute_name + "/quic_stream_factory");
931 size_t memory_estimate = 951 size_t memory_estimate =
932 base::trace_event::EstimateMemoryUsage(all_sessions_); 952 base::trace_event::EstimateMemoryUsage(all_sessions_) +
953 base::trace_event::EstimateMemoryUsage(active_sessions_) +
954 base::trace_event::EstimateMemoryUsage(session_aliases_) +
955 base::trace_event::EstimateMemoryUsage(ip_aliases_) +
956 base::trace_event::EstimateMemoryUsage(session_peer_ip_) +
957 base::trace_event::EstimateMemoryUsage(gone_away_aliases_) +
958 base::trace_event::EstimateMemoryUsage(active_jobs_) +
959 base::trace_event::EstimateMemoryUsage(job_requests_map_) +
960 base::trace_event::EstimateMemoryUsage(active_cert_verifier_jobs_);
933 factory_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 961 factory_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
934 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 962 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
935 memory_estimate); 963 memory_estimate);
936 factory_dump->AddScalar( 964 factory_dump->AddScalar("all_sessions",
937 base::trace_event::MemoryAllocatorDump::kNameObjectCount, 965 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
938 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 966 all_sessions_.size());
939 all_sessions_.size()); 967 factory_dump->AddScalar("active_jobs",
968 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
969 active_jobs_.size());
970 factory_dump->AddScalar("active_cert_jobs",
971 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
972 active_cert_verifier_jobs_.size());
940 } 973 }
941 974
942 bool QuicStreamFactory::CanUseExistingSession(const QuicServerId& server_id, 975 bool QuicStreamFactory::CanUseExistingSession(const QuicServerId& server_id,
943 const HostPortPair& destination) { 976 const HostPortPair& destination) {
944 // TODO(zhongyi): delete active_sessions_.empty() checks once the 977 // TODO(zhongyi): delete active_sessions_.empty() checks once the
945 // android crash issue(crbug.com/498823) is resolved. 978 // android crash issue(crbug.com/498823) is resolved.
946 if (active_sessions_.empty()) 979 if (active_sessions_.empty())
947 return false; 980 return false;
948 981
949 if (base::ContainsKey(active_sessions_, server_id)) 982 if (base::ContainsKey(active_sessions_, server_id))
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 // Since the session was active, there's no longer an 1960 // Since the session was active, there's no longer an
1928 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1961 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1929 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1962 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1930 // it as recently broken, which means that 0-RTT will be disabled but we'll 1963 // it as recently broken, which means that 0-RTT will be disabled but we'll
1931 // still race. 1964 // still race.
1932 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1965 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1933 alternative_service); 1966 alternative_service);
1934 } 1967 }
1935 1968
1936 } // namespace net 1969 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698