Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 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 // Note that the implementor is not supposed to set up and return | |
| 30 // URLLoaderFactory until it finds out that the handler is really going | |
| 31 // to handle the request. (For example ServiceWorker's request handler | |
| 32 // would not call the callback until it gets response from SW, and it | |
| 33 // may still call the callback with nullptr if it turns out that it needs | |
| 34 // to fallback to the network.) | |
|
michaeln
2017/05/26 17:42:27
Can we specify that the returned URLLoaderFactory
kinuko
2017/05/29 06:12:24
Done.
| |
| 35 virtual void MaybeCreateLoaderFactory(const ResourceRequest& resource_request, | |
| 36 ResourceContext* resource_context, | |
| 37 LoaderFactoryCallback callback) = 0; | |
| 38 }; | |
| 39 | |
| 40 } // namespace content | |
| 41 | |
| 42 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_ | |
| OLD | NEW |