xref: /aosp_15_r20/external/cronet/net/base/request_priority.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2012 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 NET_BASE_REQUEST_PRIORITY_H_
6 #define NET_BASE_REQUEST_PRIORITY_H_
7 
8 #include "net/base/net_export.h"
9 
10 namespace net {
11 
12 // Prioritization used in various parts of the networking code such
13 // as connection prioritization and resource loading prioritization.
14 // A Java counterpart will be generated for this enum.
15 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
16 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: RequestPriority
17 //
18 // This enum should be synchronized with the enum NetRequestPriority in
19 // tools/metrics/histograms/enums.xml.
20 enum RequestPriority {
21   THROTTLED = 0,  // Used to signal that resources
22                   // should be reserved for following
23                   // requests (i.e. that higher priority
24                   // following requests are expected).
25   MINIMUM_PRIORITY = THROTTLED,
26   IDLE = 1,  // Default "as resources available" level.
27   LOWEST = 2,
28   DEFAULT_PRIORITY = LOWEST,
29   LOW = 3,
30   MEDIUM = 4,
31   HIGHEST = 5,
32   MAXIMUM_PRIORITY = HIGHEST,
33 };
34 
35 // For simplicity, one can assume that one can index into array of
36 // NUM_PRIORITIES elements with a RequestPriority (i.e.,
37 // MINIMUM_PRIORITY == 0).
38 enum RequestPrioritySize {
39   NUM_PRIORITIES = MAXIMUM_PRIORITY + 1,
40 };
41 
42 // Default value to use for the incremental loading flag as part of HTTP
43 // extensible priorities (RFC 9218). Currently used for HTTP/3.
44 //
45 // This default is the value that works best in most cases that the networking
46 // code supports (simultaneous requests are loaded concurrently and don't block
47 // one another).
48 //
49 // This is independent from the spec default for the protocol, which is false.
50 const bool kDefaultPriorityIncremental = true;
51 
52 NET_EXPORT const char* RequestPriorityToString(RequestPriority priority);
53 
54 }  // namespace net
55 
56 #endif  // NET_BASE_REQUEST_PRIORITY_H_
57