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

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

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: incorporated mmemke's comment Created 4 years, 1 month 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 2016 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_RESOURCE_REQUESTER_INFO_H_
6 #define CONTENT_BROWSER_LOADER_RESOURCE_REQUESTER_INFO_H_
7
8 #include <memory>
9
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h"
12 #include "content/public/common/resource_type.h"
13
14 namespace net {
15 class URLRequestContext;
16 } // namespace net
17
18 namespace storage {
19 class FileSystemContext;
20 } // namespace storage
21
22 namespace content {
23 class BrowserMessageFilter;
24 class ChromeAppCacheService;
25 class ChromeBlobStorageContext;
26 class ResourceContext;
27 class ResourceMessageFilter;
28 class ServiceWorkerContextWrapper;
29
30 // This class represents the type of resource request.
31 // Currently there are three types:
32 // - Resource request from renderer processes.
33 // - Resource request for browser side navigation. (PlzNavigate).
34 // - Download request or page save request.
35 class CONTENT_EXPORT ResourceRequesterInfo {
36 public:
37 // Creates a ResourceRequesterInfo for renderer process initiated request.
38 // |filter| can't be null.
39 static std::unique_ptr<ResourceRequesterInfo> CreateForRenderer(
40 ResourceMessageFilter* filter);
41
42 // Creates a ResourceRequesterInfo for a renderer process initiated request
43 // without ResourceMessageFilter for unittests.
44 static std::unique_ptr<ResourceRequesterInfo> CreateForRendererTesting(
45 int child_id);
46
47 // Creates a ResourceRequesterInfo for a browser side navigation request which
48 // is initiated by the browser process.
49 static std::unique_ptr<ResourceRequesterInfo> CreateForBrowserSideNavigation(
50 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
51
52 // Creates a ResourceRequesterInfo for a download or page save request.
53 static std::unique_ptr<ResourceRequesterInfo> CreateForDownloadOrPageSave(
54 int child_id);
55
56 virtual ~ResourceRequesterInfo() {}
57
58 virtual std::unique_ptr<ResourceRequesterInfo> clone() const = 0;
59
60 virtual bool IsRenderer() const = 0;
61 virtual bool IsBrowserSideNavigation() const = 0;
62
63 // Returns the renderer process ID associated with the request. Returns -1 for
64 // browser side navigation requests. Even if the ResourceMessageFilter has
65 // been destroyed, this method of renderer type request info returns the
66 // valid process ID which was assigned to the renderer process of the filter.
67 virtual int GetChildID() const = 0;
68
69 // Returns the filter for sending IPC messages to the renderer process. This
70 // may return null if the process eixted. This method is available only for
71 // renderer requests.
72 virtual BrowserMessageFilter* GetFilter() const = 0;
73
74 // Returns the ResourceContext and URLRequestContext associated to the
75 // request. Currently this method is available only for renderer requests.
76 // The caller must check if the filter is still valid by calling GetFilter()
77 // in advance.
78 virtual void GetContexts(ResourceType resource_type,
79 ResourceContext** resource_context,
80 net::URLRequestContext** request_context) const = 0;
81
82 // Returns the ChromeAppCacheService associated with the request. Currently
83 // this method is available only for renderer requests. The caller must check
84 // if the filter is still valid by calling GetFilter() in advance.
85 virtual ChromeAppCacheService* appcache_service() const = 0;
86
87 // Returns the ChromeBlobStorageContext associated with the request. Currently
88 // this method is available only for renderer requests. The caller must check
89 // if the filter is still valid by calling GetFilter() in advance.
90 virtual ChromeBlobStorageContext* blob_storage_context() const = 0;
91
92 // Returns the FileSystemContext associated with the request. Currently this
93 // method is available only for renderer requests. The caller must check
94 // if the filter is still valid by calling GetFilter() in advance.
95 virtual storage::FileSystemContext* file_system_context() const = 0;
96
97 // Returns the ServiceWorkerContext associated with the request. Currently
98 // this method is available for renderer requests and browser side navigation
99 // requests. For renderer requests, the caller must check if the filter is
100 // still valid by calling GetFilter() in advance.
101 virtual ServiceWorkerContextWrapper* service_worker_context() const = 0;
102 };
103
104 } // namespace content
105
106 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUESTER_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698