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

Unified Diff: content/browser/loader/resource_requester_info.h

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: incorporated yhirano & kinuko'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 side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_requester_info.h
diff --git a/content/browser/loader/resource_requester_info.h b/content/browser/loader/resource_requester_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..61462db9660943bca1b3a51af2469fce676a3b25
--- /dev/null
+++ b/content/browser/loader/resource_requester_info.h
@@ -0,0 +1,96 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_LOADER_RESOURCE_REQUESTER_INFO_H_
+#define CONTENT_BROWSER_LOADER_RESOURCE_REQUESTER_INFO_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/common/content_export.h"
+#include "content/public/common/resource_type.h"
+
+namespace net {
+class URLRequestContext;
+} // namespace net
+
+namespace storage {
+class FileSystemContext;
+} // namespace storage
+
+namespace content {
+class BrowserMessageFilter;
+class ChromeAppCacheService;
+class ChromeBlobStorageContext;
+class ResourceContext;
+class ResourceMessageFilter;
+class ServiceWorkerContextWrapper;
+
+// This class represents the type of resource request.
+// Currently there are three types:
+// - Resource request from renderer processes.
+// - Resource request for browser side navigation. (PlzNavigate).
+// - Download request of page save request.
mmenke 2016/11/11 21:19:59 A downloads also use this path, no?
horo 2016/11/14 08:28:50 It was a typo. Fixed.
+class CONTENT_EXPORT ResourceRequesterInfo {
+ public:
+ // Creates a ResourceRequesterInfo for renderer process initiated request.
+ // |filter| can't be null.
+ static std::unique_ptr<ResourceRequesterInfo> CreateForRenderer(
mmenke 2016/11/11 21:19:59 include <memory>
horo 2016/11/14 08:28:50 Done.
+ base::WeakPtr<ResourceMessageFilter> filter);
+
+ // Creates a ResourceRequesterInfo for renderer process initiated request
+ // without ResourceMessageFilter for unittests.
+ static std::unique_ptr<ResourceRequesterInfo> CreateForRendererTesting(
+ int child_id);
+
+ // Creates a ResourceRequesterInfo for browser side navigation request which
mmenke 2016/11/11 21:19:59 Need an article here, or make it plural. Same for
horo 2016/11/14 08:28:50 Done.
+ // is initiated by browser process.
+ static std::unique_ptr<ResourceRequesterInfo> CreateForBrowserSideNavigation(
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
+
+ // Creates a ResourceRequesterInfo for download or page save request.
+ static std::unique_ptr<ResourceRequesterInfo> CreateForDownloadOrPageSave(
+ int child_id);
+
+ virtual ~ResourceRequesterInfo() {}
+
+ virtual std::unique_ptr<ResourceRequesterInfo> clone() const = 0;
+
+ virtual bool IsRenderer() const = 0;
+ virtual bool IsBrowserSideNavigation() const = 0;
+
+ // Returns the renderer process associated with the request. Returns -1 for
+ // browser side navigation requests.
+ virtual int child_id() const = 0;
mmenke 2016/11/11 21:19:59 virtual methods shouldn't use this naming scheme.
horo 2016/11/14 08:28:50 Done.
+
+ // Returns the filter for sending IPC messages to the renderer process. This
+ // may return null if the process eixted. This method is available only for
+ // renderer requests.
+ virtual BrowserMessageFilter* filter() const = 0;
+
+ // Returns the ResourceContext and URLRequestContext associated to the
+ // request. Currently this method is available only for renderer requests.
+ virtual void GetContexts(ResourceType resource_type,
+ ResourceContext** resource_context,
+ net::URLRequestContext** request_context) const = 0;
mmenke 2016/11/11 21:19:59 This method and those below it all crash if the fi
horo 2016/11/14 08:28:50 Done.
+
+ // Returns the ChromeAppCacheService associated with the request. Currently
+ // this method is available only for renderer requests.
+ virtual ChromeAppCacheService* appcache_service() const = 0;
+
+ // Returns the ChromeBlobStorageContext associated with the request. Currently
+ // this method is available only for renderer requests.
+ virtual ChromeBlobStorageContext* blob_storage_context() const = 0;
+
+ // Returns the FileSystemContext associated with the request. Currently this
+ // method is available only for renderer requests.
+ virtual storage::FileSystemContext* file_system_context() const = 0;
+
+ // Returns the ServiceWorkerContext associated with the request. Currently
+ // this method is available for renderer requests and browser side navigation
+ // requests.
+ virtual ServiceWorkerContextWrapper* service_worker_context() const = 0;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUESTER_INFO_H_

Powered by Google App Engine
This is Rietveld 408576698