blob: 0b1d634c1d272d619695cc11b13d65d1702aa04e [file] [log] [blame]
Yoshiki Tanioka49b4cfb2022-10-20 09:25:311// Copyright 2022 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_PRELOADING_PRERENDER_PRERENDER_FINAL_STATUS_H_
6#define CONTENT_BROWSER_PRELOADING_PRERENDER_PRERENDER_FINAL_STATUS_H_
7
Xinan Lin9aa790d2023-01-06 18:13:558#include "content/public/browser/preloading.h"
9
10#include "content/common/content_export.h"
11
12namespace content {
13
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3114// These values are persisted to logs. Entries should not be renumbered and
15// numeric values should never be reused.
Sreeja Kamishetty4a02b492022-11-11 19:53:5116//
keno194b9f22023-05-18 08:39:3217// If you change this, please follow the processes below:
18//
Sreeja Kamishetty4a02b492022-11-11 19:53:5119// go/preloading-dashboard-updates to update the mapping reflected in
20// dashboard, or if you are not a Googler, please file an FYI bug on
21// https://crbug.new with component Internals>Preload.
keno194b9f22023-05-18 08:39:3222//
23// https://docs.google.com/document/d/1PnrfowsZMt62PX1EvvTp2Nqs3ji1zrklrAEe1JYbkTk
24// to ensure failure reasons are correctly shown in the DevTools
25// frontend.
Hiroki Nakagawa61badcb2023-09-21 03:09:0626//
27// LINT.IfChange
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3128enum class PrerenderFinalStatus {
29 kActivated = 0,
30 kDestroyed = 1,
31 kLowEndDevice = 2,
Robert Lin10797982022-10-25 01:10:3332 // These have been broken down into SameSiteCrossOrigin and CrossSite for
33 // better understanding of the metrics. kCrossOriginRedirect = 3,
34 // kCrossOriginNavigation = 4,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3135 kInvalidSchemeRedirect = 5,
36 kInvalidSchemeNavigation = 6,
Hiroki Nakagawa04edeae2023-09-29 10:54:0737 // kInProgressNavigation = 7, // No longer used.
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3138 // kNavigationRequestFailure = 8, // No longer used.
39 kNavigationRequestBlockedByCsp = 9,
Nan Lin18aa86ce432025-05-15 22:55:3540 // kMainFrameNavigation = 10, // No longer used.
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3141 kMojoBinderPolicy = 11,
42 // kPlugin = 12, // No longer used.
43 kRendererProcessCrashed = 13,
44 kRendererProcessKilled = 14,
45 kDownload = 15,
46 kTriggerDestroyed = 16,
47 kNavigationNotCommitted = 17,
48 kNavigationBadHttpStatus = 18,
49 kClientCertRequested = 19,
50 kNavigationRequestNetworkError = 20,
Taiyo Mizuhashi459a6b22023-09-13 07:56:4851 // This is split into
52 // kMaxNumOfRunning(Eager|NonEager|Embedder)PrerendersExceeded
53 // kMaxNumOfRunningPrerendersExceeded = 21,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3154 kCancelAllHostsForTesting = 22,
55 kDidFailLoad = 23,
56 kStop = 24,
57 kSslCertificateError = 25,
58 kLoginAuthRequested = 26,
59 kUaChangeRequiresReload = 27,
60 kBlockedByClient = 28,
Takashi Toyoshimae93e4012023-06-10 20:54:5561 // Deprecate in favor of newly defined behavior to support Web Audio while
62 // prerendering. See https://github.com/WICG/nav-speculation/issues/165.
63 // kAudioOutputDeviceRequested = 29,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3164 kMixedContent = 30,
65 kTriggerBackgrounded = 31,
66 // Break down into kEmbedderTriggeredAndSameOriginRedirected and
67 // kEmbedderTriggeredAndCrossOriginRedirected for investigation.
68 // kEmbedderTriggeredAndRedirected = 32,
69 // Deprecate since same origin redirection is allowed considering that the
70 // initial prerender origin is a safe site.
71 // kEmbedderTriggeredAndSameOriginRedirected = 33,
Taiyo Mizuhashid0bac992023-07-20 18:38:3072 // Deprecated. Use kCrossSiteRedirectInInitialNavigation instead.
73 // kEmbedderTriggeredAndCrossOriginRedirected = 34,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3174 // Deprecated. This has the same meaning as kTriggerDestroyed because the
75 // metric's name includes trigger type.
76 // kEmbedderTriggeredAndDestroyed = 35,
77 kMemoryLimitExceeded = 36,
Hiroki Nakagawa35fda742023-09-07 03:51:4778
79 // Deprecated. Failure on query of current memory consumption is ignored.
80 // kFailToGetMemoryUsage = 37,
81
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3182 kDataSaverEnabled = 38,
Hiroki Nakagawad77864c2023-09-20 22:34:0383 kTriggerUrlHasEffectiveUrl = 39,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3184 kActivatedBeforeStarted = 40,
85 kInactivePageRestriction = 41,
86 kStartFailed = 42,
87 kTimeoutBackgrounded = 43,
Hiroki Nakagawad04aaaf92023-03-20 17:13:2888
89 // Enums for prerender initial navigation. For main frame navigation in
90 // prerendered pages after prerender initial navigation, use enums suffixed
91 // with InMainFrameNavigation (e.g., kCrossSiteRedirectInMainFrameNavigation).
92 kCrossSiteRedirectInInitialNavigation = 44,
93 kCrossSiteNavigationInInitialNavigation = 45,
Asami Doi1cba5242023-03-09 03:09:2394 // Deprecated. Same-site cross-origin navigation in a prerendered page is
95 // allowed in crbug.com/1239281.
Hiroki Nakagawad04aaaf92023-03-20 17:13:2896 // kSameSiteCrossOriginRedirectInInitialNavigation = 46,
97 // kSameSiteCrossOriginNavigationInInitialNavigation = 47,
98 kSameSiteCrossOriginRedirectNotOptInInInitialNavigation = 48,
99 kSameSiteCrossOriginNavigationNotOptInInInitialNavigation = 49,
100
Lingqi Chiaeec5df12022-10-26 03:41:42101 // The prediction is correct, and we are almost ready to activate this
102 // PrerenderHost, but the activation navigation's parameters are different
103 // from the initial prerendering navigation so Prerender fails to activate it.
104 kActivationNavigationParameterMismatch = 50,
Asami Doi7e33f2f2022-12-12 16:15:09105 kActivatedInBackground = 51,
Nathan Memmott093d20ac2024-12-13 17:12:59106 // kEmbedderHostDisallowed = 52, // No longer used.
lingqi8a718232022-12-21 03:58:51107 // Called when encounter failures during synchronous activation.
Alison Gale47d1537d2024-04-19 21:31:46108 // TODO(crbug.com/40238737): Remove this reason if no sample is
lingqi8a718232022-12-21 03:58:51109 // recorded in stable, or look into the reason if there are.
110 kActivationNavigationDestroyedBeforeSuccess = 53,
lingqi42ab9f452022-12-30 16:56:49111 // See comments on WebContents::kTabClosedWithoutUserGesture for the
112 // difference between the two statuses below.
113 kTabClosedByUserGesture = 54,
114 kTabClosedWithoutUserGesture = 55,
Asami Doidac3f112023-01-18 06:31:02115 kPrimaryMainFrameRendererProcessCrashed = 56,
116 kPrimaryMainFrameRendererProcessKilled = 57,
lingqi6d03e422023-01-19 02:37:06117 kActivationFramePolicyNotCompatible = 58,
Johannd0d31ee2023-01-27 03:14:54118 kPreloadingDisabled = 59,
119 kBatterySaverEnabled = 60,
Asami Doi39651732023-01-31 05:25:26120 kActivatedDuringMainFrameNavigation = 61,
Johannd811e1f2023-02-03 23:09:34121 kPreloadingUnsupportedByWebContents = 62,
Hiroki Nakagawad04aaaf92023-03-20 17:13:28122
123 // Enums for main frame navigation in prerendered pages.
124 kCrossSiteRedirectInMainFrameNavigation = 63,
125 kCrossSiteNavigationInMainFrameNavigation = 64,
126 kSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation = 65,
127 kSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation = 66,
128
Hiroki Nakagawa34e5d672023-04-21 05:00:09129 kMemoryPressureOnTrigger = 67,
130 kMemoryPressureAfterTriggered = 68,
131
keno8480d579f2023-05-25 11:34:17132 kPrerenderingDisabledByDevTools = 69,
133
Lingqi Chi350f4f12023-06-09 02:03:04134 // Different from kBlockedByClient, which tracks the failure caused by main
135 // frame navigation, this status indicates that clients block some resource
136 // loading.
Taiyo Mizuhashi3566d1e32023-10-10 18:35:22137 // Eliminated per crrev.com/c/4891929.
138 // kResourceLoadBlockedByClient = 70,
Lingqi Chi350f4f12023-06-09 02:03:04139
Hiroki Nakagawa5f7d2db2023-07-12 22:54:06140 // A trigger page removed a corresponding prerender rule from
141 // <script type="speculationrules">.
142 kSpeculationRuleRemoved = 71,
143
Hiroki Nakagawa2f427342023-07-19 23:27:04144 // A trigger page cannot activate a prerendered page when it has auxiliary
145 // browsing contexts that should be able to script each other (e.g., pop-up
146 // windows with openers). For details, see comments on the place where this
147 // status is specified.
148 kActivatedWithAuxiliaryBrowsingContexts = 72,
149
Takashi Nakayama978f0a152025-06-17 08:26:25150 kMaxNumOfRunningImmediatePrerendersExceeded = 73,
151 kMaxNumOfRunningNonImmediatePrerendersExceeded = 74,
Taiyo Mizuhashi459a6b22023-09-13 07:56:48152 kMaxNumOfRunningEmbedderPrerendersExceeded = 75,
153
Hiroki Nakagawad77864c2023-09-20 22:34:03154 kPrerenderingUrlHasEffectiveUrl = 76,
155 kRedirectedPrerenderingUrlHasEffectiveUrl = 77,
156 kActivationUrlHasEffectiveUrl = 78,
157
Hiroki Nakagawac1e58012024-05-07 23:43:41158 kJavaScriptInterfaceAdded = 79,
159 kJavaScriptInterfaceRemoved = 80,
160
Hiroki Nakagawa2db55b32024-05-09 08:41:27161 kAllPrerenderingCanceled = 81,
162
HuanPo Lin95c9bc82024-07-09 04:41:33163 // Cancelled by window.close() from renderer side.
164 kWindowClosed = 82,
165
Minoru Chikamune0e5cc5832024-07-30 04:05:10166 kSlowNetwork = 83,
Hiroki Nakagawa9669f722024-07-30 05:21:51167 kOtherPrerenderedPageActivated = 84,
Minoru Chikamune0e5cc5832024-07-30 04:05:10168
Hiroki Nakagawa29615992024-10-02 06:48:11169 // When the V8 optimizer is disabled by the site settings, prerendering a page
170 // that has the COOP crashes (see https://crbug.com/40076091 for details). To
171 // avoid it, prerendering is disabled in that case.
Daniel Chengec4c18972025-02-07 18:10:19172 // kV8OptimizerDisabled = 85,
Hiroki Nakagawa29615992024-10-02 06:48:11173
kenossab4aeb62024-10-11 11:37:40174 // Prefetch ahead of prerender failed. Precise reason is recorded as UMA
175 // `Prerender.Experimental.PrefetchAheadOfPrerenderFailed.PrefetchStatus{PreloadingTriggerType}`
176 kPrerenderFailedDuringPrefetch = 86,
177
Steven Wei893cb02c2025-02-12 20:51:30178 // Prerendering canceled by clearing cache from browsing data removal.
179 kBrowsingDataRemoved = 87,
Jiacheng Guocfca196d2025-07-30 02:13:20180 // Prerendering cancelled but the PrerenderHost is reused for future
181 // navigation.
182 kPrerenderHostReused = 88,
Steven Wei893cb02c2025-02-12 20:51:30183
Jiacheng Guocfca196d2025-07-30 02:13:20184 kMaxValue = kPrerenderHostReused,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:31185};
Nan Lin18aa86ce432025-05-15 22:55:35186// LINT.ThenChange(//third_party/blink/public/devtools_protocol/browser_protocol.pdl)
Yoshiki Tanioka49b4cfb2022-10-20 09:25:31187
Xinan Lin9aa790d2023-01-06 18:13:55188// Helper method to convert PrerenderFinalStatus to PreloadingFailureReason.
189PreloadingFailureReason CONTENT_EXPORT
190 ToPreloadingFailureReason(PrerenderFinalStatus);
191
192} // namespace content
193
Yoshiki Tanioka49b4cfb2022-10-20 09:25:31194#endif // CONTENT_BROWSER_PRELOADING_PRERENDER_PRERENDER_FINAL_STATUS_H_