xref: /aosp_15_r20/external/cronet/net/docs/life-of-a-feature.md (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker# Life of a Feature
2*6777b538SAndroid Build Coastguard Worker
3*6777b538SAndroid Build Coastguard WorkerIn the years since the Chromium browser was first open-sourced, the `//net`
4*6777b538SAndroid Build Coastguard Workerdirectory has expanded from being the basis of loading web content in the
5*6777b538SAndroid Build Coastguard WorkerChromium browser to accommodating a wide variety of networking needs,
6*6777b538SAndroid Build Coastguard Workerboth in the Chromium browser and in other Google and third-party products
7*6777b538SAndroid Build Coastguard Workerand projects.
8*6777b538SAndroid Build Coastguard Worker
9*6777b538SAndroid Build Coastguard WorkerThis brings with it many new opportunities, such as the ability to
10*6777b538SAndroid Build Coastguard Workerintroduce new protocols rapidly or push Web security forward, as well as
11*6777b538SAndroid Build Coastguard Workernew challenges, such as how to balance the needs of various `//net`
12*6777b538SAndroid Build Coastguard Workerconsumers effectively.
13*6777b538SAndroid Build Coastguard Worker
14*6777b538SAndroid Build Coastguard WorkerTo make it easier to contribute new features or to change existing
15*6777b538SAndroid Build Coastguard Workerbehaviors in `//net`, this document tries to capture the life of a
16*6777b538SAndroid Build Coastguard Workerfeature in `//net`, from initial design to the eventual possibility of
17*6777b538SAndroid Build Coastguard Workerdeprecation and removal.
18*6777b538SAndroid Build Coastguard Worker
19*6777b538SAndroid Build Coastguard Worker## Supported Projects
20*6777b538SAndroid Build Coastguard Worker
21*6777b538SAndroid Build Coastguard WorkerWhen considering the introduction of a new `//net` feature or changing
22*6777b538SAndroid Build Coastguard Workera `//net` behavior, it's first necessary to understand where `//net`
23*6777b538SAndroid Build Coastguard Workeris used, how it is used, and what the various constraints and limits are.
24*6777b538SAndroid Build Coastguard Worker
25*6777b538SAndroid Build Coastguard WorkerTo understand a more comprehensive matrix of the supported platforms and
26*6777b538SAndroid Build Coastguard Workerconstraints, see [Supported Projects](supported-projects.md). When
27*6777b538SAndroid Build Coastguard Workerexamining a new feature request, or a change in behavior, it's necessary
28*6777b538SAndroid Build Coastguard Workerto consider dimensions such as:
29*6777b538SAndroid Build Coastguard Worker
30*6777b538SAndroid Build Coastguard Worker  * Does this feature apply to all supported projects, or is this something
31*6777b538SAndroid Build Coastguard Worker    like a Browser-only feature?
32*6777b538SAndroid Build Coastguard Worker  * Does this feature apply to all supported platforms, or is this something
33*6777b538SAndroid Build Coastguard Worker    specific to a particular subset?
34*6777b538SAndroid Build Coastguard Worker  * Is the feature a basic networking library feature, or is it specific to
35*6777b538SAndroid Build Coastguard Worker    something in the Web Platform?
36*6777b538SAndroid Build Coastguard Worker  * Will some projects wish to strip the feature in order to meet targets
37*6777b538SAndroid Build Coastguard Worker    such as memory usage (RAM) or binary size?
38*6777b538SAndroid Build Coastguard Worker  * Does it depend on Google services or Google-specific behaviors or
39*6777b538SAndroid Build Coastguard Worker    features?
40*6777b538SAndroid Build Coastguard Worker  * How will this feature be tested / experimented with? For example,
41*6777b538SAndroid Build Coastguard Worker    __Field Trials (Finch)__ and __User Metrics (UMA)__ may not be available
42*6777b538SAndroid Build Coastguard Worker    on a number of platforms.
43*6777b538SAndroid Build Coastguard Worker  * How risky is the feature towards compatibility/stability? How will it
44*6777b538SAndroid Build Coastguard Worker    be undone if there is a bug?
45*6777b538SAndroid Build Coastguard Worker  * Are the power/memory/CPU/bandwidth requirements appropriate for the
46*6777b538SAndroid Build Coastguard Worker    targeted projects and/or platforms?
47*6777b538SAndroid Build Coastguard Worker
48*6777b538SAndroid Build Coastguard Worker## Design and Layering
49*6777b538SAndroid Build Coastguard Worker
50*6777b538SAndroid Build Coastguard WorkerOnce the supported platforms and constraints are identified, it's necessary
51*6777b538SAndroid Build Coastguard Workerto determine how to actually design the feature to meet those constraints,
52*6777b538SAndroid Build Coastguard Workerin hopefully the easiest way possible both for implementation and consumption.
53*6777b538SAndroid Build Coastguard Worker
54*6777b538SAndroid Build Coastguard Worker### Designing for multiple platforms
55*6777b538SAndroid Build Coastguard Worker
56*6777b538SAndroid Build Coastguard WorkerIn general, `//net` features try to support all platforms with a common
57*6777b538SAndroid Build Coastguard Workerinterface, and generally eschew OS-specific interfaces from being exposed as
58*6777b538SAndroid Build Coastguard Workerpart of `//net`.
59*6777b538SAndroid Build Coastguard Worker
60*6777b538SAndroid Build Coastguard WorkerCross-platform code is generally done via declaring an interface named
61*6777b538SAndroid Build Coastguard Worker`foo.h`, which is common for all platforms, and then using the build-system to
62*6777b538SAndroid Build Coastguard Workerdo compile-time switching between implementations in `foo_win.cc`, `foo_mac.cc`,
63*6777b538SAndroid Build Coastguard Worker`foo_android.cc`, etc.
64*6777b538SAndroid Build Coastguard Worker
65*6777b538SAndroid Build Coastguard WorkerThe goal is to ensure that consumers generally don't have to think about
66*6777b538SAndroid Build Coastguard WorkerOS-specific considerations, and can instead code to the interface.
67*6777b538SAndroid Build Coastguard Worker
68*6777b538SAndroid Build Coastguard Worker### Designing for multiple products
69*6777b538SAndroid Build Coastguard Worker
70*6777b538SAndroid Build Coastguard WorkerWhile premature abstraction can significantly harm readability, if it is
71*6777b538SAndroid Build Coastguard Workeranticipated that different products will have different implementation needs,
72*6777b538SAndroid Build Coastguard Workeror may wish to selectively disable the feature, it's often necessary to
73*6777b538SAndroid Build Coastguard Workerabstract that interface sufficiently in `//net` to allow for dependency
74*6777b538SAndroid Build Coastguard Workerinjection.
75*6777b538SAndroid Build Coastguard Worker
76*6777b538SAndroid Build Coastguard WorkerThis is true whether discussing concrete classes and interfaces or something
77*6777b538SAndroid Build Coastguard Workeras simple a boolean configuration flag that different consumers wish to set
78*6777b538SAndroid Build Coastguard Workerdifferently.
79*6777b538SAndroid Build Coastguard Worker
80*6777b538SAndroid Build Coastguard WorkerThe two most common approaches in `//net` are injection and delegation.
81*6777b538SAndroid Build Coastguard Worker
82*6777b538SAndroid Build Coastguard Worker#### Injection
83*6777b538SAndroid Build Coastguard Worker
84*6777b538SAndroid Build Coastguard WorkerInjection refers to the pattern of defining the interface or concrete
85*6777b538SAndroid Build Coastguard Workerconfiguration parameter (such as a boolean), along with the concrete
86*6777b538SAndroid Build Coastguard Workerimplementation, but requiring the `//net` embedder to supply an instance
87*6777b538SAndroid Build Coastguard Workerof the interface or the configuration parameters (perhaps optionally).
88*6777b538SAndroid Build Coastguard Worker
89*6777b538SAndroid Build Coastguard WorkerExamples of this pattern include things such as the `ProxyConfigService`,
90*6777b538SAndroid Build Coastguard Workerwhich has concrete implementations in `//net` for a variety of platforms'
91*6777b538SAndroid Build Coastguard Workerconfiguration of proxies, but which requires it be supplied as part of the
92*6777b538SAndroid Build Coastguard Worker`URLRequestContextGetter` building, if proxies are going to be supported.
93*6777b538SAndroid Build Coastguard Worker
94*6777b538SAndroid Build Coastguard WorkerAn example of injecting configuration flags can be seen in the
95*6777b538SAndroid Build Coastguard Worker`HttpNetworkSessionParams` structure, which is used to provide much of
96*6777b538SAndroid Build Coastguard Workerthe initialization parameters for the HTTP layer.
97*6777b538SAndroid Build Coastguard Worker
98*6777b538SAndroid Build Coastguard WorkerThe ideal form of injection is to pass ownership of the injected object,
99*6777b538SAndroid Build Coastguard Workersuch as via a `std::unique_ptr<Foo>`. While this is not consistently
100*6777b538SAndroid Build Coastguard Workerapplied in `//net`, as there are a number of places in which ownership is
101*6777b538SAndroid Build Coastguard Workereither shared or left to the embedder, with the injected object passed
102*6777b538SAndroid Build Coastguard Workeraround as a naked/raw pointer, this is generally seen as an anti-pattern
103*6777b538SAndroid Build Coastguard Workerand not to be mirrored for new features.
104*6777b538SAndroid Build Coastguard Worker
105*6777b538SAndroid Build Coastguard Worker#### Delegation
106*6777b538SAndroid Build Coastguard Worker
107*6777b538SAndroid Build Coastguard WorkerDelegation refers to forcing the `//net` embedder to respond to specific
108*6777b538SAndroid Build Coastguard Workerdelegated calls via a Delegate interface that it implements. In general,
109*6777b538SAndroid Build Coastguard Workerwhen using the delegate pattern, ownership of the delegate should be
110*6777b538SAndroid Build Coastguard Workertransferred, so that the lifetime and threading semantics are clear and
111*6777b538SAndroid Build Coastguard Workerunambiguous.
112*6777b538SAndroid Build Coastguard Worker
113*6777b538SAndroid Build Coastguard WorkerThat is, for a given class `Foo`, which has a `Foo::Delegate` interface
114*6777b538SAndroid Build Coastguard Workerdefined to allow embedders to alter behavior, prefer a constructor that
115*6777b538SAndroid Build Coastguard Workeris
116*6777b538SAndroid Build Coastguard Worker```
117*6777b538SAndroid Build Coastguard Workerexplicit Foo(std::unique_ptr<Delegate> delegate);
118*6777b538SAndroid Build Coastguard Worker```
119*6777b538SAndroid Build Coastguard Workerso that it is clear that the lifetime of `delegate` is determined by
120*6777b538SAndroid Build Coastguard Worker`Foo`.
121*6777b538SAndroid Build Coastguard Worker
122*6777b538SAndroid Build Coastguard WorkerWhile this may appear similar to Injection, the general difference
123*6777b538SAndroid Build Coastguard Workerbetween the two approaches is determining where the bulk of the
124*6777b538SAndroid Build Coastguard Workerimplementation lies. With Injection, the interface describes a
125*6777b538SAndroid Build Coastguard Workerbehavior contract that concrete implementations must adhere to; this
126*6777b538SAndroid Build Coastguard Workerallows for much more flexibility with behavior, but with the downside
127*6777b538SAndroid Build Coastguard Workerof significantly more work to implement or extend. Delegation attempts
128*6777b538SAndroid Build Coastguard Workerto keep the bulk of the implementation in `//net`, and the decision as
129*6777b538SAndroid Build Coastguard Workerto which implementation to use in `//net`, but allows `//net` to
130*6777b538SAndroid Build Coastguard Workerprovide specific ways in which embedders can alter behaviors.
131*6777b538SAndroid Build Coastguard Worker
132*6777b538SAndroid Build Coastguard WorkerThe most notable example of the delegate pattern is `URLRequest::Delegate`,
133*6777b538SAndroid Build Coastguard Workerwhich keeps the vast majority of the loading logic within `URLRequest`,
134*6777b538SAndroid Build Coastguard Workerbut allows the `URLRequest::Delegate` to participate during specific times
135*6777b538SAndroid Build Coastguard Workerin the request lifetime and alter specific behaviors as necessary. (Note:
136*6777b538SAndroid Build Coastguard Worker`URLRequest::Delegate`, like much of the original `//net` code, doesn't
137*6777b538SAndroid Build Coastguard Workeradhere to the recommended lifetime patterns of passing ownership of the
138*6777b538SAndroid Build Coastguard WorkerDelegate. It is from the experience debugging and supporting these APIs
139*6777b538SAndroid Build Coastguard Workerthat the `//net` team strongly encourages all new code pass explicit
140*6777b538SAndroid Build Coastguard Workerownership, to reduce the complexity and risk of lifetime issues).
141*6777b538SAndroid Build Coastguard Worker
142*6777b538SAndroid Build Coastguard WorkerWhile the use of a `base::RepeatingCallback` can also be considered a form of
143*6777b538SAndroid Build Coastguard Workerdelegation, the `//net` layer tries to eschew any callbacks that can be
144*6777b538SAndroid Build Coastguard Workercalled more than once, and instead favors defining class interfaces
145*6777b538SAndroid Build Coastguard Workerwith concrete behavioral requirements in order to ensure the correct
146*6777b538SAndroid Build Coastguard Workerlifetimes of objects and to adjust over time. When `//net` takes a
147*6777b538SAndroid Build Coastguard Workercallback (e.g. `net::CompletionOnceCallback`), the intended pattern is to
148*6777b538SAndroid Build Coastguard Workersignal the asynchronous completion of a single method, invoking that
149*6777b538SAndroid Build Coastguard Workercallback at most once before deallocating it. For more discussion
150*6777b538SAndroid Build Coastguard Workerof these patterns, see [Code Patterns](code-patterns.md).
151*6777b538SAndroid Build Coastguard Worker
152*6777b538SAndroid Build Coastguard Worker### Understanding the Layering
153*6777b538SAndroid Build Coastguard Worker
154*6777b538SAndroid Build Coastguard WorkerA significant challenge many feature proposals face is understanding the
155*6777b538SAndroid Build Coastguard Workerlayering in `//net` and what different portions of `//net` are allowed to
156*6777b538SAndroid Build Coastguard Workerknow.
157*6777b538SAndroid Build Coastguard Worker
158*6777b538SAndroid Build Coastguard Worker#### Socket Pools
159*6777b538SAndroid Build Coastguard Worker
160*6777b538SAndroid Build Coastguard WorkerThe most common challenge feature proposals encounter is the awareness
161*6777b538SAndroid Build Coastguard Workerthat the act of associating an actual request to make with a socket is
162*6777b538SAndroid Build Coastguard Workerdone lazily, referred to as "late-binding".
163*6777b538SAndroid Build Coastguard Worker
164*6777b538SAndroid Build Coastguard WorkerWith late-bound sockets, a given `URLRequest` will not be assigned an actual
165*6777b538SAndroid Build Coastguard Workertransport connection until the request is ready to be sent. This allows for
166*6777b538SAndroid Build Coastguard Workerreprioritizing requests as they come in, to ensure that higher priority requests
167*6777b538SAndroid Build Coastguard Workerget preferential treatment, but it also means that features or data associated
168*6777b538SAndroid Build Coastguard Workerwith a `URLRequest` generally don't participate in socket establishment or
169*6777b538SAndroid Build Coastguard Workermaintenance.
170*6777b538SAndroid Build Coastguard Worker
171*6777b538SAndroid Build Coastguard WorkerFor example, a feature that wants to associate the low-level network socket
172*6777b538SAndroid Build Coastguard Workerwith a `URLRequest` during connection establishment is not something that the
173*6777b538SAndroid Build Coastguard Worker`//net` design supports, since the `URLRequest` is kept unaware of how sockets
174*6777b538SAndroid Build Coastguard Workerare established by virtue of the socket pools and late binding. This allows for
175*6777b538SAndroid Build Coastguard Workermore flexibility when working to improve performance, such as the ability to
176*6777b538SAndroid Build Coastguard Workercoalesce multiple logical 'sockets' over a single HTTP/2 or QUIC stream, which
177*6777b538SAndroid Build Coastguard Workermay only have a single physical network socket involved.
178*6777b538SAndroid Build Coastguard Worker
179*6777b538SAndroid Build Coastguard Worker#### Making Additional Requests
180*6777b538SAndroid Build Coastguard Worker
181*6777b538SAndroid Build Coastguard WorkerFrom time to time, `//net` feature proposals will involve needing to load
182*6777b538SAndroid Build Coastguard Workera secondary resource as part of processing. For example, feature proposals have
183*6777b538SAndroid Build Coastguard Workerinvolved fetching a `/.well-known/` URI or reporting errors to a particular URL.
184*6777b538SAndroid Build Coastguard Worker
185*6777b538SAndroid Build Coastguard WorkerThis is particularly challenging, because often, these features are implemented
186*6777b538SAndroid Build Coastguard Workerdeeper in the network stack, such as [`//net/cert`](../cert), [`//net/http`](../http),
187*6777b538SAndroid Build Coastguard Workeror [`//net/filter`](../filter), which [`//net/url_request`](../url_request) depends
188*6777b538SAndroid Build Coastguard Workeron. Because `//net/url_request` depends on these low-level directories, it would
189*6777b538SAndroid Build Coastguard Workerbe a circular dependency to have these directories depend on `//net/url_request`,
190*6777b538SAndroid Build Coastguard Workerand circular dependencies are forbidden.
191*6777b538SAndroid Build Coastguard Worker
192*6777b538SAndroid Build Coastguard WorkerThe recommended solution to address this is to adopt the delegation or injection
193*6777b538SAndroid Build Coastguard Workerpatterns. The lower-level directory will define some interface that represents the
194*6777b538SAndroid Build Coastguard Worker"I need this URL" request, and then elsewhere, in a directory allowed to depend
195*6777b538SAndroid Build Coastguard Workeron `//net/url_request`, an implementation of that interface/delegate that uses
196*6777b538SAndroid Build Coastguard Worker`//net/url_request` is implemented.
197*6777b538SAndroid Build Coastguard Worker
198*6777b538SAndroid Build Coastguard Worker### Understanding the Lifetimes
199*6777b538SAndroid Build Coastguard Worker
200*6777b538SAndroid Build Coastguard WorkerUnderstanding the object lifetime and dependency graph can be one of the largest
201*6777b538SAndroid Build Coastguard Workerchallenges to contributing and maintaining `//net`. As a consequence, features
202*6777b538SAndroid Build Coastguard Workerwhich require introducing more complexity to the lifetimes of objects generally
203*6777b538SAndroid Build Coastguard Workerhave a greater challenge to acceptance.
204*6777b538SAndroid Build Coastguard Worker
205*6777b538SAndroid Build Coastguard WorkerThe `//net` stack is designed heavily around a sync-or-async pattern, as
206*6777b538SAndroid Build Coastguard Workerdocumented in [Code Patterns](code-patterns.md), while also having a strong
207*6777b538SAndroid Build Coastguard Workerrequirement that it be possible to cleanly shutdown the network stack. As a
208*6777b538SAndroid Build Coastguard Workerconsequence, features should have precise, well-defined lifetime semantics
209*6777b538SAndroid Build Coastguard Workerand support graceful cleanup. Further, because much of the network stack can
210*6777b538SAndroid Build Coastguard Workerhave web-observable side-effects, it is often required for tasks to have
211*6777b538SAndroid Build Coastguard Workerdefined sequencing that cannot be reordered. To be ensure these requirements
212*6777b538SAndroid Build Coastguard Workerare met, features should attempt to model object lifetimes as a hierarchical
213*6777b538SAndroid Build Coastguard WorkerDAG, using explicit ownership and avoiding the use of reference counting or
214*6777b538SAndroid Build Coastguard Workerweak pointers as part of any of the exposed API contracts (even for features
215*6777b538SAndroid Build Coastguard Workeronly consumed in `//net`). Features that pay close attention to the lifetime
216*6777b538SAndroid Build Coastguard Workersemantics are more likely to be reviewed and accepted than those that leave
217*6777b538SAndroid Build Coastguard Workerit ambiguous.
218*6777b538SAndroid Build Coastguard Worker
219*6777b538SAndroid Build Coastguard WorkerIn addition to preferring explicit lifetimes, such as through judicious use of
220*6777b538SAndroid Build Coastguard Worker`std::unique_ptr<>` to indicate ownership transfer of dependencies, many
221*6777b538SAndroid Build Coastguard Workerfeatures in `//net` also expect that if a `base::{Once, Repeating}Callback` is
222*6777b538SAndroid Build Coastguard Workerinvolved (which includes `net::CompletionOnceCallback`), then it's possible that
223*6777b538SAndroid Build Coastguard Workerinvoking the callback may result in the deletion of the current (calling)
224*6777b538SAndroid Build Coastguard Workerobject. As further expanded upon in [Code Patterns](code-patterns.md), features
225*6777b538SAndroid Build Coastguard Workerand changes should be designed such that any callback invocation is the last bit
226*6777b538SAndroid Build Coastguard Workerof code executed, and that the callback is accessed via the stack (such as
227*6777b538SAndroid Build Coastguard Workerthrough the use of `std::move(callback_).Run()`.
228*6777b538SAndroid Build Coastguard Worker
229*6777b538SAndroid Build Coastguard Worker### Specs: What Are They Good For
230*6777b538SAndroid Build Coastguard Worker
231*6777b538SAndroid Build Coastguard WorkerAs `//net` is used as the basis for a number of browsers, it's an important part
232*6777b538SAndroid Build Coastguard Workerof the design philosophy to ensure behaviors are well-specified, and that the
233*6777b538SAndroid Build Coastguard Workerimplementation conforms to those specifications. This may be seen as burdensome
234*6777b538SAndroid Build Coastguard Workerwhen it's unclear whether or not a feature will 'take off,' but it's equally
235*6777b538SAndroid Build Coastguard Workercritical to ensure that the Chromium projects do not fork the Web Platform.
236*6777b538SAndroid Build Coastguard Worker
237*6777b538SAndroid Build Coastguard Worker#### Incubation Is Required
238*6777b538SAndroid Build Coastguard Worker
239*6777b538SAndroid Build Coastguard Worker`//net` respects Chromium's overall position of [incubation first](https://groups.google.com/a/chromium.org/d/msg/blink-dev/PJ_E04kcFb8/baiLN3DTBgAJ) standards development.
240*6777b538SAndroid Build Coastguard Worker
241*6777b538SAndroid Build Coastguard WorkerWith an incubation first approach, before introducing any new features that
242*6777b538SAndroid Build Coastguard Workermight be exposed over the wire to servers, whether they are explicit behaviors,
243*6777b538SAndroid Build Coastguard Workersuch as adding new headers, or implicit behaviors such as
244*6777b538SAndroid Build Coastguard Worker[Happy Eyeballs](https://tools.ietf.org/html/rfc6555), should have some form
245*6777b538SAndroid Build Coastguard Workerof specification written. That specification should at least be on an
246*6777b538SAndroid Build Coastguard Workerincubation track, and the expectation is that the specification should have a
247*6777b538SAndroid Build Coastguard Workerdirect path to an appropriate standards track. Features which don't adhere to
248*6777b538SAndroid Build Coastguard Workerthis pattern, or which are not making progress towards a standards track, will
249*6777b538SAndroid Build Coastguard Workerrequire high-level approvals, to ensure that the Platform doesn't fragment.
250*6777b538SAndroid Build Coastguard Worker
251*6777b538SAndroid Build Coastguard Worker#### Introducing New Headers
252*6777b538SAndroid Build Coastguard Worker
253*6777b538SAndroid Build Coastguard WorkerA common form of feature request is the introduction of new headers, either via
254*6777b538SAndroid Build Coastguard Workerthe `//net` implementation directly, or through consuming `//net` interfaces
255*6777b538SAndroid Build Coastguard Workerand modifying headers on the fly.
256*6777b538SAndroid Build Coastguard Worker
257*6777b538SAndroid Build Coastguard WorkerThe introduction of any additional headers SHOULD have an incubated spec attached,
258*6777b538SAndroid Build Coastguard Workerideally with cross-vendor interest. Particularly, headers which only apply to
259*6777b538SAndroid Build Coastguard WorkerGoogle or Google services are very likely to be rejected outright.
260*6777b538SAndroid Build Coastguard Worker
261*6777b538SAndroid Build Coastguard Worker#### Making Additional Requests
262*6777b538SAndroid Build Coastguard Worker
263*6777b538SAndroid Build Coastguard WorkerWhile it's necessary to provide abstraction around `//net/url_request` for
264*6777b538SAndroid Build Coastguard Workerany lower-level components that may need to make additional requests, for most
265*6777b538SAndroid Build Coastguard Workerfeatures, that's not all that is necessary. Because `//net/url_request` only
266*6777b538SAndroid Build Coastguard Workerprovides a basic HTTP fetching mechanism, it's insufficient for any Web Platform
267*6777b538SAndroid Build Coastguard Workerfeature, because it doesn't consider the broader platform concerns such as
268*6777b538SAndroid Build Coastguard Workerinteractions with CORS, Service Workers, cookie and authentication policies, or
269*6777b538SAndroid Build Coastguard Workereven basic interactions with optional features like Extensions or SafeBrowsing.
270*6777b538SAndroid Build Coastguard Worker
271*6777b538SAndroid Build Coastguard WorkerTo account for all of these things, any resource fetching that is to support
272*6777b538SAndroid Build Coastguard Workera feature of the Web Platform, whether because the resource will be directly
273*6777b538SAndroid Build Coastguard Workerexposed to web content (for example, an image load or prefetch) or because it
274*6777b538SAndroid Build Coastguard Workeris in response to invoking a Web Platform API (for example, invoking the
275*6777b538SAndroid Build Coastguard Workercredential management API), the feature's resource fetching should be
276*6777b538SAndroid Build Coastguard Workerexplainable in terms of the  [Fetch Living Standard](https://fetch.spec.whatwg.org/).
277*6777b538SAndroid Build Coastguard WorkerThe Fetch standard defines a JavaScript API for fetching resources, but more
278*6777b538SAndroid Build Coastguard Workerimportantly, defines a common set of infrastructure and terminology that
279*6777b538SAndroid Build Coastguard Workertries to define how all resource loads in the Web Platform happen - whether
280*6777b538SAndroid Build Coastguard Workerit be through the JavaScript API, through `XMLHttpRequest`, or the `src`
281*6777b538SAndroid Build Coastguard Workerattribute in HTML tags, for example.
282*6777b538SAndroid Build Coastguard Worker
283*6777b538SAndroid Build Coastguard WorkerThis also includes any resource fetching that wishes to use the same socket
284*6777b538SAndroid Build Coastguard Workerpools or caches as the Web Platform, to ensure that every resource that is
285*6777b538SAndroid Build Coastguard Workerweb exposed (directly or indirectly) is fetched in a consistent and
286*6777b538SAndroid Build Coastguard Workerwell-documented way, thus minimizing platform fragmentation and security
287*6777b538SAndroid Build Coastguard Workerissues.
288*6777b538SAndroid Build Coastguard Worker
289*6777b538SAndroid Build Coastguard WorkerThere are exceptions to this, however, but they're generally few and far
290*6777b538SAndroid Build Coastguard Workerbetween. In general, any feature that needs to define an abstraction to
291*6777b538SAndroid Build Coastguard Workerallow it to "fetch resources," likely needs to also be "explained in terms
292*6777b538SAndroid Build Coastguard Workerof Fetch".
293*6777b538SAndroid Build Coastguard Worker
294*6777b538SAndroid Build Coastguard Worker## Implementation
295*6777b538SAndroid Build Coastguard Worker
296*6777b538SAndroid Build Coastguard WorkerIn general, prior to implementing, try to get a review on [email protected]
297*6777b538SAndroid Build Coastguard Workerfor the general feedback and design review.
298*6777b538SAndroid Build Coastguard Worker
299*6777b538SAndroid Build Coastguard WorkerIn addition to the [email protected] early review, `//net` requires that any
300*6777b538SAndroid Build Coastguard Workerbrowser-exposed behavior should also adhere to the
301*6777b538SAndroid Build Coastguard Worker[Blink Process](https://www.chromium.org/blink#new-features), which includes an
302*6777b538SAndroid Build Coastguard Worker"Intent to Implement" message to [email protected]
303*6777b538SAndroid Build Coastguard Worker
304*6777b538SAndroid Build Coastguard WorkerFor features that are unclear about their future, such as experiments or trials,
305*6777b538SAndroid Build Coastguard Workerit's also expected that the design planning will also account for how features
306*6777b538SAndroid Build Coastguard Workerwill be removed cleanly. For features that radically affect the architecture of
307*6777b538SAndroid Build Coastguard Worker`//net`, expect a high bar of justification, since reversing those changes if
308*6777b538SAndroid Build Coastguard Workerthey fail to pan out can cause significant disruption to productivity and
309*6777b538SAndroid Build Coastguard Workerstability.
310*6777b538SAndroid Build Coastguard Worker
311*6777b538SAndroid Build Coastguard Worker## Deprecation
312*6777b538SAndroid Build Coastguard Worker
313*6777b538SAndroid Build Coastguard WorkerPlan for obsolence, hope for success. Similar to implementation, features that
314*6777b538SAndroid Build Coastguard Workerare to be removed should also go through the
315*6777b538SAndroid Build Coastguard Worker[Blink Process](https://www.chromium.org/blink#TOC-Web-Platform-Changes:-Process)
316*6777b538SAndroid Build Coastguard Workerfor removing features.
317*6777b538SAndroid Build Coastguard Worker
318*6777b538SAndroid Build Coastguard WorkerNote that due to the diversity of [Supported Projects](supported-projects.md),
319*6777b538SAndroid Build Coastguard Workerremoving a feature while minimizing disruption can be just as complex as adding
320*6777b538SAndroid Build Coastguard Workera feature. For example, relying solely on __User Metrics (UMA)__ to signal the
321*6777b538SAndroid Build Coastguard Workersafety of removing a feature may not consider all projects, and relying on
322*6777b538SAndroid Build Coastguard Worker__Field Trials (Finch)__ to assess risk or restore the 'legacy' behavior may not
323*6777b538SAndroid Build Coastguard Workerwork on all projects either.
324*6777b538SAndroid Build Coastguard Worker
325*6777b538SAndroid Build Coastguard WorkerIt's precisely because of these challenges that there's such a high bar for
326*6777b538SAndroid Build Coastguard Workeradding features, because they may represent multi-year commitments to support,
327*6777b538SAndroid Build Coastguard Workereven when the feature itself is deprecated or targeted for removal.
328