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

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

Issue 2324183002: Implement QuicHttpStream::GetLoadTimingInfo (Closed)
Patch Set: address comments Created 4 years, 3 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
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 <openssl/aead.h> 7 #include <openssl/aead.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <tuple> 10 #include <tuple>
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 QuicSessionKey key_; 345 QuicSessionKey key_;
346 int cert_verify_flags_; 346 int cert_verify_flags_;
347 bool was_alternative_service_recently_broken_; 347 bool was_alternative_service_recently_broken_;
348 std::unique_ptr<QuicServerInfo> server_info_; 348 std::unique_ptr<QuicServerInfo> server_info_;
349 bool started_another_job_; 349 bool started_another_job_;
350 const BoundNetLog net_log_; 350 const BoundNetLog net_log_;
351 int num_sent_client_hellos_; 351 int num_sent_client_hellos_;
352 QuicChromiumClientSession* session_; 352 QuicChromiumClientSession* session_;
353 CompletionCallback callback_; 353 CompletionCallback callback_;
354 AddressList address_list_; 354 AddressList address_list_;
355 base::TimeTicks dns_resolution_start_time_;
355 base::TimeTicks dns_resolution_end_time_; 356 base::TimeTicks dns_resolution_end_time_;
356 base::WeakPtrFactory<Job> weak_factory_; 357 base::WeakPtrFactory<Job> weak_factory_;
357 DISALLOW_COPY_AND_ASSIGN(Job); 358 DISALLOW_COPY_AND_ASSIGN(Job);
358 }; 359 };
359 360
360 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, 361 QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
361 HostResolver* host_resolver, 362 HostResolver* host_resolver,
362 const QuicSessionKey& key, 363 const QuicSessionKey& key,
363 bool was_alternative_service_recently_broken, 364 bool was_alternative_service_recently_broken,
364 int cert_verify_flags, 365 int cert_verify_flags,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 472
472 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { 473 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() {
473 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. 474 // If we are waiting for WaitForDataReadyCallback, then cancel the callback.
474 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) 475 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE)
475 return; 476 return;
476 server_info_->CancelWaitForDataReadyCallback(); 477 server_info_->CancelWaitForDataReadyCallback();
477 OnIOComplete(OK); 478 OnIOComplete(OK);
478 } 479 }
479 480
480 int QuicStreamFactory::Job::DoResolveHost() { 481 int QuicStreamFactory::Job::DoResolveHost() {
482 dns_resolution_start_time_ = base::TimeTicks::Now();
481 // Start loading the data now, and wait for it after we resolve the host. 483 // Start loading the data now, and wait for it after we resolve the host.
482 if (server_info_) 484 if (server_info_)
483 server_info_->Start(); 485 server_info_->Start();
484 486
485 io_state_ = STATE_RESOLVE_HOST_COMPLETE; 487 io_state_ = STATE_RESOLVE_HOST_COMPLETE;
486 return host_resolver_->Resolve( 488 return host_resolver_->Resolve(
487 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY, 489 HostResolver::RequestInfo(key_.destination()), DEFAULT_PRIORITY,
488 &address_list_, 490 &address_list_,
489 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()), 491 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr()),
490 &request_, net_log_); 492 &request_, net_log_);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return ERR_CONNECTION_CLOSED; 565 return ERR_CONNECTION_CLOSED;
564 } 566 }
565 567
566 io_state_ = STATE_CONNECT; 568 io_state_ = STATE_CONNECT;
567 return OK; 569 return OK;
568 } 570 }
569 571
570 int QuicStreamFactory::Job::DoConnect() { 572 int QuicStreamFactory::Job::DoConnect() {
571 io_state_ = STATE_CONNECT_COMPLETE; 573 io_state_ = STATE_CONNECT_COMPLETE;
572 574
573 int rv = factory_->CreateSession( 575 int rv =
574 key_, cert_verify_flags_, std::move(server_info_), address_list_, 576 factory_->CreateSession(key_, cert_verify_flags_, std::move(server_info_),
575 dns_resolution_end_time_, net_log_, &session_); 577 address_list_, dns_resolution_start_time_,
578 dns_resolution_end_time_, net_log_, &session_);
576 if (rv != OK) { 579 if (rv != OK) {
577 DCHECK(rv != ERR_IO_PENDING); 580 DCHECK(rv != ERR_IO_PENDING);
578 DCHECK(!session_); 581 DCHECK(!session_);
579 return rv; 582 return rv;
580 } 583 }
581 584
582 if (!session_->connection()->connected()) 585 if (!session_->connection()->connected())
583 return ERR_CONNECTION_CLOSED; 586 return ERR_CONNECTION_CLOSED;
584 587
585 session_->StartReading(); 588 session_->StartReading();
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 } 1763 }
1761 1764
1762 return OK; 1765 return OK;
1763 } 1766 }
1764 1767
1765 int QuicStreamFactory::CreateSession( 1768 int QuicStreamFactory::CreateSession(
1766 const QuicSessionKey& key, 1769 const QuicSessionKey& key,
1767 int cert_verify_flags, 1770 int cert_verify_flags,
1768 std::unique_ptr<QuicServerInfo> server_info, 1771 std::unique_ptr<QuicServerInfo> server_info,
1769 const AddressList& address_list, 1772 const AddressList& address_list,
1773 base::TimeTicks dns_resolution_start_time,
1770 base::TimeTicks dns_resolution_end_time, 1774 base::TimeTicks dns_resolution_end_time,
1771 const BoundNetLog& net_log, 1775 const BoundNetLog& net_log,
1772 QuicChromiumClientSession** session) { 1776 QuicChromiumClientSession** session) {
1773 TRACE_EVENT0("net", "QuicStreamFactory::CreateSession"); 1777 TRACE_EVENT0("net", "QuicStreamFactory::CreateSession");
1774 IPEndPoint addr = *address_list.begin(); 1778 IPEndPoint addr = *address_list.begin();
1775 bool enable_port_selection = enable_port_selection_; 1779 bool enable_port_selection = enable_port_selection_;
1776 if (enable_port_selection && base::ContainsKey(gone_away_aliases_, key)) { 1780 if (enable_port_selection && base::ContainsKey(gone_away_aliases_, key)) {
1777 // Disable port selection when the server is going away. 1781 // Disable port selection when the server is going away.
1778 // There is no point in trying to return to the same server, if 1782 // There is no point in trying to return to the same server, if
1779 // that server is no longer handling requests. 1783 // that server is no longer handling requests.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 socket_performance_watcher = 1856 socket_performance_watcher =
1853 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( 1857 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher(
1854 SocketPerformanceWatcherFactory::PROTOCOL_QUIC); 1858 SocketPerformanceWatcherFactory::PROTOCOL_QUIC);
1855 } 1859 }
1856 1860
1857 *session = new QuicChromiumClientSession( 1861 *session = new QuicChromiumClientSession(
1858 connection, std::move(socket), this, quic_crypto_client_stream_factory_, 1862 connection, std::move(socket), this, quic_crypto_client_stream_factory_,
1859 clock_.get(), transport_security_state_, std::move(server_info), 1863 clock_.get(), transport_security_state_, std::move(server_info),
1860 server_id, yield_after_packets_, yield_after_duration_, cert_verify_flags, 1864 server_id, yield_after_packets_, yield_after_duration_, cert_verify_flags,
1861 config, &crypto_config_, network_connection_.GetDescription(), 1865 config, &crypto_config_, network_connection_.GetDescription(),
1862 dns_resolution_end_time, &push_promise_index_, 1866 dns_resolution_start_time, dns_resolution_end_time, &push_promise_index_,
1863 base::ThreadTaskRunnerHandle::Get().get(), 1867 base::ThreadTaskRunnerHandle::Get().get(),
1864 std::move(socket_performance_watcher), net_log.net_log()); 1868 std::move(socket_performance_watcher), net_log.net_log());
1865 1869
1866 all_sessions_[*session] = key; // owning pointer 1870 all_sessions_[*session] = key; // owning pointer
1867 writer->Initialize(*session, connection); 1871 writer->Initialize(*session, connection);
1868 1872
1869 (*session)->Initialize(); 1873 (*session)->Initialize();
1870 bool closed_during_initialize = !base::ContainsKey(all_sessions_, *session) || 1874 bool closed_during_initialize = !base::ContainsKey(all_sessions_, *session) ||
1871 !(*session)->connection()->connected(); 1875 !(*session)->connection()->connected();
1872 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", 1876 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession",
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 // Since the session was active, there's no longer an 2061 // Since the session was active, there's no longer an
2058 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 2062 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
2059 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 2063 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
2060 // it as recently broken, which means that 0-RTT will be disabled but we'll 2064 // it as recently broken, which means that 0-RTT will be disabled but we'll
2061 // still race. 2065 // still race.
2062 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 2066 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
2063 alternative_service); 2067 alternative_service);
2064 } 2068 }
2065 2069
2066 } // namespace net 2070 } // namespace net
OLDNEW
« net/quic/chromium/quic_http_stream.cc ('K') | « net/quic/chromium/quic_stream_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698