1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
content / browser / preloading / prefetch / prefetch_type.cc [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/preloading/prefetch/prefetch_type.h"
#include <tuple>
#include "base/check.h"
#include "content/browser/preloading/prefetch/prefetch_params.h"
#include "content/browser/preloading/preloading_trigger_type_impl.h"
#include "content/public/browser/preloading_trigger_type.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h"
namespace content {
PrefetchType::PrefetchType(PreloadingTriggerType non_speculation_trigger_type,
bool use_prefetch_proxy)
: trigger_type_(non_speculation_trigger_type),
use_prefetch_proxy_(use_prefetch_proxy) {
CHECK(PrefetchBrowserInitiatedTriggersEnabled());
CHECK(!IsSpeculationRuleType(non_speculation_trigger_type));
}
PrefetchType::PrefetchType(PreloadingTriggerType trigger_type,
bool use_prefetch_proxy,
blink::mojom::SpeculationEagerness eagerness)
: trigger_type_(trigger_type),
use_prefetch_proxy_(use_prefetch_proxy),
eagerness_(eagerness) {
CHECK(IsSpeculationRuleType(trigger_type));
}
void PrefetchType::SetProxyBypassedForTest() {
DCHECK(use_prefetch_proxy_);
proxy_bypassed_for_testing_ = true;
}
blink::mojom::SpeculationEagerness PrefetchType::GetEagerness() const {
CHECK(IsSpeculationRuleType(trigger_type_));
return eagerness_.value();
}
bool PrefetchType::IsRendererInitiated() const {
return IsSpeculationRuleType(trigger_type_);
}
} // namespace content