| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ | 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ |
| 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ | 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ |
| 7 | 7 |
| 8 #include "components/previews/core/previews_experiments.h" | 8 #include "components/previews/core/previews_experiments.h" |
| 9 | 9 |
| 10 #include "net/nqe/effective_connection_type.h" |
| 11 |
| 10 namespace net { | 12 namespace net { |
| 11 class URLRequest; | 13 class URLRequest; |
| 12 } | 14 } |
| 13 | 15 |
| 14 namespace previews { | 16 namespace previews { |
| 15 | 17 |
| 16 class PreviewsDecider { | 18 class PreviewsDecider { |
| 17 public: | 19 public: |
| 18 // Whether |request| is allowed to show a preview of |type|. | 20 // Whether |request| is allowed to show a preview of |type|. If the current |
| 21 // ECT is strictly faster than |effective_connection_type_threshold|, the |
| 22 // preview will be disallowed; preview types that check network quality before |
| 23 // calling ShouldAllowPreviewAtECT should pass in |
| 24 // EFFECTIVE_CONNECTION_TYPE_4G. |
| 25 virtual bool ShouldAllowPreviewAtECT( |
| 26 const net::URLRequest& request, |
| 27 PreviewsType type, |
| 28 net::EffectiveConnectionType effective_connection_type_threshold) |
| 29 const = 0; |
| 30 |
| 31 // Same as ShouldAllowPreviewAtECT, but uses the previews default |
| 32 // EffectiveConnectionType. |
| 19 virtual bool ShouldAllowPreview(const net::URLRequest& request, | 33 virtual bool ShouldAllowPreview(const net::URLRequest& request, |
| 20 PreviewsType type) const = 0; | 34 PreviewsType type) const = 0; |
| 21 | 35 |
| 22 protected: | 36 protected: |
| 23 PreviewsDecider() {} | 37 PreviewsDecider() {} |
| 24 virtual ~PreviewsDecider() {} | 38 virtual ~PreviewsDecider() {} |
| 25 }; | 39 }; |
| 26 | 40 |
| 27 } // namespace previews | 41 } // namespace previews |
| 28 | 42 |
| 29 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ | 43 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_DECIDER_H_ |
| OLD | NEW |