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

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

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: make ResourceRequestInfoImpl::requester_info() non-const 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 #include "content/browser/loader/resource_requester_info.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "content/browser/appcache/chrome_appcache_service.h"
10 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
11 #include "content/browser/loader/resource_message_filter.h"
12 #include "content/browser/service_worker/service_worker_context_wrapper.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/resource_context.h"
15 #include "storage/browser/fileapi/file_system_context.h"
16
17 namespace content {
18
19 ResourceRequesterInfo::ResourceRequesterInfo(
20 RequesterType type,
21 int child_id,
22 ChromeAppCacheService* appcache_service,
23 ChromeBlobStorageContext* blob_storage_context,
24 storage::FileSystemContext* file_system_context,
25 ServiceWorkerContextWrapper* service_worker_context,
26 const GetContextsCallback& get_contexts_callback)
27 : type_(type),
28 child_id_(child_id),
29 appcache_service_(appcache_service),
30 blob_storage_context_(blob_storage_context),
31 file_system_context_(file_system_context),
32 service_worker_context_(service_worker_context),
33 get_contexts_callback_(get_contexts_callback) {}
34
35 ResourceRequesterInfo::~ResourceRequesterInfo() {}
36
37 void ResourceRequesterInfo::set_filter(
38 base::WeakPtr<ResourceMessageFilter> filter) {
39 DCHECK_CURRENTLY_ON(BrowserThread::IO);
40 DCHECK_EQ(RequesterType::RENDERER, type_);
41 filter_ = filter;
42 }
43
44 void ResourceRequesterInfo::GetContexts(
45 ResourceType resource_type,
46 ResourceContext** resource_context,
47 net::URLRequestContext** request_context) const {
48 get_contexts_callback_.Run(resource_type, resource_context, request_context);
49 }
50
51 scoped_refptr<ResourceRequesterInfo> ResourceRequesterInfo::CreateForRenderer(
52 int child_id,
53 ChromeAppCacheService* appcache_service,
54 ChromeBlobStorageContext* blob_storage_context,
55 storage::FileSystemContext* file_system_context,
56 ServiceWorkerContextWrapper* service_worker_context,
57 const GetContextsCallback& get_contexts_callback) {
58 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo(
59 RequesterType::RENDERER, child_id, appcache_service, blob_storage_context,
60 file_system_context, service_worker_context, get_contexts_callback));
61 }
62
63 scoped_refptr<ResourceRequesterInfo>
64 ResourceRequesterInfo::CreateForRendererTesting(int child_id) {
65 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo(
66 RequesterType::RENDERER, child_id, nullptr /* appcache_service */,
67 nullptr /* blob_storage_context */, nullptr /* file_system_context */,
68 nullptr /*service_worker_context */, GetContextsCallback()));
69 }
70
71 scoped_refptr<ResourceRequesterInfo>
72 ResourceRequesterInfo::CreateForBrowserSideNavigation(
73 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) {
74 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo(
75 RequesterType::BROWSER_SIDE_NAVIGATION, -1,
76 nullptr /* appcache_service */, nullptr /* blob_storage_context */,
77 nullptr /* file_system_context */, service_worker_context.get(),
78 GetContextsCallback()));
79 }
80
81 scoped_refptr<ResourceRequesterInfo>
82 ResourceRequesterInfo::CreateForDownloadOrPageSave(int child_id) {
83 return scoped_refptr<ResourceRequesterInfo>(new ResourceRequesterInfo(
84 RequesterType::DOWNLOAD_OR_PAGE_SAVE, child_id,
85 nullptr /* appcache_service */, nullptr /* blob_storage_context */,
86 nullptr /* file_system_context */, nullptr /*service_worker_context */,
87 GetContextsCallback()));
88 }
89
90 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698