Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: content/browser/loader/url_loader_request_handler.h

Issue 2897063002: Network service: Implement URLLoader chaining for interceptors (Closed)
Patch Set: documentation Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
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_LOADER_URL_LOADER_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
7
8 #include "base/callback_forward.h"
9 #include "base/macros.h"
10 #include "content/common/url_loader_factory.mojom.h"
11
12 namespace content {
13
14 class ResourceContext;
15 struct ResourceRequest;
16
17 using LoaderFactoryCallback =
18 base::OnceCallback<void(mojom::URLLoaderFactory*)>;
19
20 // An instance of this class is a per-request object and kept around during
21 // the lifetime of a request (including multiple redirect legs) on IO thread.
22 class CONTENT_EXPORT URLLoaderRequestHandler {
23 public:
24 URLLoaderRequestHandler() = default;
25 virtual ~URLLoaderRequestHandler() = default;
26
27 // Calls |callback| with non-null factory if this handler can handle
28 // the request, calls it with nullptr otherwise.
29 // Some implementation notes:
30 // 1) The returned pointer needs to be valid only until a single
31 // CreateLoaderAndStart call is made, and it is okay to do CHECK(false) for
32 // any subsequent calls.
33 // 2) The implementor is not supposed to set up and return URLLoaderFactory
34 // until it finds out that the handler is really going to handle the
35 // request. (For example ServiceWorker's request handler would not need to
36 // call the callback until it gets response from SW, and it may still
37 // call the callback with nullptr if it turns out that it needs to fallback
38 // to the network.)
39 virtual void MaybeCreateLoaderFactory(const ResourceRequest& resource_request,
40 ResourceContext* resource_context,
41 LoaderFactoryCallback callback) = 0;
42 };
43
44 } // namespace content
45
46 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698