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

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

Issue 2982363002: Add support for fallback content for the frame. This includes main and subframes. (Closed)
Patch Set: Address review comments. Created 3 years, 5 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_ 6 #define CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "content/public/common/url_loader.mojom.h" 11 #include "content/public/common/url_loader.mojom.h"
12 #include "content/public/common/url_loader_factory.mojom.h" 12 #include "content/public/common/url_loader_factory.mojom.h"
13 #include "net/url_request/redirect_info.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 class ResourceContext; 17 class ResourceContext;
17 struct ResourceRequest; 18 struct ResourceRequest;
18 19
19 using StartLoaderCallback = 20 using StartLoaderCallback =
20 base::OnceCallback<void(mojom::URLLoaderRequest request, 21 base::OnceCallback<void(mojom::URLLoaderRequest request,
21 mojom::URLLoaderClientPtr client)>; 22 mojom::URLLoaderClientPtr client)>;
22 23
23 using LoaderCallback = base::OnceCallback<void(StartLoaderCallback)>; 24 using LoaderCallback = base::OnceCallback<void(StartLoaderCallback)>;
24 25
25 // An instance of this class is a per-request object and kept around during 26 // An instance of this class is a per-request object and kept around during
26 // the lifetime of a request (including multiple redirect legs) on IO thread. 27 // the lifetime of a request (including multiple redirect legs) on IO thread.
27 class CONTENT_EXPORT URLLoaderRequestHandler { 28 class CONTENT_EXPORT URLLoaderRequestHandler {
28 public: 29 public:
29 URLLoaderRequestHandler() = default; 30 URLLoaderRequestHandler() = default;
30 virtual ~URLLoaderRequestHandler() = default; 31 virtual ~URLLoaderRequestHandler() = default;
31 32
32 // Calls |callback| with a non-null StartLoaderCallback if this handler 33 // Calls |callback| with a non-null StartLoaderCallback if this handler
33 // can handle the request, calls it with null callback otherwise. 34 // can handle the request, calls it with null callback otherwise.
34 virtual void MaybeCreateLoader(const ResourceRequest& resource_request, 35 virtual void MaybeCreateLoader(const ResourceRequest& resource_request,
35 ResourceContext* resource_context, 36 ResourceContext* resource_context,
36 LoaderCallback callback) = 0; 37 LoaderCallback callback) = 0;
37 38
38 // Returns the URLLoaderFactory if any to be used for subsequent URL requests 39 // Returns the URLLoaderFactory if any to be used for subsequent URL requests
39 // going forward. Subclasses who want to handle subresource requests etc may 40 // going forward. Subclasses who want to handle subresource requests etc may
40 // want to override this to return a custom factory. 41 // want to override this to return a custom factory.
41 virtual mojom::URLLoaderFactoryPtr MaybeCreateSubresourceFactory(); 42 virtual mojom::URLLoaderFactoryPtr MaybeCreateSubresourceFactory();
43
44 // Returns true if the handler delivers fallback content for the |response|
45 // passed. The |client| parameter points to the URLLoaderClient instance
46 // which is used for passing the fallback content and other information to
47 // the client. The |request| parameter points to the bound url request.
48 virtual bool MaybeGetFallbackForResponse(const ResourceResponseHead& response,
49 mojom::URLLoaderClientPtr* client,
50 mojom::URLLoaderRequest* request);
kinuko 2017/07/26 01:59:14 (If we end up having this kind of hooks) Could we
michaeln 2017/07/26 23:08:41 I don't know how much it helps, but we could expos
ananta 2017/07/27 02:40:25 Removed the functions added to the URLLoaderReques
ananta 2017/07/27 02:40:25 We decided to go with the additional callback func
kinuko 2017/07/27 13:46:26 Hm... sorry to say this, but I think I might have
jam 2017/07/27 23:19:13 If we don't want the appcache handler to make the
51
52 // Returns true if the handler delivers fallback content for the redirect
53 // |response| passed in. The |redirect_info| parameter contains the new
54 // location, etc. The |client| parameter points to the URLLoaderClient
55 // instance which is used for passing the fallback content and other
56 // information to the client. The |request| parameter points to the
57 // bound url request.
58 virtual bool MaybeGetFallbackForRedirect(
59 const ResourceResponseHead& response,
60 const net::RedirectInfo& redirect_info,
61 mojom::URLLoaderClientPtr* client,
62 mojom::URLLoaderRequest* request);
42 }; 63 };
43 64
44 } // namespace content 65 } // namespace content
45 66
46 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_ 67 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_REQUEST_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698