Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 1 | // 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 Lin | 9aa790d | 2023-01-06 18:13:55 | [diff] [blame] | 8 | #include "content/public/browser/preloading.h" |
| 9 | |
| 10 | #include "content/common/content_export.h" |
| 11 | |
| 12 | namespace content { |
| 13 | |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 14 | // These values are persisted to logs. Entries should not be renumbered and |
| 15 | // numeric values should never be reused. |
Sreeja Kamishetty | 4a02b49 | 2022-11-11 19:53:51 | [diff] [blame] | 16 | // |
keno | 194b9f2 | 2023-05-18 08:39:32 | [diff] [blame] | 17 | // If you change this, please follow the processes below: |
| 18 | // |
Sreeja Kamishetty | 4a02b49 | 2022-11-11 19:53:51 | [diff] [blame] | 19 | // 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. |
keno | 194b9f2 | 2023-05-18 08:39:32 | [diff] [blame] | 22 | // |
| 23 | // https://docs.google.com/document/d/1PnrfowsZMt62PX1EvvTp2Nqs3ji1zrklrAEe1JYbkTk |
| 24 | // to ensure failure reasons are correctly shown in the DevTools |
| 25 | // frontend. |
Hiroki Nakagawa | 61badcb | 2023-09-21 03:09:06 | [diff] [blame] | 26 | // |
| 27 | // LINT.IfChange |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 28 | enum class PrerenderFinalStatus { |
| 29 | kActivated = 0, |
| 30 | kDestroyed = 1, |
| 31 | kLowEndDevice = 2, |
Robert Lin | 1079798 | 2022-10-25 01:10:33 | [diff] [blame] | 32 | // These have been broken down into SameSiteCrossOrigin and CrossSite for |
| 33 | // better understanding of the metrics. kCrossOriginRedirect = 3, |
| 34 | // kCrossOriginNavigation = 4, |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 35 | kInvalidSchemeRedirect = 5, |
| 36 | kInvalidSchemeNavigation = 6, |
Hiroki Nakagawa | 04edeae | 2023-09-29 10:54:07 | [diff] [blame] | 37 | // kInProgressNavigation = 7, // No longer used. |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 38 | // kNavigationRequestFailure = 8, // No longer used. |
| 39 | kNavigationRequestBlockedByCsp = 9, |
Nan Lin | 18aa86ce43 | 2025-05-15 22:55:35 | [diff] [blame] | 40 | // kMainFrameNavigation = 10, // No longer used. |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 41 | 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 Mizuhashi | 459a6b2 | 2023-09-13 07:56:48 | [diff] [blame] | 51 | // This is split into |
| 52 | // kMaxNumOfRunning(Eager|NonEager|Embedder)PrerendersExceeded |
| 53 | // kMaxNumOfRunningPrerendersExceeded = 21, |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 54 | kCancelAllHostsForTesting = 22, |
| 55 | kDidFailLoad = 23, |
| 56 | kStop = 24, |
| 57 | kSslCertificateError = 25, |
| 58 | kLoginAuthRequested = 26, |
| 59 | kUaChangeRequiresReload = 27, |
| 60 | kBlockedByClient = 28, |
Takashi Toyoshima | e93e401 | 2023-06-10 20:54:55 | [diff] [blame] | 61 | // 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 Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 64 | 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 Mizuhashi | d0bac99 | 2023-07-20 18:38:30 | [diff] [blame] | 72 | // Deprecated. Use kCrossSiteRedirectInInitialNavigation instead. |
| 73 | // kEmbedderTriggeredAndCrossOriginRedirected = 34, |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 74 | // Deprecated. This has the same meaning as kTriggerDestroyed because the |
| 75 | // metric's name includes trigger type. |
| 76 | // kEmbedderTriggeredAndDestroyed = 35, |
| 77 | kMemoryLimitExceeded = 36, |
Hiroki Nakagawa | 35fda74 | 2023-09-07 03:51:47 | [diff] [blame] | 78 | |
| 79 | // Deprecated. Failure on query of current memory consumption is ignored. |
| 80 | // kFailToGetMemoryUsage = 37, |
| 81 | |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 82 | kDataSaverEnabled = 38, |
Hiroki Nakagawa | d77864c | 2023-09-20 22:34:03 | [diff] [blame] | 83 | kTriggerUrlHasEffectiveUrl = 39, |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 84 | kActivatedBeforeStarted = 40, |
| 85 | kInactivePageRestriction = 41, |
| 86 | kStartFailed = 42, |
| 87 | kTimeoutBackgrounded = 43, |
Hiroki Nakagawa | d04aaaf9 | 2023-03-20 17:13:28 | [diff] [blame] | 88 | |
| 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 Doi | 1cba524 | 2023-03-09 03:09:23 | [diff] [blame] | 94 | // Deprecated. Same-site cross-origin navigation in a prerendered page is |
| 95 | // allowed in crbug.com/1239281. |
Hiroki Nakagawa | d04aaaf9 | 2023-03-20 17:13:28 | [diff] [blame] | 96 | // kSameSiteCrossOriginRedirectInInitialNavigation = 46, |
| 97 | // kSameSiteCrossOriginNavigationInInitialNavigation = 47, |
| 98 | kSameSiteCrossOriginRedirectNotOptInInInitialNavigation = 48, |
| 99 | kSameSiteCrossOriginNavigationNotOptInInInitialNavigation = 49, |
| 100 | |
Lingqi Chi | aeec5df1 | 2022-10-26 03:41:42 | [diff] [blame] | 101 | // 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 Doi | 7e33f2f | 2022-12-12 16:15:09 | [diff] [blame] | 105 | kActivatedInBackground = 51, |
Nathan Memmott | 093d20ac | 2024-12-13 17:12:59 | [diff] [blame] | 106 | // kEmbedderHostDisallowed = 52, // No longer used. |
lingqi | 8a71823 | 2022-12-21 03:58:51 | [diff] [blame] | 107 | // Called when encounter failures during synchronous activation. |
Alison Gale | 47d1537d | 2024-04-19 21:31:46 | [diff] [blame] | 108 | // TODO(crbug.com/40238737): Remove this reason if no sample is |
lingqi | 8a71823 | 2022-12-21 03:58:51 | [diff] [blame] | 109 | // recorded in stable, or look into the reason if there are. |
| 110 | kActivationNavigationDestroyedBeforeSuccess = 53, |
lingqi | 42ab9f45 | 2022-12-30 16:56:49 | [diff] [blame] | 111 | // See comments on WebContents::kTabClosedWithoutUserGesture for the |
| 112 | // difference between the two statuses below. |
| 113 | kTabClosedByUserGesture = 54, |
| 114 | kTabClosedWithoutUserGesture = 55, |
Asami Doi | dac3f11 | 2023-01-18 06:31:02 | [diff] [blame] | 115 | kPrimaryMainFrameRendererProcessCrashed = 56, |
| 116 | kPrimaryMainFrameRendererProcessKilled = 57, |
lingqi | 6d03e42 | 2023-01-19 02:37:06 | [diff] [blame] | 117 | kActivationFramePolicyNotCompatible = 58, |
Johann | d0d31ee | 2023-01-27 03:14:54 | [diff] [blame] | 118 | kPreloadingDisabled = 59, |
| 119 | kBatterySaverEnabled = 60, |
Asami Doi | 3965173 | 2023-01-31 05:25:26 | [diff] [blame] | 120 | kActivatedDuringMainFrameNavigation = 61, |
Johann | d811e1f | 2023-02-03 23:09:34 | [diff] [blame] | 121 | kPreloadingUnsupportedByWebContents = 62, |
Hiroki Nakagawa | d04aaaf9 | 2023-03-20 17:13:28 | [diff] [blame] | 122 | |
| 123 | // Enums for main frame navigation in prerendered pages. |
| 124 | kCrossSiteRedirectInMainFrameNavigation = 63, |
| 125 | kCrossSiteNavigationInMainFrameNavigation = 64, |
| 126 | kSameSiteCrossOriginRedirectNotOptInInMainFrameNavigation = 65, |
| 127 | kSameSiteCrossOriginNavigationNotOptInInMainFrameNavigation = 66, |
| 128 | |
Hiroki Nakagawa | 34e5d67 | 2023-04-21 05:00:09 | [diff] [blame] | 129 | kMemoryPressureOnTrigger = 67, |
| 130 | kMemoryPressureAfterTriggered = 68, |
| 131 | |
keno | 8480d579f | 2023-05-25 11:34:17 | [diff] [blame] | 132 | kPrerenderingDisabledByDevTools = 69, |
| 133 | |
Lingqi Chi | 350f4f1 | 2023-06-09 02:03:04 | [diff] [blame] | 134 | // Different from kBlockedByClient, which tracks the failure caused by main |
| 135 | // frame navigation, this status indicates that clients block some resource |
| 136 | // loading. |
Taiyo Mizuhashi | 3566d1e3 | 2023-10-10 18:35:22 | [diff] [blame] | 137 | // Eliminated per crrev.com/c/4891929. |
| 138 | // kResourceLoadBlockedByClient = 70, |
Lingqi Chi | 350f4f1 | 2023-06-09 02:03:04 | [diff] [blame] | 139 | |
Hiroki Nakagawa | 5f7d2db | 2023-07-12 22:54:06 | [diff] [blame] | 140 | // A trigger page removed a corresponding prerender rule from |
| 141 | // <script type="speculationrules">. |
| 142 | kSpeculationRuleRemoved = 71, |
| 143 | |
Hiroki Nakagawa | 2f42734 | 2023-07-19 23:27:04 | [diff] [blame] | 144 | // 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 Nakayama | 978f0a15 | 2025-06-17 08:26:25 | [diff] [blame] | 150 | kMaxNumOfRunningImmediatePrerendersExceeded = 73, |
| 151 | kMaxNumOfRunningNonImmediatePrerendersExceeded = 74, |
Taiyo Mizuhashi | 459a6b2 | 2023-09-13 07:56:48 | [diff] [blame] | 152 | kMaxNumOfRunningEmbedderPrerendersExceeded = 75, |
| 153 | |
Hiroki Nakagawa | d77864c | 2023-09-20 22:34:03 | [diff] [blame] | 154 | kPrerenderingUrlHasEffectiveUrl = 76, |
| 155 | kRedirectedPrerenderingUrlHasEffectiveUrl = 77, |
| 156 | kActivationUrlHasEffectiveUrl = 78, |
| 157 | |
Hiroki Nakagawa | c1e5801 | 2024-05-07 23:43:41 | [diff] [blame] | 158 | kJavaScriptInterfaceAdded = 79, |
| 159 | kJavaScriptInterfaceRemoved = 80, |
| 160 | |
Hiroki Nakagawa | 2db55b3 | 2024-05-09 08:41:27 | [diff] [blame] | 161 | kAllPrerenderingCanceled = 81, |
| 162 | |
HuanPo Lin | 95c9bc8 | 2024-07-09 04:41:33 | [diff] [blame] | 163 | // Cancelled by window.close() from renderer side. |
| 164 | kWindowClosed = 82, |
| 165 | |
Minoru Chikamune | 0e5cc583 | 2024-07-30 04:05:10 | [diff] [blame] | 166 | kSlowNetwork = 83, |
Hiroki Nakagawa | 9669f72 | 2024-07-30 05:21:51 | [diff] [blame] | 167 | kOtherPrerenderedPageActivated = 84, |
Minoru Chikamune | 0e5cc583 | 2024-07-30 04:05:10 | [diff] [blame] | 168 | |
Hiroki Nakagawa | 2961599 | 2024-10-02 06:48:11 | [diff] [blame] | 169 | // 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 Cheng | ec4c1897 | 2025-02-07 18:10:19 | [diff] [blame] | 172 | // kV8OptimizerDisabled = 85, |
Hiroki Nakagawa | 2961599 | 2024-10-02 06:48:11 | [diff] [blame] | 173 | |
kenoss | ab4aeb6 | 2024-10-11 11:37:40 | [diff] [blame] | 174 | // Prefetch ahead of prerender failed. Precise reason is recorded as UMA |
| 175 | // `Prerender.Experimental.PrefetchAheadOfPrerenderFailed.PrefetchStatus{PreloadingTriggerType}` |
| 176 | kPrerenderFailedDuringPrefetch = 86, |
| 177 | |
Steven Wei | 893cb02c | 2025-02-12 20:51:30 | [diff] [blame] | 178 | // Prerendering canceled by clearing cache from browsing data removal. |
| 179 | kBrowsingDataRemoved = 87, |
Jiacheng Guo | cfca196d | 2025-07-30 02:13:20 | [diff] [blame] | 180 | // Prerendering cancelled but the PrerenderHost is reused for future |
| 181 | // navigation. |
| 182 | kPrerenderHostReused = 88, |
Steven Wei | 893cb02c | 2025-02-12 20:51:30 | [diff] [blame] | 183 | |
Jiacheng Guo | cfca196d | 2025-07-30 02:13:20 | [diff] [blame] | 184 | kMaxValue = kPrerenderHostReused, |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 185 | }; |
Nan Lin | 18aa86ce43 | 2025-05-15 22:55:35 | [diff] [blame] | 186 | // LINT.ThenChange(//third_party/blink/public/devtools_protocol/browser_protocol.pdl) |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 187 | |
Xinan Lin | 9aa790d | 2023-01-06 18:13:55 | [diff] [blame] | 188 | // Helper method to convert PrerenderFinalStatus to PreloadingFailureReason. |
| 189 | PreloadingFailureReason CONTENT_EXPORT |
| 190 | ToPreloadingFailureReason(PrerenderFinalStatus); |
| 191 | |
| 192 | } // namespace content |
| 193 | |
Yoshiki Tanioka | 49b4cfb | 2022-10-20 09:25:31 | [diff] [blame] | 194 | #endif // CONTENT_BROWSER_PRELOADING_PRERENDER_PRERENDER_FINAL_STATUS_H_ |