OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/crypto/quic_crypto_server_config.h" | 5 #include "net/quic/crypto/quic_crypto_server_config.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 << " orbit: " << base::HexEncode( | 458 << " orbit: " << base::HexEncode( |
459 reinterpret_cast<const char *>(config->orbit), kOrbitSize) | 459 reinterpret_cast<const char *>(config->orbit), kOrbitSize) |
460 << " primary_time " << config->primary_time.ToUNIXSeconds() | 460 << " primary_time " << config->primary_time.ToUNIXSeconds() |
461 << " priority " << config->priority; | 461 << " priority " << config->priority; |
462 new_configs.insert(make_pair(config->id, config)); | 462 new_configs.insert(make_pair(config->id, config)); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 configs_.swap(new_configs); | 466 configs_.swap(new_configs); |
467 SelectNewPrimaryConfig(now); | 467 SelectNewPrimaryConfig(now); |
468 DCHECK(primary_config_); | 468 DCHECK(primary_config_.get()); |
469 DCHECK_EQ(configs_.find(primary_config_->id)->second, primary_config_); | 469 DCHECK_EQ(configs_.find(primary_config_->id)->second, primary_config_); |
470 } | 470 } |
471 | 471 |
472 return ok; | 472 return ok; |
473 } | 473 } |
474 | 474 |
475 void QuicCryptoServerConfig::GetConfigIds(vector<string>* scids) const { | 475 void QuicCryptoServerConfig::GetConfigIds(vector<string>* scids) const { |
476 base::AutoLock locked(configs_lock_); | 476 base::AutoLock locked(configs_lock_); |
477 for (ConfigMap::const_iterator it = configs_.begin(); | 477 for (ConfigMap::const_iterator it = configs_.begin(); |
478 it != configs_.end(); ++it) { | 478 it != configs_.end(); ++it) { |
(...skipping 20 matching lines...) Expand all Loading... |
499 { | 499 { |
500 base::AutoLock locked(configs_lock_); | 500 base::AutoLock locked(configs_lock_); |
501 | 501 |
502 if (!primary_config_.get()) { | 502 if (!primary_config_.get()) { |
503 result->error_code = QUIC_CRYPTO_INTERNAL_ERROR; | 503 result->error_code = QUIC_CRYPTO_INTERNAL_ERROR; |
504 result->error_details = "No configurations loaded"; | 504 result->error_details = "No configurations loaded"; |
505 } else { | 505 } else { |
506 if (!next_config_promotion_time_.IsZero() && | 506 if (!next_config_promotion_time_.IsZero() && |
507 next_config_promotion_time_.IsAfter(now)) { | 507 next_config_promotion_time_.IsAfter(now)) { |
508 SelectNewPrimaryConfig(now); | 508 SelectNewPrimaryConfig(now); |
509 DCHECK(primary_config_); | 509 DCHECK(primary_config_.get()); |
510 DCHECK(configs_.find(primary_config_->id)->second == primary_config_); | 510 DCHECK_EQ(configs_.find(primary_config_->id)->second, primary_config_); |
511 } | 511 } |
512 | 512 |
513 memcpy(primary_orbit, primary_config_->orbit, sizeof(primary_orbit)); | 513 memcpy(primary_orbit, primary_config_->orbit, sizeof(primary_orbit)); |
514 } | 514 } |
515 | 515 |
516 requested_config = GetConfigWithScid(requested_scid); | 516 requested_config = GetConfigWithScid(requested_scid); |
517 } | 517 } |
518 | 518 |
519 if (result->error_code == QUIC_NO_ERROR) { | 519 if (result->error_code == QUIC_NO_ERROR) { |
520 EvaluateClientHello(primary_orbit, requested_config, result, done_cb); | 520 EvaluateClientHello(primary_orbit, requested_config, result, done_cb); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 base::AutoLock locked(configs_lock_); | 572 base::AutoLock locked(configs_lock_); |
573 | 573 |
574 if (!primary_config_.get()) { | 574 if (!primary_config_.get()) { |
575 *error_details = "No configurations loaded"; | 575 *error_details = "No configurations loaded"; |
576 return QUIC_CRYPTO_INTERNAL_ERROR; | 576 return QUIC_CRYPTO_INTERNAL_ERROR; |
577 } | 577 } |
578 | 578 |
579 if (!next_config_promotion_time_.IsZero() && | 579 if (!next_config_promotion_time_.IsZero() && |
580 next_config_promotion_time_.IsAfter(now)) { | 580 next_config_promotion_time_.IsAfter(now)) { |
581 SelectNewPrimaryConfig(now); | 581 SelectNewPrimaryConfig(now); |
582 DCHECK(primary_config_); | 582 DCHECK(primary_config_.get()); |
583 DCHECK(configs_.find(primary_config_->id)->second == primary_config_); | 583 DCHECK_EQ(configs_.find(primary_config_->id)->second, primary_config_); |
584 } | 584 } |
585 | 585 |
586 // We'll use the config that the client requested in order to do | 586 // We'll use the config that the client requested in order to do |
587 // key-agreement. Otherwise we'll give it a copy of |primary_config_| | 587 // key-agreement. Otherwise we'll give it a copy of |primary_config_| |
588 // to use. | 588 // to use. |
589 primary_config = primary_config_; | 589 primary_config = primary_config_; |
590 | 590 |
591 requested_config = GetConfigWithScid(requested_scid); | 591 requested_config = GetConfigWithScid(requested_scid); |
592 } | 592 } |
593 | 593 |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 QuicCryptoServerConfig::Config::Config() | 1505 QuicCryptoServerConfig::Config::Config() |
1506 : channel_id_enabled(false), | 1506 : channel_id_enabled(false), |
1507 is_primary(false), | 1507 is_primary(false), |
1508 primary_time(QuicWallTime::Zero()), | 1508 primary_time(QuicWallTime::Zero()), |
1509 priority(0), | 1509 priority(0), |
1510 source_address_token_boxer(NULL) {} | 1510 source_address_token_boxer(NULL) {} |
1511 | 1511 |
1512 QuicCryptoServerConfig::Config::~Config() { STLDeleteElements(&key_exchanges); } | 1512 QuicCryptoServerConfig::Config::~Config() { STLDeleteElements(&key_exchanges); } |
1513 | 1513 |
1514 } // namespace net | 1514 } // namespace net |
OLD | NEW |