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

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

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: incorporated 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_message_filter.h
diff --git a/content/browser/loader/resource_message_filter.h b/content/browser/loader/resource_message_filter.h
index bcc07138851c51c5c92be8f5e46738ff5e55150c..55c143cba8b519356e93d0b6a9d8d28d90ac78cb 100644
--- a/content/browser/loader/resource_message_filter.h
+++ b/content/browser/loader/resource_message_filter.h
@@ -31,6 +31,7 @@ namespace content {
class ChromeAppCacheService;
class ChromeBlobStorageContext;
class ResourceContext;
+class ResourceRequesterInfo;
class ServiceWorkerContextWrapper;
// This class filters out incoming IPC messages for network requests and
@@ -47,13 +48,9 @@ class CONTENT_EXPORT ResourceMessageFilter
ResourceContext**,
net::URLRequestContext**)> GetContextsCallback;
- // |appcache_service|, |blob_storage_context|, |file_system_context| may be
- // NULL in unittests or for requests from the (NPAPI) plugin process.
- // The |origin_pid| argument to |get_contexts_callback| is not used
- // (and may be invalid) for requests that are NOT from the NPAPI plugin
- // process.
+ // |appcache_service|, |blob_storage_context|, |file_system_context|,
+ // |service_worker_context| may be NULL in unittests.
kinuko 2016/11/21 13:36:25 nit: NULL -> nullptr would be probably more usefu
horo 2016/11/21 14:57:59 Done.
ResourceMessageFilter(int child_id,
- int process_type,
ChromeAppCacheService* appcache_service,
ChromeBlobStorageContext* blob_storage_context,
storage::FileSystemContext* file_system_context,
@@ -61,36 +58,11 @@ class CONTENT_EXPORT ResourceMessageFilter
const GetContextsCallback& get_contexts_callback);
// BrowserMessageFilter implementation.
+ void OnFilterAdded(IPC::Channel* channel) override;
void OnChannelClosing() override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() const override;
- void GetContexts(ResourceType resource_type,
- ResourceContext** resource_context,
- net::URLRequestContext** request_context);
-
- // Returns the net::URLRequestContext for the given request.
- net::URLRequestContext* GetURLRequestContext(ResourceType request_type);
-
- ChromeAppCacheService* appcache_service() const {
- return appcache_service_.get();
- }
-
- ChromeBlobStorageContext* blob_storage_context() const {
- return blob_storage_context_.get();
- }
-
- storage::FileSystemContext* file_system_context() const {
- return file_system_context_.get();
- }
-
- ServiceWorkerContextWrapper* service_worker_context() const {
- return service_worker_context_.get();
- }
-
- int child_id() const { return child_id_; }
- int process_type() const { return process_type_; }
-
base::WeakPtr<ResourceMessageFilter> GetWeakPtr();
void CreateLoaderAndStart(
@@ -103,27 +75,30 @@ class CONTENT_EXPORT ResourceMessageFilter
int32_t request_id,
const ResourceRequest& request,
const SyncLoadCallback& callback) override;
+ int child_id() const;
protected:
+ friend class URLLoaderFactoryImplTest;
+
// Protected destructor so that we can be overriden in tests.
~ResourceMessageFilter() override;
+ // In unit tests, this method has to be called to initialize |requester_info_|
+ // after creating the ResourceMessageFilter.
kinuko 2016/11/21 13:36:26 nit: maybe just comment about what this does here
horo 2016/11/21 14:57:59 Done.
+ void InitializeOnIOThread();
+
private:
friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
friend class base::DeleteHelper<ResourceMessageFilter>;
+ friend class AsyncResourceHandlerTest;
+ friend class ResourceDispatcherHostTest;
- // The ID of the child process.
- int child_id_;
+ const ResourceRequesterInfo* requester_info() const {
+ return requester_info_.get();
+ }
- int process_type_;
bool is_channel_closed_;
-
- scoped_refptr<ChromeAppCacheService> appcache_service_;
- scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
- scoped_refptr<storage::FileSystemContext> file_system_context_;
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
-
- GetContextsCallback get_contexts_callback_;
+ scoped_refptr<ResourceRequesterInfo> requester_info_;
// This must come last to make sure weak pointers are invalidated first.
base::WeakPtrFactory<ResourceMessageFilter> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698