| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #endif | 58 #endif |
| 59 | 59 |
| 60 #if defined(USE_OPENSSL) | 60 #if defined(USE_OPENSSL) |
| 61 #include <openssl/aead.h> | 61 #include <openssl/aead.h> |
| 62 #include "crypto/openssl_util.h" | 62 #include "crypto/openssl_util.h" |
| 63 #else | 63 #else |
| 64 #include "base/cpu.h" | 64 #include "base/cpu.h" |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 using std::min; | 67 using std::min; |
| 68 using std::vector; |
| 68 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; | 69 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; |
| 69 | 70 |
| 70 namespace net { | 71 namespace net { |
| 71 | 72 |
| 72 namespace { | 73 namespace { |
| 73 | 74 |
| 74 enum CreateSessionFailure { | 75 enum CreateSessionFailure { |
| 75 CREATION_ERROR_CONNECTING_SOCKET, | 76 CREATION_ERROR_CONNECTING_SOCKET, |
| 76 CREATION_ERROR_SETTING_RECEIVE_BUFFER, | 77 CREATION_ERROR_SETTING_RECEIVE_BUFFER, |
| 77 CREATION_ERROR_SETTING_SEND_BUFFER, | 78 CREATION_ERROR_SETTING_SEND_BUFFER, |
| (...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 if (alternative_service_info.alternative_service.protocol == QUIC) { | 1706 if (alternative_service_info.alternative_service.protocol == QUIC) { |
| 1706 quic_supported_servers_at_startup_.insert(key_value.first); | 1707 quic_supported_servers_at_startup_.insert(key_value.first); |
| 1707 break; | 1708 break; |
| 1708 } | 1709 } |
| 1709 } | 1710 } |
| 1710 } | 1711 } |
| 1711 | 1712 |
| 1712 if (http_server_properties_->max_server_configs_stored_in_properties() == 0) | 1713 if (http_server_properties_->max_server_configs_stored_in_properties() == 0) |
| 1713 return; | 1714 return; |
| 1714 // Create a temporary QuicServerInfo object to deserialize and to populate the | 1715 // Create a temporary QuicServerInfo object to deserialize and to populate the |
| 1715 // in-memory crypto server config cache. | 1716 // in-memory crypto server config cache in the MRU order. |
| 1716 scoped_ptr<QuicServerInfo> server_info; | 1717 scoped_ptr<QuicServerInfo> server_info; |
| 1717 CompletionCallback callback; | 1718 CompletionCallback callback; |
| 1718 for (const auto& key_value : | 1719 // Get the list of servers to be deserialized first because WaitForDataReady |
| 1719 http_server_properties_->quic_server_info_map()) { | 1720 // touches quic_server_info_map. |
| 1720 const QuicServerId& server_id = key_value.first; | 1721 const QuicServerInfoMap& quic_server_info_map = |
| 1722 http_server_properties_->quic_server_info_map(); |
| 1723 vector<QuicServerId> server_list(quic_server_info_map.size()); |
| 1724 for (const auto& key_value : quic_server_info_map) |
| 1725 server_list.push_back(key_value.first); |
| 1726 for (auto it = server_list.rbegin(); it != server_list.rend(); ++it) { |
| 1727 const QuicServerId& server_id = *it; |
| 1721 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); | 1728 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
| 1722 if (server_info->WaitForDataReady(callback) == OK) { | 1729 if (server_info->WaitForDataReady(callback) == OK) { |
| 1723 DVLOG(1) << "Initialized server config for: " << server_id.ToString(); | 1730 DVLOG(1) << "Initialized server config for: " << server_id.ToString(); |
| 1724 InitializeCachedStateInCryptoConfig(server_id, server_info, nullptr); | 1731 InitializeCachedStateInCryptoConfig(server_id, server_info, nullptr); |
| 1725 } | 1732 } |
| 1726 } | 1733 } |
| 1727 } | 1734 } |
| 1728 | 1735 |
| 1729 void QuicStreamFactory::ProcessGoingAwaySession( | 1736 void QuicStreamFactory::ProcessGoingAwaySession( |
| 1730 QuicChromiumClientSession* session, | 1737 QuicChromiumClientSession* session, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 // Since the session was active, there's no longer an | 1769 // Since the session was active, there's no longer an |
| 1763 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1770 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1764 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1771 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1765 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1772 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1766 // still race. | 1773 // still race. |
| 1767 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1774 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1768 alternative_service); | 1775 alternative_service); |
| 1769 } | 1776 } |
| 1770 | 1777 |
| 1771 } // namespace net | 1778 } // namespace net |
| OLD | NEW |