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

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

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/quic_session.cc ('k') | net/quic/test_tools/crypto_test_utils_chromium.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/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() { 311 void QuicStreamFactory::Job::CancelWaitForDataReadyCallback() {
312 // If we are waiting for WaitForDataReadyCallback, then cancel the callback. 312 // If we are waiting for WaitForDataReadyCallback, then cancel the callback.
313 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE) 313 if (io_state_ != STATE_LOAD_SERVER_INFO_COMPLETE)
314 return; 314 return;
315 server_info_->CancelWaitForDataReadyCallback(); 315 server_info_->CancelWaitForDataReadyCallback();
316 OnIOComplete(OK); 316 OnIOComplete(OK);
317 } 317 }
318 318
319 int QuicStreamFactory::Job::DoResolveHost() { 319 int QuicStreamFactory::Job::DoResolveHost() {
320 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
321 tracked_objects::ScopedTracker tracking_profile(
322 FROM_HERE_WITH_EXPLICIT_FUNCTION(
323 "422516 QuicStreamFactory::Job::DoResolveHost"));
324
320 // Start loading the data now, and wait for it after we resolve the host. 325 // Start loading the data now, and wait for it after we resolve the host.
321 if (server_info_) { 326 if (server_info_) {
322 server_info_->Start(); 327 server_info_->Start();
323 } 328 }
324 329
325 io_state_ = STATE_RESOLVE_HOST_COMPLETE; 330 io_state_ = STATE_RESOLVE_HOST_COMPLETE;
326 dns_resolution_start_time_ = base::TimeTicks::Now(); 331 dns_resolution_start_time_ = base::TimeTicks::Now();
327 return host_resolver_.Resolve( 332 return host_resolver_.Resolve(
328 HostResolver::RequestInfo(server_id_.host_port_pair()), 333 HostResolver::RequestInfo(server_id_.host_port_pair()),
329 DEFAULT_PRIORITY, 334 DEFAULT_PRIORITY,
330 &address_list_, 335 &address_list_,
331 base::Bind(&QuicStreamFactory::Job::OnIOComplete, 336 base::Bind(&QuicStreamFactory::Job::OnIOComplete,
332 weak_factory_.GetWeakPtr()), 337 weak_factory_.GetWeakPtr()),
333 net_log_); 338 net_log_);
334 } 339 }
335 340
336 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) { 341 int QuicStreamFactory::Job::DoResolveHostComplete(int rv) {
342 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
343 tracked_objects::ScopedTracker tracking_profile(
344 FROM_HERE_WITH_EXPLICIT_FUNCTION(
345 "422516 QuicStreamFactory::Job::DoResolveHostComplete"));
346
337 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime", 347 UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolutionTime",
338 base::TimeTicks::Now() - dns_resolution_start_time_); 348 base::TimeTicks::Now() - dns_resolution_start_time_);
339 if (rv != OK) 349 if (rv != OK)
340 return rv; 350 return rv;
341 351
342 DCHECK(!factory_->HasActiveSession(server_id_)); 352 DCHECK(!factory_->HasActiveSession(server_id_));
343 353
344 // Inform the factory of this resolution, which will set up 354 // Inform the factory of this resolution, which will set up
345 // a session alias, if possible. 355 // a session alias, if possible.
346 if (factory_->OnResolution(server_id_, address_list_)) { 356 if (factory_->OnResolution(server_id_, address_list_)) {
347 return OK; 357 return OK;
348 } 358 }
349 359
350 io_state_ = STATE_LOAD_SERVER_INFO; 360 io_state_ = STATE_LOAD_SERVER_INFO;
351 return OK; 361 return OK;
352 } 362 }
353 363
354 int QuicStreamFactory::Job::DoLoadServerInfo() { 364 int QuicStreamFactory::Job::DoLoadServerInfo() {
365 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
366 tracked_objects::ScopedTracker tracking_profile(
367 FROM_HERE_WITH_EXPLICIT_FUNCTION(
368 "422516 QuicStreamFactory::Job::DoLoadServerInfo"));
369
355 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE; 370 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE;
356 371
357 if (!server_info_) 372 if (!server_info_)
358 return OK; 373 return OK;
359 374
360 // To mitigate the effects of disk cache taking too long to load QUIC server 375 // To mitigate the effects of disk cache taking too long to load QUIC server
361 // information, set up a timer to cancel WaitForDataReady's callback. 376 // information, set up a timer to cancel WaitForDataReady's callback.
362 if (factory_->load_server_info_timeout_ms_ > 0) { 377 if (factory_->load_server_info_timeout_ms_ > 0) {
363 factory_->task_runner_->PostDelayedTask( 378 factory_->task_runner_->PostDelayedTask(
364 FROM_HERE, 379 FROM_HERE,
365 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, 380 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback,
366 weak_factory_.GetWeakPtr()), 381 weak_factory_.GetWeakPtr()),
367 base::TimeDelta::FromMilliseconds( 382 base::TimeDelta::FromMilliseconds(
368 factory_->load_server_info_timeout_ms_)); 383 factory_->load_server_info_timeout_ms_));
369 } 384 }
370 385
371 disk_cache_load_start_time_ = base::TimeTicks::Now(); 386 disk_cache_load_start_time_ = base::TimeTicks::Now();
372 return server_info_->WaitForDataReady( 387 return server_info_->WaitForDataReady(
373 base::Bind(&QuicStreamFactory::Job::OnIOComplete, 388 base::Bind(&QuicStreamFactory::Job::OnIOComplete,
374 weak_factory_.GetWeakPtr())); 389 weak_factory_.GetWeakPtr()));
375 } 390 }
376 391
377 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) { 392 int QuicStreamFactory::Job::DoLoadServerInfoComplete(int rv) {
393 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
394 tracked_objects::ScopedTracker tracking_profile(
395 FROM_HERE_WITH_EXPLICIT_FUNCTION(
396 "422516 QuicStreamFactory::Job::DoLoadServerInfoComplete"));
397
378 if (server_info_) { 398 if (server_info_) {
379 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime", 399 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheWaitForDataReadyTime",
380 base::TimeTicks::Now() - disk_cache_load_start_time_); 400 base::TimeTicks::Now() - disk_cache_load_start_time_);
381 } 401 }
382 402
383 if (rv != OK) { 403 if (rv != OK) {
384 server_info_.reset(); 404 server_info_.reset();
385 } 405 }
386 406
387 io_state_ = STATE_CONNECT; 407 io_state_ = STATE_CONNECT;
388 return OK; 408 return OK;
389 } 409 }
390 410
391 int QuicStreamFactory::Job::DoConnect() { 411 int QuicStreamFactory::Job::DoConnect() {
412 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
413 tracked_objects::ScopedTracker tracking_profile(
414 FROM_HERE_WITH_EXPLICIT_FUNCTION(
415 "422516 QuicStreamFactory::Job::DoConnect"));
416
392 io_state_ = STATE_CONNECT_COMPLETE; 417 io_state_ = STATE_CONNECT_COMPLETE;
393 418
394 int rv = factory_->CreateSession(server_id_, server_info_.Pass(), 419 int rv = factory_->CreateSession(server_id_, server_info_.Pass(),
395 address_list_, net_log_, &session_); 420 address_list_, net_log_, &session_);
396 if (rv != OK) { 421 if (rv != OK) {
397 DCHECK(rv != ERR_IO_PENDING); 422 DCHECK(rv != ERR_IO_PENDING);
398 DCHECK(!session_); 423 DCHECK(!session_);
399 return rv; 424 return rv;
400 } 425 }
401 426
402 if (!session_->connection()->connected()) { 427 if (!session_->connection()->connected()) {
403 return ERR_CONNECTION_CLOSED; 428 return ERR_CONNECTION_CLOSED;
404 } 429 }
405 430
406 session_->StartReading(); 431 session_->StartReading();
407 if (!session_->connection()->connected()) { 432 if (!session_->connection()->connected()) {
408 return ERR_QUIC_PROTOCOL_ERROR; 433 return ERR_QUIC_PROTOCOL_ERROR;
409 } 434 }
410 bool require_confirmation = 435 bool require_confirmation =
411 factory_->require_confirmation() || is_post_ || 436 factory_->require_confirmation() || is_post_ ||
412 was_alternate_protocol_recently_broken_; 437 was_alternate_protocol_recently_broken_;
413 rv = session_->CryptoConnect( 438 rv = session_->CryptoConnect(
414 require_confirmation, 439 require_confirmation,
415 base::Bind(&QuicStreamFactory::Job::OnIOComplete, 440 base::Bind(&QuicStreamFactory::Job::OnIOComplete,
416 base::Unretained(this))); 441 base::Unretained(this)));
417 return rv; 442 return rv;
418 } 443 }
419 444
420 int QuicStreamFactory::Job::DoResumeConnect() { 445 int QuicStreamFactory::Job::DoResumeConnect() {
446 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
447 tracked_objects::ScopedTracker tracking_profile(
448 FROM_HERE_WITH_EXPLICIT_FUNCTION(
449 "422516 QuicStreamFactory::Job::DoResumeConnect"));
450
421 io_state_ = STATE_CONNECT_COMPLETE; 451 io_state_ = STATE_CONNECT_COMPLETE;
422 452
423 int rv = session_->ResumeCryptoConnect( 453 int rv = session_->ResumeCryptoConnect(
424 base::Bind(&QuicStreamFactory::Job::OnIOComplete, 454 base::Bind(&QuicStreamFactory::Job::OnIOComplete,
425 base::Unretained(this))); 455 base::Unretained(this)));
426 456
427 return rv; 457 return rv;
428 } 458 }
429 459
430 int QuicStreamFactory::Job::DoConnectComplete(int rv) { 460 int QuicStreamFactory::Job::DoConnectComplete(int rv) {
461 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
462 tracked_objects::ScopedTracker tracking_profile(
463 FROM_HERE_WITH_EXPLICIT_FUNCTION(
464 "422516 QuicStreamFactory::Job::DoConnectComplete"));
465
431 if (rv != OK) 466 if (rv != OK)
432 return rv; 467 return rv;
433 468
434 DCHECK(!factory_->HasActiveSession(server_id_)); 469 DCHECK(!factory_->HasActiveSession(server_id_));
435 // There may well now be an active session for this IP. If so, use the 470 // There may well now be an active session for this IP. If so, use the
436 // existing session instead. 471 // existing session instead.
437 AddressList address(session_->connection()->peer_address()); 472 AddressList address(session_->connection()->peer_address());
438 if (factory_->OnResolution(server_id_, address)) { 473 if (factory_->OnResolution(server_id_, address)) {
439 session_->connection()->SendConnectionClose(QUIC_CONNECTION_IP_POOLED); 474 session_->connection()->SendConnectionClose(QUIC_CONNECTION_IP_POOLED);
440 session_ = nullptr; 475 session_ = nullptr;
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 http_server_properties_->ClearAlternateProtocol(server); 1135 http_server_properties_->ClearAlternateProtocol(server);
1101 http_server_properties_->SetAlternateProtocol( 1136 http_server_properties_->SetAlternateProtocol(
1102 server, alternate.port, alternate.protocol, 1); 1137 server, alternate.port, alternate.protocol, 1);
1103 DCHECK_EQ(QUIC, 1138 DCHECK_EQ(QUIC,
1104 http_server_properties_->GetAlternateProtocol(server).protocol); 1139 http_server_properties_->GetAlternateProtocol(server).protocol);
1105 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( 1140 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken(
1106 server)); 1141 server));
1107 } 1142 }
1108 1143
1109 } // namespace net 1144 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/test_tools/crypto_test_utils_chromium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698