| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 #ifndef NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ | 5 #ifndef NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ |
| 6 #define NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ | 6 #define NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/time/default_tick_clock.h" |
| 12 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 13 #include "net/http/http_server_properties.h" | 14 #include "net/http/http_server_properties.h" |
| 14 | 15 |
| 15 namespace base { | |
| 16 class TickClock; | |
| 17 } | |
| 18 | |
| 19 namespace net { | 16 namespace net { |
| 20 | 17 |
| 21 // This class tracks HTTP alternative services that have been marked as broken. | 18 // This class tracks HTTP alternative services that have been marked as broken. |
| 22 // The brokenness of an alt-svc will expire after some time according to an | 19 // The brokenness of an alt-svc will expire after some time according to an |
| 23 // exponential back-off formula: each time an alt-svc is marked broken, the | 20 // exponential back-off formula: each time an alt-svc is marked broken, the |
| 24 // expiration delay will be some constant multiple of its previous expiration | 21 // expiration delay will be some constant multiple of its previous expiration |
| 25 // delay. This prevents broken alt-svcs from being retried too often by the | 22 // delay. This prevents broken alt-svcs from being retried too often by the |
| 26 // network stack. | 23 // network stack. |
| 27 class NET_EXPORT_PRIVATE BrokenAlternativeServices { | 24 class NET_EXPORT_PRIVATE BrokenAlternativeServices { |
| 28 public: | 25 public: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const AlternativeService& alternative_service); | 74 const AlternativeService& alternative_service); |
| 78 | 75 |
| 79 // Marks |alternative_service| as not broken and not recently broken. | 76 // Marks |alternative_service| as not broken and not recently broken. |
| 80 void ConfirmAlternativeService(const AlternativeService& alternative_service); | 77 void ConfirmAlternativeService(const AlternativeService& alternative_service); |
| 81 | 78 |
| 82 // Sets broken and recently broken alternative services. | 79 // Sets broken and recently broken alternative services. |
| 83 // |broken_alternative_service_list| must be sorted from earliest to latest | 80 // |broken_alternative_service_list| must be sorted from earliest to latest |
| 84 // expiration time. | 81 // expiration time. |
| 85 // All AlternativeServices in |broken_alternative_service_list| must exist in | 82 // All AlternativeServices in |broken_alternative_service_list| must exist in |
| 86 // |recently_broken_alternative_services|. | 83 // |recently_broken_alternative_services|. |
| 84 // |
| 85 // If a broken/recently-broken alt svc that's being added is already stored, |
| 86 // the stored expiration/broken-count for that alt svc will be overwritten |
| 87 // with the new value. |
| 88 // However, |recently_broken_alternative_services_| will still have the |
| 89 // already-stored alt svcs at the front of the recency list, followed by the |
| 90 // newly added ones. |
| 87 void SetBrokenAndRecentlyBrokenAlternativeServices( | 91 void SetBrokenAndRecentlyBrokenAlternativeServices( |
| 88 std::unique_ptr<BrokenAlternativeServiceList> | 92 std::unique_ptr<BrokenAlternativeServiceList> |
| 89 broken_alternative_service_list, | 93 broken_alternative_service_list, |
| 90 std::unique_ptr<RecentlyBrokenAlternativeServices> | 94 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 91 recently_broken_alternative_services); | 95 recently_broken_alternative_services); |
| 92 | 96 |
| 93 const BrokenAlternativeServiceList& broken_alternative_service_list() const; | 97 const BrokenAlternativeServiceList& broken_alternative_service_list() const; |
| 94 | 98 |
| 95 const RecentlyBrokenAlternativeServices& | 99 const RecentlyBrokenAlternativeServices& |
| 96 recently_broken_alternative_services() const; | 100 recently_broken_alternative_services() const; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Used for scheduling the task that expires the brokenness of alternative | 143 // Used for scheduling the task that expires the brokenness of alternative |
| 140 // services. | 144 // services. |
| 141 base::OneShotTimer expiration_timer_; | 145 base::OneShotTimer expiration_timer_; |
| 142 | 146 |
| 143 base::WeakPtrFactory<BrokenAlternativeServices> weak_ptr_factory_; | 147 base::WeakPtrFactory<BrokenAlternativeServices> weak_ptr_factory_; |
| 144 }; | 148 }; |
| 145 | 149 |
| 146 } // namespace net | 150 } // namespace net |
| 147 | 151 |
| 148 #endif // NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ | 152 #endif // NET_HTTP_BROKEN_ALTERNATIVE_SERVICES_H_ |
| OLD | NEW |