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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 NetLogCaptureMode capture_mode) { 106 NetLogCaptureMode capture_mode) {
107 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 107 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
108 dict->SetString("connection_id", base::Uint64ToString(connection_id)); 108 dict->SetString("connection_id", base::Uint64ToString(connection_id));
109 return std::move(dict); 109 return std::move(dict);
110 } 110 }
111 111
112 // Helper class that is used to log a connection migration event. 112 // Helper class that is used to log a connection migration event.
113 class ScopedConnectionMigrationEventLog { 113 class ScopedConnectionMigrationEventLog {
114 public: 114 public:
115 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger) 115 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger)
116 : net_log_( 116 : net_log_(NetLogWithSource::Make(
117 BoundNetLog::Make(net_log, 117 net_log,
118 NetLogSourceType::QUIC_CONNECTION_MIGRATION)) { 118 NetLogSourceType::QUIC_CONNECTION_MIGRATION)) {
119 net_log_.BeginEvent( 119 net_log_.BeginEvent(
120 NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED, 120 NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED,
121 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger)); 121 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger));
122 } 122 }
123 123
124 ~ScopedConnectionMigrationEventLog() { 124 ~ScopedConnectionMigrationEventLog() {
125 net_log_.EndEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED); 125 net_log_.EndEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED);
126 } 126 }
127 127
128 const BoundNetLog& net_log() { return net_log_; } 128 const NetLogWithSource& net_log() { return net_log_; }
129 129
130 private: 130 private:
131 const BoundNetLog net_log_; 131 const NetLogWithSource net_log_;
132 }; 132 };
133 133
134 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { 134 void HistogramCreateSessionFailure(enum CreateSessionFailure error) {
135 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, 135 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error,
136 CREATION_ERROR_MAX); 136 CREATION_ERROR_MAX);
137 } 137 }
138 138
139 void HistogramAndLogMigrationFailure(const BoundNetLog& net_log, 139 void HistogramAndLogMigrationFailure(const NetLogWithSource& net_log,
140 enum QuicConnectionMigrationStatus status, 140 enum QuicConnectionMigrationStatus status,
141 QuicConnectionId connection_id, 141 QuicConnectionId connection_id,
142 std::string reason) { 142 std::string reason) {
143 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status, 143 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status,
144 MIGRATION_STATUS_MAX); 144 MIGRATION_STATUS_MAX);
145 net_log.AddEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_FAILURE, 145 net_log.AddEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_FAILURE,
146 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, 146 base::Bind(&NetLogQuicConnectionMigrationFailureCallback,
147 connection_id, reason)); 147 connection_id, reason));
148 } 148 }
149 149
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 void Cancel() { job_ = nullptr; } 213 void Cancel() { job_ = nullptr; }
214 214
215 private: 215 private:
216 CertVerifierJob* job_; 216 CertVerifierJob* job_;
217 }; 217 };
218 218
219 CertVerifierJob(const QuicServerId& server_id, 219 CertVerifierJob(const QuicServerId& server_id,
220 int cert_verify_flags, 220 int cert_verify_flags,
221 const BoundNetLog& net_log) 221 const NetLogWithSource& net_log)
222 : server_id_(server_id), 222 : server_id_(server_id),
223 verify_callback_(nullptr), 223 verify_callback_(nullptr),
224 verify_context_(base::WrapUnique( 224 verify_context_(base::WrapUnique(
225 new ProofVerifyContextChromium(cert_verify_flags, net_log))), 225 new ProofVerifyContextChromium(cert_verify_flags, net_log))),
226 start_time_(base::TimeTicks::Now()), 226 start_time_(base::TimeTicks::Now()),
227 net_log_(net_log), 227 net_log_(net_log),
228 weak_factory_(this) {} 228 weak_factory_(this) {}
229 229
230 ~CertVerifierJob() { 230 ~CertVerifierJob() {
231 if (verify_callback_) 231 if (verify_callback_)
(...skipping 27 matching lines...) Expand all
259 259
260 const QuicServerId& server_id() const { return server_id_; } 260 const QuicServerId& server_id() const { return server_id_; }
261 261
262 private: 262 private:
263 QuicServerId server_id_; 263 QuicServerId server_id_;
264 ProofVerifierCallbackImpl* verify_callback_; 264 ProofVerifierCallbackImpl* verify_callback_;
265 std::unique_ptr<ProofVerifyContext> verify_context_; 265 std::unique_ptr<ProofVerifyContext> verify_context_;
266 std::unique_ptr<ProofVerifyDetails> verify_details_; 266 std::unique_ptr<ProofVerifyDetails> verify_details_;
267 std::string verify_error_details_; 267 std::string verify_error_details_;
268 base::TimeTicks start_time_; 268 base::TimeTicks start_time_;
269 const BoundNetLog net_log_; 269 const NetLogWithSource net_log_;
270 CompletionCallback callback_; 270 CompletionCallback callback_;
271 base::WeakPtrFactory<CertVerifierJob> weak_factory_; 271 base::WeakPtrFactory<CertVerifierJob> weak_factory_;
272 272
273 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob); 273 DISALLOW_COPY_AND_ASSIGN(CertVerifierJob);
274 }; 274 };
275 275
276 // Responsible for creating a new QUIC session to the specified server, and 276 // Responsible for creating a new QUIC session to the specified server, and
277 // for notifying any associated requests when complete. 277 // for notifying any associated requests when complete.
278 class QuicStreamFactory::Job { 278 class QuicStreamFactory::Job {
279 public: 279 public:
280 Job(QuicStreamFactory* factory, 280 Job(QuicStreamFactory* factory,
281 HostResolver* host_resolver, 281 HostResolver* host_resolver,
282 const QuicSessionKey& key, 282 const QuicSessionKey& key,
283 bool was_alternative_service_recently_broken, 283 bool was_alternative_service_recently_broken,
284 int cert_verify_flags, 284 int cert_verify_flags,
285 QuicServerInfo* server_info, 285 QuicServerInfo* server_info,
286 const BoundNetLog& net_log); 286 const NetLogWithSource& net_log);
287 287
288 // Creates a new job to handle the resumption of for connecting an 288 // Creates a new job to handle the resumption of for connecting an
289 // existing session. 289 // existing session.
290 Job(QuicStreamFactory* factory, 290 Job(QuicStreamFactory* factory,
291 HostResolver* host_resolver, 291 HostResolver* host_resolver,
292 QuicChromiumClientSession* session, 292 QuicChromiumClientSession* session,
293 const QuicSessionKey& key); 293 const QuicSessionKey& key);
294 294
295 ~Job(); 295 ~Job();
296 296
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 IoState io_state_; 331 IoState io_state_;
332 332
333 QuicStreamFactory* factory_; 333 QuicStreamFactory* factory_;
334 HostResolver* host_resolver_; 334 HostResolver* host_resolver_;
335 std::unique_ptr<HostResolver::Request> request_; 335 std::unique_ptr<HostResolver::Request> request_;
336 QuicSessionKey key_; 336 QuicSessionKey key_;
337 int cert_verify_flags_; 337 int cert_verify_flags_;
338 bool was_alternative_service_recently_broken_; 338 bool was_alternative_service_recently_broken_;
339 std::unique_ptr<QuicServerInfo> server_info_; 339 std::unique_ptr<QuicServerInfo> server_info_;
340 bool started_another_job_; 340 bool started_another_job_;
341 const BoundNetLog net_log_; 341 const NetLogWithSource net_log_;
342 int num_sent_client_hellos_; 342 int num_sent_client_hellos_;
343 QuicChromiumClientSession* session_; 343 QuicChromiumClientSession* session_;
344 CompletionCallback callback_; 344 CompletionCallback callback_;
345 AddressList address_list_; 345 AddressList address_list_;
346 base::TimeTicks dns_resolution_start_time_; 346 base::TimeTicks dns_resolution_start_time_;
347 base::TimeTicks dns_resolution_end_time_; 347 base::TimeTicks dns_resolution_end_time_;
348 base::WeakPtrFactory<Job> weak_factory_; 348 base::WeakPtrFactory<Job> weak_factory_;
349 DISALLOW_COPY_AND_ASSIGN(Job); 349 DISALLOW_COPY_AND_ASSIGN(Job);
350 }; 350 };
351 351
352 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, 352 QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
353 HostResolver* host_resolver, 353 HostResolver* host_resolver,
354 const QuicSessionKey& key, 354 const QuicSessionKey& key,
355 bool was_alternative_service_recently_broken, 355 bool was_alternative_service_recently_broken,
356 int cert_verify_flags, 356 int cert_verify_flags,
357 QuicServerInfo* server_info, 357 QuicServerInfo* server_info,
358 const BoundNetLog& net_log) 358 const NetLogWithSource& net_log)
359 : io_state_(STATE_RESOLVE_HOST), 359 : io_state_(STATE_RESOLVE_HOST),
360 factory_(factory), 360 factory_(factory),
361 host_resolver_(host_resolver), 361 host_resolver_(host_resolver),
362 key_(key), 362 key_(key),
363 cert_verify_flags_(cert_verify_flags), 363 cert_verify_flags_(cert_verify_flags),
364 was_alternative_service_recently_broken_( 364 was_alternative_service_recently_broken_(
365 was_alternative_service_recently_broken), 365 was_alternative_service_recently_broken),
366 server_info_(server_info), 366 server_info_(server_info),
367 started_another_job_(false), 367 started_another_job_(false),
368 net_log_(net_log), 368 net_log_(net_log),
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 QuicStreamRequest::~QuicStreamRequest() { 643 QuicStreamRequest::~QuicStreamRequest() {
644 if (factory_ && !callback_.is_null()) 644 if (factory_ && !callback_.is_null())
645 factory_->CancelRequest(this); 645 factory_->CancelRequest(this);
646 } 646 }
647 647
648 int QuicStreamRequest::Request(const HostPortPair& destination, 648 int QuicStreamRequest::Request(const HostPortPair& destination,
649 PrivacyMode privacy_mode, 649 PrivacyMode privacy_mode,
650 int cert_verify_flags, 650 int cert_verify_flags,
651 const GURL& url, 651 const GURL& url,
652 base::StringPiece method, 652 base::StringPiece method,
653 const BoundNetLog& net_log, 653 const NetLogWithSource& net_log,
654 const CompletionCallback& callback) { 654 const CompletionCallback& callback) {
655 DCHECK(callback_.is_null()); 655 DCHECK(callback_.is_null());
656 DCHECK(factory_); 656 DCHECK(factory_);
657 server_id_ = QuicServerId(HostPortPair::FromURL(url), privacy_mode); 657 server_id_ = QuicServerId(HostPortPair::FromURL(url), privacy_mode);
658 658
659 int rv = factory_->Create(server_id_, destination, cert_verify_flags, url, 659 int rv = factory_->Create(server_id_, destination, cert_verify_flags, url,
660 method, net_log, this); 660 method, net_log, this);
661 if (rv == ERR_IO_PENDING) { 661 if (rv == ERR_IO_PENDING) {
662 net_log_ = net_log; 662 net_log_ = net_log;
663 callback_ = callback; 663 callback_ = callback;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 918 }
919 919
920 return false; 920 return false;
921 } 921 }
922 922
923 int QuicStreamFactory::Create(const QuicServerId& server_id, 923 int QuicStreamFactory::Create(const QuicServerId& server_id,
924 const HostPortPair& destination, 924 const HostPortPair& destination,
925 int cert_verify_flags, 925 int cert_verify_flags,
926 const GURL& url, 926 const GURL& url,
927 base::StringPiece method, 927 base::StringPiece method,
928 const BoundNetLog& net_log, 928 const NetLogWithSource& net_log,
929 QuicStreamRequest* request) { 929 QuicStreamRequest* request) {
930 DCHECK(server_id.host_port_pair().Equals(HostPortPair::FromURL(url))); 930 DCHECK(server_id.host_port_pair().Equals(HostPortPair::FromURL(url)));
931 // Enforce session affinity for promised streams. 931 // Enforce session affinity for promised streams.
932 QuicClientPromisedInfo* promised = 932 QuicClientPromisedInfo* promised =
933 push_promise_index_.GetPromised(url.spec()); 933 push_promise_index_.GetPromised(url.spec());
934 if (promised) { 934 if (promised) {
935 QuicChromiumClientSession* session = 935 QuicChromiumClientSession* session =
936 static_cast<QuicChromiumClientSession*>(promised->session()); 936 static_cast<QuicChromiumClientSession*>(promised->session());
937 DCHECK(session); 937 DCHECK(session);
938 if (session->server_id().privacy_mode() == server_id.privacy_mode()) { 938 if (session->server_id().privacy_mode() == server_id.privacy_mode()) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 1035 }
1036 1036
1037 bool QuicStreamFactory::QuicSessionKey::operator==( 1037 bool QuicStreamFactory::QuicSessionKey::operator==(
1038 const QuicSessionKey& other) const { 1038 const QuicSessionKey& other) const {
1039 return destination_.Equals(other.destination_) && 1039 return destination_.Equals(other.destination_) &&
1040 server_id_ == other.server_id_; 1040 server_id_ == other.server_id_;
1041 } 1041 }
1042 1042
1043 void QuicStreamFactory::CreateAuxilaryJob(const QuicSessionKey& key, 1043 void QuicStreamFactory::CreateAuxilaryJob(const QuicSessionKey& key,
1044 int cert_verify_flags, 1044 int cert_verify_flags,
1045 const BoundNetLog& net_log) { 1045 const NetLogWithSource& net_log) {
1046 Job* aux_job = 1046 Job* aux_job =
1047 new Job(this, host_resolver_, key, WasQuicRecentlyBroken(key.server_id()), 1047 new Job(this, host_resolver_, key, WasQuicRecentlyBroken(key.server_id()),
1048 cert_verify_flags, nullptr, net_log); 1048 cert_verify_flags, nullptr, net_log);
1049 active_jobs_[key.server_id()].insert(aux_job); 1049 active_jobs_[key.server_id()].insert(aux_job);
1050 task_runner_->PostTask(FROM_HERE, 1050 task_runner_->PostTask(FROM_HERE,
1051 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, 1051 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob,
1052 aux_job->GetWeakPtr())); 1052 aux_job->GetWeakPtr()));
1053 } 1053 }
1054 1054
1055 bool QuicStreamFactory::OnResolution(const QuicSessionKey& key, 1055 bool QuicStreamFactory::OnResolution(const QuicSessionKey& key,
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 for (NetworkHandle new_network : network_list) { 1321 for (NetworkHandle new_network : network_list) {
1322 if (new_network != old_network) 1322 if (new_network != old_network)
1323 return new_network; 1323 return new_network;
1324 } 1324 }
1325 return NetworkChangeNotifier::kInvalidNetworkHandle; 1325 return NetworkChangeNotifier::kInvalidNetworkHandle;
1326 } 1326 }
1327 1327
1328 void QuicStreamFactory::MaybeMigrateOrCloseSessions( 1328 void QuicStreamFactory::MaybeMigrateOrCloseSessions(
1329 NetworkHandle new_network, 1329 NetworkHandle new_network,
1330 bool close_if_cannot_migrate, 1330 bool close_if_cannot_migrate,
1331 const BoundNetLog& bound_net_log) { 1331 const NetLogWithSource& net_log) {
1332 QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin(); 1332 QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin();
1333 while (it != all_sessions_.end()) { 1333 while (it != all_sessions_.end()) {
1334 QuicChromiumClientSession* session = it->first; 1334 QuicChromiumClientSession* session = it->first;
1335 ++it; 1335 ++it;
1336 1336
1337 // If session is already bound to |new_network|, move on. 1337 // If session is already bound to |new_network|, move on.
1338 if (session->GetDefaultSocket()->GetBoundNetwork() == new_network) { 1338 if (session->GetDefaultSocket()->GetBoundNetwork() == new_network) {
1339 HistogramAndLogMigrationFailure( 1339 HistogramAndLogMigrationFailure(
1340 bound_net_log, MIGRATION_STATUS_ALREADY_MIGRATED, 1340 net_log, MIGRATION_STATUS_ALREADY_MIGRATED, session->connection_id(),
1341 session->connection_id(), "Already bound to new network"); 1341 "Already bound to new network");
1342 continue; 1342 continue;
1343 } 1343 }
1344 1344
1345 // Close idle sessions. 1345 // Close idle sessions.
1346 if (session->GetNumActiveStreams() == 0) { 1346 if (session->GetNumActiveStreams() == 0) {
1347 HistogramAndLogMigrationFailure( 1347 HistogramAndLogMigrationFailure(
1348 bound_net_log, MIGRATION_STATUS_NO_MIGRATABLE_STREAMS, 1348 net_log, MIGRATION_STATUS_NO_MIGRATABLE_STREAMS,
1349 session->connection_id(), "No active sessions"); 1349 session->connection_id(), "No active sessions");
1350 session->CloseSessionOnError( 1350 session->CloseSessionOnError(
1351 ERR_NETWORK_CHANGED, QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS); 1351 ERR_NETWORK_CHANGED, QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS);
1352 continue; 1352 continue;
1353 } 1353 }
1354 1354
1355 // If session has active streams, mark it as going away. 1355 // If session has active streams, mark it as going away.
1356 OnSessionGoingAway(session); 1356 OnSessionGoingAway(session);
1357 1357
1358 // Do not migrate sessions where connection migration is disabled. 1358 // Do not migrate sessions where connection migration is disabled.
1359 if (session->config()->DisableConnectionMigration()) { 1359 if (session->config()->DisableConnectionMigration()) {
1360 HistogramAndLogMigrationFailure(bound_net_log, MIGRATION_STATUS_DISABLED, 1360 HistogramAndLogMigrationFailure(net_log, MIGRATION_STATUS_DISABLED,
1361 session->connection_id(), 1361 session->connection_id(),
1362 "Migration disabled"); 1362 "Migration disabled");
1363 if (close_if_cannot_migrate) { 1363 if (close_if_cannot_migrate) {
1364 session->CloseSessionOnError(ERR_NETWORK_CHANGED, 1364 session->CloseSessionOnError(ERR_NETWORK_CHANGED,
1365 QUIC_IP_ADDRESS_CHANGED); 1365 QUIC_IP_ADDRESS_CHANGED);
1366 } 1366 }
1367 continue; 1367 continue;
1368 } 1368 }
1369 1369
1370 // Do not migrate sessions with non-migratable streams. 1370 // Do not migrate sessions with non-migratable streams.
1371 if (session->HasNonMigratableStreams()) { 1371 if (session->HasNonMigratableStreams()) {
1372 HistogramAndLogMigrationFailure( 1372 HistogramAndLogMigrationFailure(
1373 bound_net_log, MIGRATION_STATUS_NON_MIGRATABLE_STREAM, 1373 net_log, MIGRATION_STATUS_NON_MIGRATABLE_STREAM,
1374 session->connection_id(), "Non-migratable stream"); 1374 session->connection_id(), "Non-migratable stream");
1375 if (close_if_cannot_migrate) { 1375 if (close_if_cannot_migrate) {
1376 session->CloseSessionOnError( 1376 session->CloseSessionOnError(
1377 ERR_NETWORK_CHANGED, 1377 ERR_NETWORK_CHANGED,
1378 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); 1378 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM);
1379 } 1379 }
1380 continue; 1380 continue;
1381 } 1381 }
1382 1382
1383 // No new network was found. Notify session, so it can wait for a 1383 // No new network was found. Notify session, so it can wait for a
1384 // new network. 1384 // new network.
1385 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { 1385 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
1386 session->OnNoNewNetwork(); 1386 session->OnNoNewNetwork();
1387 continue; 1387 continue;
1388 } 1388 }
1389 1389
1390 MigrateSessionToNewNetwork(session, new_network, 1390 MigrateSessionToNewNetwork(session, new_network,
1391 /*close_session_on_error=*/true, bound_net_log); 1391 /*close_session_on_error=*/true, net_log);
1392 } 1392 }
1393 } 1393 }
1394 1394
1395 MigrationResult QuicStreamFactory::MaybeMigrateSingleSession( 1395 MigrationResult QuicStreamFactory::MaybeMigrateSingleSession(
1396 QuicChromiumClientSession* session, 1396 QuicChromiumClientSession* session,
1397 MigrationCause migration_cause) { 1397 MigrationCause migration_cause) {
1398 ScopedConnectionMigrationEventLog scoped_event_log( 1398 ScopedConnectionMigrationEventLog scoped_event_log(
1399 net_log_, 1399 net_log_,
1400 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError"); 1400 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError");
1401 if (!migrate_sessions_on_network_change_ || 1401 if (!migrate_sessions_on_network_change_ ||
(...skipping 16 matching lines...) Expand all
1418 } 1418 }
1419 OnSessionGoingAway(session); 1419 OnSessionGoingAway(session);
1420 return MigrateSessionToNewNetwork(session, new_network, 1420 return MigrateSessionToNewNetwork(session, new_network,
1421 migration_cause != WRITE_ERROR, 1421 migration_cause != WRITE_ERROR,
1422 scoped_event_log.net_log()); 1422 scoped_event_log.net_log());
1423 } 1423 }
1424 1424
1425 void QuicStreamFactory::MigrateSessionToNewPeerAddress( 1425 void QuicStreamFactory::MigrateSessionToNewPeerAddress(
1426 QuicChromiumClientSession* session, 1426 QuicChromiumClientSession* session,
1427 IPEndPoint peer_address, 1427 IPEndPoint peer_address,
1428 const BoundNetLog& bound_net_log) { 1428 const NetLogWithSource& net_log) {
1429 if (!allow_server_migration_) 1429 if (!allow_server_migration_)
1430 return; 1430 return;
1431 1431
1432 IPEndPoint old_address; 1432 IPEndPoint old_address;
1433 session->GetDefaultSocket()->GetPeerAddress(&old_address); 1433 session->GetDefaultSocket()->GetPeerAddress(&old_address);
1434 DCHECK_EQ(old_address.GetFamily(), peer_address.GetFamily()); 1434 DCHECK_EQ(old_address.GetFamily(), peer_address.GetFamily());
1435 1435
1436 // Specifying kInvalidNetworkHandle for the |network| parameter 1436 // Specifying kInvalidNetworkHandle for the |network| parameter
1437 // causes the session to use the default network for the new socket. 1437 // causes the session to use the default network for the new socket.
1438 MigrateSessionInner(session, peer_address, 1438 MigrateSessionInner(session, peer_address,
1439 NetworkChangeNotifier::kInvalidNetworkHandle, 1439 NetworkChangeNotifier::kInvalidNetworkHandle,
1440 /*close_session_on_error=*/true, bound_net_log); 1440 /*close_session_on_error=*/true, net_log);
1441 } 1441 }
1442 1442
1443 MigrationResult QuicStreamFactory::MigrateSessionToNewNetwork( 1443 MigrationResult QuicStreamFactory::MigrateSessionToNewNetwork(
1444 QuicChromiumClientSession* session, 1444 QuicChromiumClientSession* session,
1445 NetworkHandle network, 1445 NetworkHandle network,
1446 bool close_session_on_error, 1446 bool close_session_on_error,
1447 const BoundNetLog& bound_net_log) { 1447 const NetLogWithSource& net_log) {
1448 return MigrateSessionInner(session, session->connection()->peer_address(), 1448 return MigrateSessionInner(session, session->connection()->peer_address(),
1449 network, close_session_on_error, bound_net_log); 1449 network, close_session_on_error, net_log);
1450 } 1450 }
1451 1451
1452 MigrationResult QuicStreamFactory::MigrateSessionInner( 1452 MigrationResult QuicStreamFactory::MigrateSessionInner(
1453 QuicChromiumClientSession* session, 1453 QuicChromiumClientSession* session,
1454 IPEndPoint peer_address, 1454 IPEndPoint peer_address,
1455 NetworkHandle network, 1455 NetworkHandle network,
1456 bool close_session_on_error, 1456 bool close_session_on_error,
1457 const BoundNetLog& bound_net_log) { 1457 const NetLogWithSource& net_log) {
1458 // Use OS-specified port for socket (DEFAULT_BIND) instead of 1458 // Use OS-specified port for socket (DEFAULT_BIND) instead of
1459 // using the PortSuggester since the connection is being migrated 1459 // using the PortSuggester since the connection is being migrated
1460 // and not being newly created. 1460 // and not being newly created.
1461 std::unique_ptr<DatagramClientSocket> socket( 1461 std::unique_ptr<DatagramClientSocket> socket(
1462 client_socket_factory_->CreateDatagramClientSocket( 1462 client_socket_factory_->CreateDatagramClientSocket(
1463 DatagramSocket::DEFAULT_BIND, RandIntCallback(), 1463 DatagramSocket::DEFAULT_BIND, RandIntCallback(),
1464 session->net_log().net_log(), session->net_log().source())); 1464 session->net_log().net_log(), session->net_log().source()));
1465 if (ConfigureSocket(socket.get(), peer_address, network) != OK) { 1465 if (ConfigureSocket(socket.get(), peer_address, network) != OK) {
1466 HistogramAndLogMigrationFailure( 1466 HistogramAndLogMigrationFailure(net_log, MIGRATION_STATUS_INTERNAL_ERROR,
1467 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR, 1467 session->connection_id(),
1468 session->connection_id(), "Socket configuration failed"); 1468 "Socket configuration failed");
1469 if (close_session_on_error) { 1469 if (close_session_on_error) {
1470 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); 1470 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR);
1471 } 1471 }
1472 return MigrationResult::FAILURE; 1472 return MigrationResult::FAILURE;
1473 } 1473 }
1474 std::unique_ptr<QuicChromiumPacketReader> new_reader( 1474 std::unique_ptr<QuicChromiumPacketReader> new_reader(
1475 new QuicChromiumPacketReader(socket.get(), clock_.get(), session, 1475 new QuicChromiumPacketReader(socket.get(), clock_.get(), session,
1476 yield_after_packets_, yield_after_duration_, 1476 yield_after_packets_, yield_after_duration_,
1477 session->net_log())); 1477 session->net_log()));
1478 std::unique_ptr<QuicChromiumPacketWriter> new_writer( 1478 std::unique_ptr<QuicChromiumPacketWriter> new_writer(
1479 new QuicChromiumPacketWriter(socket.get())); 1479 new QuicChromiumPacketWriter(socket.get()));
1480 new_writer->set_delegate(session); 1480 new_writer->set_delegate(session);
1481 1481
1482 if (!session->MigrateToSocket(std::move(socket), std::move(new_reader), 1482 if (!session->MigrateToSocket(std::move(socket), std::move(new_reader),
1483 std::move(new_writer))) { 1483 std::move(new_writer))) {
1484 HistogramAndLogMigrationFailure( 1484 HistogramAndLogMigrationFailure(net_log, MIGRATION_STATUS_TOO_MANY_CHANGES,
1485 bound_net_log, MIGRATION_STATUS_TOO_MANY_CHANGES, 1485 session->connection_id(),
1486 session->connection_id(), "Too many migrations"); 1486 "Too many migrations");
1487 if (close_session_on_error) { 1487 if (close_session_on_error) {
1488 session->CloseSessionOnError(ERR_NETWORK_CHANGED, 1488 session->CloseSessionOnError(ERR_NETWORK_CHANGED,
1489 QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES); 1489 QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES);
1490 } 1490 }
1491 return MigrationResult::FAILURE; 1491 return MigrationResult::FAILURE;
1492 } 1492 }
1493 HistogramMigrationStatus(MIGRATION_STATUS_SUCCESS); 1493 HistogramMigrationStatus(MIGRATION_STATUS_SUCCESS);
1494 bound_net_log.AddEvent( 1494 net_log.AddEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_SUCCESS,
1495 NetLogEventType::QUIC_CONNECTION_MIGRATION_SUCCESS, 1495 base::Bind(&NetLogQuicConnectionMigrationSuccessCallback,
1496 base::Bind(&NetLogQuicConnectionMigrationSuccessCallback, 1496 session->connection_id()));
1497 session->connection_id()));
1498 return MigrationResult::SUCCESS; 1497 return MigrationResult::SUCCESS;
1499 } 1498 }
1500 1499
1501 void QuicStreamFactory::OnSSLConfigChanged() { 1500 void QuicStreamFactory::OnSSLConfigChanged() {
1502 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); 1501 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED);
1503 } 1502 }
1504 1503
1505 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { 1504 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) {
1506 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); 1505 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED);
1507 } 1506 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 return OK; 1593 return OK;
1595 } 1594 }
1596 1595
1597 int QuicStreamFactory::CreateSession( 1596 int QuicStreamFactory::CreateSession(
1598 const QuicSessionKey& key, 1597 const QuicSessionKey& key,
1599 int cert_verify_flags, 1598 int cert_verify_flags,
1600 std::unique_ptr<QuicServerInfo> server_info, 1599 std::unique_ptr<QuicServerInfo> server_info,
1601 const AddressList& address_list, 1600 const AddressList& address_list,
1602 base::TimeTicks dns_resolution_start_time, 1601 base::TimeTicks dns_resolution_start_time,
1603 base::TimeTicks dns_resolution_end_time, 1602 base::TimeTicks dns_resolution_end_time,
1604 const BoundNetLog& net_log, 1603 const NetLogWithSource& net_log,
1605 QuicChromiumClientSession** session) { 1604 QuicChromiumClientSession** session) {
1606 if (need_to_evaluate_consecutive_disabled_count_) { 1605 if (need_to_evaluate_consecutive_disabled_count_) {
1607 task_runner_->PostDelayedTask( 1606 task_runner_->PostDelayedTask(
1608 FROM_HERE, 1607 FROM_HERE,
1609 base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount, 1608 base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount,
1610 weak_factory_.GetWeakPtr()), 1609 weak_factory_.GetWeakPtr()),
1611 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs)); 1610 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs));
1612 1611
1613 need_to_evaluate_consecutive_disabled_count_ = false; 1612 need_to_evaluate_consecutive_disabled_count_ = false;
1614 } 1613 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 bool QuicStreamFactory::CryptoConfigCacheIsEmpty( 1755 bool QuicStreamFactory::CryptoConfigCacheIsEmpty(
1757 const QuicServerId& server_id) { 1756 const QuicServerId& server_id) {
1758 QuicCryptoClientConfig::CachedState* cached = 1757 QuicCryptoClientConfig::CachedState* cached =
1759 crypto_config_.LookupOrCreate(server_id); 1758 crypto_config_.LookupOrCreate(server_id);
1760 return cached->IsEmpty(); 1759 return cached->IsEmpty();
1761 } 1760 }
1762 1761
1763 QuicAsyncStatus QuicStreamFactory::StartCertVerifyJob( 1762 QuicAsyncStatus QuicStreamFactory::StartCertVerifyJob(
1764 const QuicServerId& server_id, 1763 const QuicServerId& server_id,
1765 int cert_verify_flags, 1764 int cert_verify_flags,
1766 const BoundNetLog& net_log) { 1765 const NetLogWithSource& net_log) {
1767 if (!race_cert_verification_) 1766 if (!race_cert_verification_)
1768 return QUIC_FAILURE; 1767 return QUIC_FAILURE;
1769 QuicCryptoClientConfig::CachedState* cached = 1768 QuicCryptoClientConfig::CachedState* cached =
1770 crypto_config_.LookupOrCreate(server_id); 1769 crypto_config_.LookupOrCreate(server_id);
1771 if (!cached || cached->certs().empty() || 1770 if (!cached || cached->certs().empty() ||
1772 HasActiveCertVerifierJob(server_id)) { 1771 HasActiveCertVerifierJob(server_id)) {
1773 return QUIC_FAILURE; 1772 return QUIC_FAILURE;
1774 } 1773 }
1775 std::unique_ptr<CertVerifierJob> cert_verifier_job( 1774 std::unique_ptr<CertVerifierJob> cert_verifier_job(
1776 new CertVerifierJob(server_id, cert_verify_flags, net_log)); 1775 new CertVerifierJob(server_id, cert_verify_flags, net_log));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 void QuicStreamFactory::OpenFactory() { 1906 void QuicStreamFactory::OpenFactory() {
1908 status_ = OPEN; 1907 status_ = OPEN;
1909 } 1908 }
1910 1909
1911 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { 1910 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() {
1912 if (status_ == OPEN) 1911 if (status_ == OPEN)
1913 consecutive_disabled_count_ = 0; 1912 consecutive_disabled_count_ = 0;
1914 } 1913 }
1915 1914
1916 } // namespace net 1915 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698