diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 02:21:21 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 02:21:21 +0000 |
commit | 1ded764281537e5c5539b69a62d347f41900067f (patch) | |
tree | 5e7df728ff6ea8ef451df41490b7bd5519e8e738 | |
parent | 40ded3df5caebd375b0431d3165e1c11768ec767 (diff) | |
download | chromium_src-1ded764281537e5c5539b69a62d347f41900067f.zip chromium_src-1ded764281537e5c5539b69a62d347f41900067f.tar.gz chromium_src-1ded764281537e5c5539b69a62d347f41900067f.tar.bz2 |
Replace more uses of ChromeURLRequestContext/URLRequestContextGetter in content with ResourceContext
BUG=78596
TEST=none
Review URL: http://codereview.chromium.org/6882016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82219 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 2 | ||||
-rw-r--r-- | content/browser/appcache/appcache_dispatcher_host.cc | 27 | ||||
-rw-r--r-- | content/browser/appcache/appcache_dispatcher_host.h | 19 | ||||
-rw-r--r-- | content/browser/file_system/file_system_dispatcher_host.cc | 30 | ||||
-rw-r--r-- | content/browser/file_system/file_system_dispatcher_host.h | 32 | ||||
-rw-r--r-- | content/browser/renderer_host/browser_render_process_host.cc | 10 | ||||
-rw-r--r-- | content/browser/renderer_host/pepper_message_filter.cc | 13 | ||||
-rw-r--r-- | content/browser/renderer_host/pepper_message_filter.h | 11 | ||||
-rw-r--r-- | content/browser/resource_context.cc | 28 | ||||
-rw-r--r-- | content/browser/resource_context.h | 12 | ||||
-rw-r--r-- | content/browser/worker_host/worker_message_filter.cc | 7 | ||||
-rw-r--r-- | content/browser/worker_host/worker_message_filter.h | 2 | ||||
-rw-r--r-- | content/browser/worker_host/worker_process_host.cc | 12 | ||||
-rw-r--r-- | content/browser/worker_host/worker_process_host.h | 8 | ||||
-rw-r--r-- | content/browser/worker_host/worker_service.cc | 10 | ||||
-rw-r--r-- | content/browser/worker_host/worker_service.h | 1 |
16 files changed, 119 insertions, 105 deletions
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 1d2ee66..3419efb 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -311,6 +311,8 @@ void ProfileIOData::LazyInitialize() const { blob_storage_context_ = profile_params_->blob_storage_context; file_system_context_ = profile_params_->file_system_context; + resource_context_.set_host_resolver(io_thread_globals->host_resolver.get()); + resource_context_.set_request_context(main_request_context_); resource_context_.set_database_tracker(database_tracker_); resource_context_.set_appcache_service(appcache_service_); resource_context_.set_blob_storage_context(blob_storage_context_); diff --git a/content/browser/appcache/appcache_dispatcher_host.cc b/content/browser/appcache/appcache_dispatcher_host.cc index b4dc118..955b4fc 100644 --- a/content/browser/appcache/appcache_dispatcher_host.cc +++ b/content/browser/appcache/appcache_dispatcher_host.cc @@ -8,24 +8,16 @@ #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "content/browser/appcache/chrome_appcache_service.h" +#include "content/browser/resource_context.h" #include "content/common/appcache_messages.h" AppCacheDispatcherHost::AppCacheDispatcherHost( - net::URLRequestContext* request_context, + const content::ResourceContext* resource_context, int process_id) : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), - request_context_(request_context), + resource_context_(resource_context), process_id_(process_id) { - DCHECK(request_context_.get()); -} - -AppCacheDispatcherHost::AppCacheDispatcherHost( - net::URLRequestContextGetter* request_context_getter, - int process_id) - : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), - request_context_getter_(request_context_getter), - process_id_(process_id) { - DCHECK(request_context_getter_.get()); + DCHECK(resource_context_); } AppCacheDispatcherHost::~AppCacheDispatcherHost() {} @@ -33,16 +25,9 @@ AppCacheDispatcherHost::~AppCacheDispatcherHost() {} void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { BrowserMessageFilter::OnChannelConnected(peer_pid); - DCHECK(request_context_.get() || request_context_getter_.get()); - // Get the AppCacheService (it can only be accessed from IO thread). - net::URLRequestContext* context = request_context_.get(); - if (!context) - context = request_context_getter_->GetURLRequestContext(); - appcache_service_ = - static_cast<ChromeURLRequestContext*>(context)->appcache_service(); - request_context_ = NULL; - request_context_getter_ = NULL; + appcache_service_ = resource_context_->appcache_service(); + resource_context_ = NULL; if (appcache_service_.get()) { backend_impl_.Initialize( diff --git a/content/browser/appcache/appcache_dispatcher_host.h b/content/browser/appcache/appcache_dispatcher_host.h index 8ff8044..776ef04 100644 --- a/content/browser/appcache/appcache_dispatcher_host.h +++ b/content/browser/appcache/appcache_dispatcher_host.h @@ -17,11 +17,9 @@ #include "webkit/appcache/appcache_backend_impl.h" class ChromeAppCacheService; - -namespace net { -class URLRequestContext; -class URLRequestContextGetter; -} // namespace net +namespace content { +class ResourceContext; +} // namespace content // Handles appcache related messages sent to the main browser process from // its child processes. There is a distinct host for each child process. @@ -29,14 +27,8 @@ class URLRequestContextGetter; // WorkerProcessHost create an instance and delegates calls to it. class AppCacheDispatcherHost : public BrowserMessageFilter { public: - // Constructor for use on the IO thread. - AppCacheDispatcherHost(net::URLRequestContext* request_context, - int process_id); - - // Constructor for use on the UI thread. - AppCacheDispatcherHost(net::URLRequestContextGetter* request_context_getter, + AppCacheDispatcherHost(const content::ResourceContext* resource_context, int process_id); - ~AppCacheDispatcherHost(); // BrowserIOMessageFilter implementation @@ -80,8 +72,7 @@ class AppCacheDispatcherHost : public BrowserMessageFilter { // Temporary until OnChannelConnected() can be called from the IO thread, // which will extract the AppCacheService from the net::URLRequestContext. - scoped_refptr<net::URLRequestContext> request_context_; - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; + const content::ResourceContext* resource_context_; scoped_ptr<appcache::GetStatusCallback> get_status_callback_; scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; diff --git a/content/browser/file_system/file_system_dispatcher_host.cc b/content/browser/file_system/file_system_dispatcher_host.cc index 2bc89a8..a3ec0b7 100644 --- a/content/browser/file_system/file_system_dispatcher_host.cc +++ b/content/browser/file_system/file_system_dispatcher_host.cc @@ -14,6 +14,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" +#include "content/browser/resource_context.h" #include "content/common/file_system_messages.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_platform_file.h" @@ -100,10 +101,15 @@ class BrowserFileSystemCallbackDispatcher int request_id_; }; -FileSystemDispatcherHost::FileSystemDispatcherHost(Profile* profile) - : context_(profile->GetFileSystemContext()), - host_content_settings_map_(profile->GetHostContentSettingsMap()), - request_context_getter_(profile->GetRequestContext()) { +FileSystemDispatcherHost::FileSystemDispatcherHost( + const content::ResourceContext* resource_context, + HostContentSettingsMap* host_content_settings_map) + : context_(NULL), + host_content_settings_map_(host_content_settings_map), + resource_context_(resource_context), + request_context_(NULL) { + DCHECK(resource_context_); + DCHECK(host_content_settings_map_); } FileSystemDispatcherHost::FileSystemDispatcherHost( @@ -111,7 +117,11 @@ FileSystemDispatcherHost::FileSystemDispatcherHost( fileapi::FileSystemContext* file_system_context) : context_(file_system_context), host_content_settings_map_(request_context->host_content_settings_map()), + resource_context_(NULL), request_context_(request_context) { + DCHECK(request_context_); + DCHECK(host_content_settings_map_); + DCHECK(context_); } FileSystemDispatcherHost::~FileSystemDispatcherHost() { @@ -120,11 +130,15 @@ FileSystemDispatcherHost::~FileSystemDispatcherHost() { void FileSystemDispatcherHost::OnChannelConnected(int32 peer_pid) { BrowserMessageFilter::OnChannelConnected(peer_pid); - if (request_context_getter_.get()) { - DCHECK(!request_context_.get()); - request_context_ = request_context_getter_->GetURLRequestContext(); + if (resource_context_) { + DCHECK(!request_context_); + request_context_ = resource_context_->request_context(); + DCHECK(!context_); + context_ = resource_context_->file_system_context(); + resource_context_ = NULL; } - DCHECK(request_context_.get()); + DCHECK(request_context_); + DCHECK(context_); } bool FileSystemDispatcherHost::OnMessageReceived( diff --git a/content/browser/file_system/file_system_dispatcher_host.h b/content/browser/file_system/file_system_dispatcher_host.h index 76767fe..440f20b 100644 --- a/content/browser/file_system/file_system_dispatcher_host.h +++ b/content/browser/file_system/file_system_dispatcher_host.h @@ -12,10 +12,6 @@ #include "content/browser/browser_message_filter.h" #include "webkit/fileapi/file_system_types.h" -namespace base { -class Time; -} - class ChromeURLRequestContext; class GURL; class HostContentSettingsMap; @@ -23,20 +19,30 @@ class Profile; class Receiver; class RenderMessageFilter; -namespace net { -class URLRequestContext; -class URLRequestContextGetter; -} // namespace net +namespace base { +class Time; +} + +namespace content { +class ResourceContext; +} namespace fileapi { class FileSystemContext; class FileSystemOperation; } +namespace net { +class URLRequestContext; +class URLRequestContextGetter; +} // namespace net + class FileSystemDispatcherHost : public BrowserMessageFilter { public: // Used by the renderer. - explicit FileSystemDispatcherHost(Profile* profile); + FileSystemDispatcherHost( + const content::ResourceContext* resource_context, + HostContentSettingsMap* host_content_settings_map); // Used by the worker, since it has the context handy already. FileSystemDispatcherHost(ChromeURLRequestContext* request_context, fileapi::FileSystemContext* file_system_context); @@ -85,7 +91,7 @@ class FileSystemDispatcherHost : public BrowserMessageFilter { // Creates a new FileSystemOperation. fileapi::FileSystemOperation* GetNewOperation(int request_id); - scoped_refptr<fileapi::FileSystemContext> context_; + fileapi::FileSystemContext* context_; // Used to look up permissions. scoped_refptr<HostContentSettingsMap> host_content_settings_map_; @@ -94,10 +100,10 @@ class FileSystemDispatcherHost : public BrowserMessageFilter { typedef IDMap<fileapi::FileSystemOperation> OperationsMap; OperationsMap operations_; - // This holds the URLRequestContextGetter until Init() can be called from the + // This holds the ResourceContext until Init() can be called from the // IO thread, which will extract the net::URLRequestContext from it. - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; - scoped_refptr<net::URLRequestContext> request_context_; + const content::ResourceContext* resource_context_; + net::URLRequestContext* request_context_; DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcherHost); }; diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index b10ce64..cf81afd 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -463,7 +463,7 @@ void BrowserRenderProcessHost::CreateMessageFilters() { channel_->AddFilter(new AudioInputRendererHost()); channel_->AddFilter(new AudioRendererHost()); channel_->AddFilter( - new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); + new AppCacheDispatcherHost(&profile()->GetResourceContext(), id())); channel_->AddFilter(new ClipboardMessageFilter()); channel_->AddFilter( new DOMStorageMessageFilter(id(), profile()->GetWebKitContext(), @@ -476,9 +476,12 @@ void BrowserRenderProcessHost::CreateMessageFilters() { id(), profile()->GetGeolocationPermissionContext())); channel_->AddFilter(new GpuMessageFilter(id())); channel_->AddFilter(new PepperFileMessageFilter(id(), profile())); - channel_->AddFilter(new PepperMessageFilter(profile())); + channel_->AddFilter( + new PepperMessageFilter(&profile()->GetResourceContext())); channel_->AddFilter(new speech_input::SpeechInputDispatcherHost(id())); - channel_->AddFilter(new FileSystemDispatcherHost(profile())); + channel_->AddFilter( + new FileSystemDispatcherHost(&profile()->GetResourceContext(), + profile()->GetHostContentSettingsMap())); channel_->AddFilter(new device_orientation::MessageFilter()); channel_->AddFilter( new BlobMessageFilter(id(), profile()->GetBlobStorageContext())); @@ -495,7 +498,6 @@ void BrowserRenderProcessHost::CreateMessageFilters() { channel_->AddFilter( new WorkerMessageFilter( id(), - profile()->GetRequestContext(), &profile()->GetResourceContext(), g_browser_process->resource_dispatcher_host(), NewCallbackWithReturnValue( diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc index 1c79a90..061d1f4 100644 --- a/content/browser/renderer_host/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper_message_filter.cc @@ -8,9 +8,9 @@ #include "base/process_util.h" #include "base/threading/worker_pool.h" #include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/profiles/profile.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/browser_render_process_host.h" +#include "content/browser/resource_context.h" #include "content/common/pepper_messages.h" #include "net/base/address_list.h" #include "net/base/host_port_pair.h" @@ -34,9 +34,10 @@ COMPILE_ASSERT(sizeof(reinterpret_cast<PP_Flash_NetAddress*>(0)->data) >= const PP_Flash_NetAddress kInvalidNetAddress = { 0 }; -PepperMessageFilter::PepperMessageFilter(Profile* profile) - : profile_(profile), - request_context_(profile_->GetRequestContext()) { +PepperMessageFilter::PepperMessageFilter( + const content::ResourceContext* resource_context) + : resource_context_(resource_context) { + DCHECK(resource_context_); } PepperMessageFilter::~PepperMessageFilter() {} @@ -173,13 +174,11 @@ void PepperMessageFilter::OnConnectTcp(int routing_id, uint16 port) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - net::URLRequestContext* req_context = - request_context_->GetURLRequestContext(); net::HostResolver::RequestInfo request_info(net::HostPortPair(host, port)); // The lookup request will delete itself on completion. LookupRequest* lookup_request = - new LookupRequest(this, req_context->host_resolver(), + new LookupRequest(this, resource_context_->host_resolver(), routing_id, request_id, request_info); lookup_request->Start(); } diff --git a/content/browser/renderer_host/pepper_message_filter.h b/content/browser/renderer_host/pepper_message_filter.h index 35adc97..3b7bc81 100644 --- a/content/browser/renderer_host/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper_message_filter.h @@ -13,16 +13,18 @@ #include "content/browser/browser_message_filter.h" #include "ppapi/c/private/ppb_flash_net_connector.h" -class Profile; +namespace content { +class ResourceContext; +} namespace net { class AddressList; -class URLRequestContextGetter; } class PepperMessageFilter : public BrowserMessageFilter { public: - explicit PepperMessageFilter(Profile* profile); + explicit PepperMessageFilter( + const content::ResourceContext* resource_context); virtual ~PepperMessageFilter(); private: @@ -62,8 +64,7 @@ class PepperMessageFilter : public BrowserMessageFilter { PP_Flash_NetAddress addr); #endif // ENABLE_FLAPPER_HACKS - Profile* profile_; - scoped_refptr<net::URLRequestContextGetter> request_context_; + const content::ResourceContext* const resource_context_; }; #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_MESSAGE_FILTER_H_ diff --git a/content/browser/resource_context.cc b/content/browser/resource_context.cc index 849cd1d..199f5dc 100644 --- a/content/browser/resource_context.cc +++ b/content/browser/resource_context.cc @@ -11,7 +11,9 @@ namespace content { ResourceContext::ResourceContext() - : appcache_service_(NULL), + : host_resolver_(NULL), + request_context_(NULL), + appcache_service_(NULL), database_tracker_(NULL), file_system_context_(NULL), blob_storage_context_(NULL) { @@ -20,6 +22,30 @@ ResourceContext::ResourceContext() ResourceContext::~ResourceContext() {} +net::HostResolver* ResourceContext::host_resolver() const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + EnsureInitialized(); + return host_resolver_; +} + +void ResourceContext::set_host_resolver( + net::HostResolver* host_resolver) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + host_resolver_ = host_resolver; +} + +net::URLRequestContext* ResourceContext::request_context() const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + EnsureInitialized(); + return request_context_; +} + +void ResourceContext::set_request_context( + net::URLRequestContext* request_context) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + request_context_ = request_context; +} + ChromeAppCacheService* ResourceContext::appcache_service() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); EnsureInitialized(); diff --git a/content/browser/resource_context.h b/content/browser/resource_context.h index 77eaf5c..68994b5 100644 --- a/content/browser/resource_context.h +++ b/content/browser/resource_context.h @@ -13,6 +13,10 @@ class ChromeBlobStorageContext; namespace fileapi { class FileSystemContext; } // namespace fileapi +namespace net { +class HostResolver; +class URLRequestContext; +} // namespace net namespace webkit_database { class DatabaseTracker; } // namespace webkit_database @@ -27,6 +31,12 @@ class ResourceContext { public: virtual ~ResourceContext(); + net::HostResolver* host_resolver() const; + void set_host_resolver(net::HostResolver* host_resolver); + + net::URLRequestContext* request_context() const; + void set_request_context(net::URLRequestContext* request_context); + ChromeAppCacheService* appcache_service() const; void set_appcache_service(ChromeAppCacheService* service); @@ -45,6 +55,8 @@ class ResourceContext { private: virtual void EnsureInitialized() const = 0; + net::HostResolver* host_resolver_; + net::URLRequestContext* request_context_; ChromeAppCacheService* appcache_service_; webkit_database::DatabaseTracker* database_tracker_; fileapi::FileSystemContext* file_system_context_; diff --git a/content/browser/worker_host/worker_message_filter.cc b/content/browser/worker_host/worker_message_filter.cc index 2c470f8..0ed58a6 100644 --- a/content/browser/worker_host/worker_message_filter.cc +++ b/content/browser/worker_host/worker_message_filter.cc @@ -10,16 +10,13 @@ #include "content/browser/worker_host/worker_service.h" #include "content/common/view_messages.h" #include "content/common/worker_messages.h" -#include "net/url_request/url_request_context_getter.h" WorkerMessageFilter::WorkerMessageFilter( int render_process_id, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext* resource_context, ResourceDispatcherHost* resource_dispatcher_host, CallbackWithReturnValue<int>::Type* next_routing_id) : render_process_id_(render_process_id), - request_context_getter_(request_context_getter), resource_context_(resource_context), resource_dispatcher_host_(resource_dispatcher_host), next_routing_id_(next_routing_id) { @@ -85,7 +82,7 @@ void WorkerMessageFilter::OnCreateWorker( *route_id = params.route_id != MSG_ROUTING_NONE ? params.route_id : next_routing_id_->Run(); WorkerService::GetInstance()->CreateWorker( - params, *route_id, this, request_context_getter_, *resource_context_); + params, *route_id, this, *resource_context_); } void WorkerMessageFilter::OnLookupSharedWorker( @@ -96,7 +93,7 @@ void WorkerMessageFilter::OnLookupSharedWorker( *route_id = next_routing_id_->Run(); bool incognito = static_cast<ChromeURLRequestContext*>( - request_context_getter_->GetURLRequestContext())->is_incognito(); + resource_context_->request_context())->is_incognito(); WorkerService::GetInstance()->LookupSharedWorker( params, *route_id, this, incognito, exists, url_error); } diff --git a/content/browser/worker_host/worker_message_filter.h b/content/browser/worker_host/worker_message_filter.h index 19be385..ebdbf31 100644 --- a/content/browser/worker_host/worker_message_filter.h +++ b/content/browser/worker_host/worker_message_filter.h @@ -25,7 +25,6 @@ class WorkerMessageFilter : public BrowserMessageFilter { // OnChannelClosing. WorkerMessageFilter( int render_process_id, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext* resource_context, ResourceDispatcherHost* resource_dispatcher_host, CallbackWithReturnValue<int>::Type* next_routing_id); @@ -57,7 +56,6 @@ class WorkerMessageFilter : public BrowserMessageFilter { void OnCreateMessagePort(int* route_id, int* message_port_id); int render_process_id_; - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; const content::ResourceContext* const resource_context_; ResourceDispatcherHost* resource_dispatcher_host_; diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index 683c622..1a9670b 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -85,16 +85,13 @@ class WorkerCrashTask : public Task { }; WorkerProcessHost::WorkerProcessHost( - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext* resource_context, ResourceDispatcherHost* resource_dispatcher_host) : BrowserChildProcessHost(WORKER_PROCESS), - request_context_getter_(request_context_getter), resource_context_(resource_context), resource_dispatcher_host_(resource_dispatcher_host) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(resource_context); - DCHECK(request_context_getter); } WorkerProcessHost::~WorkerProcessHost() { @@ -219,13 +216,12 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { worker_message_filter_ = new WorkerMessageFilter( render_process_id, - request_context_getter_, resource_context_, resource_dispatcher_host_, NewCallbackWithReturnValue( WorkerService::GetInstance(), &WorkerService::next_worker_route_id)); AddFilter(worker_message_filter_); - AddFilter(new AppCacheDispatcherHost(chrome_url_context, id())); + AddFilter(new AppCacheDispatcherHost(resource_context_, id())); AddFilter(new FileSystemDispatcherHost( chrome_url_context, resource_context_->file_system_context())); AddFilter(new FileUtilitiesMessageFilter(id())); @@ -488,7 +484,7 @@ void WorkerProcessHost::UpdateTitle() { ChromeURLRequestContext* WorkerProcessHost::GetChromeURLRequestContext() { return static_cast<ChromeURLRequestContext*>( - request_context_getter_->GetURLRequestContext()); + resource_context_->request_context()); } void WorkerProcessHost::DocumentDetached(WorkerMessageFilter* filter, @@ -519,7 +515,6 @@ WorkerProcessHost::WorkerInstance::WorkerInstance( int parent_process_id, int parent_appcache_host_id, int64 main_resource_appcache_id, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext& resource_context) : url_(url), shared_(shared), @@ -530,10 +525,8 @@ WorkerProcessHost::WorkerInstance::WorkerInstance( parent_process_id_(parent_process_id), parent_appcache_host_id_(parent_appcache_host_id), main_resource_appcache_id_(main_resource_appcache_id), - request_context_getter_(request_context_getter), worker_document_set_(new WorkerDocumentSet()), resource_context_(&resource_context) { - DCHECK(request_context_getter_); DCHECK(resource_context_); } @@ -551,7 +544,6 @@ WorkerProcessHost::WorkerInstance::WorkerInstance( parent_process_id_(0), parent_appcache_host_id_(0), main_resource_appcache_id_(0), - request_context_getter_(NULL), worker_document_set_(new WorkerDocumentSet()), resource_context_(NULL) { } diff --git a/content/browser/worker_host/worker_process_host.h b/content/browser/worker_host/worker_process_host.h index cdcefb9..6f21b9a 100644 --- a/content/browser/worker_host/worker_process_host.h +++ b/content/browser/worker_host/worker_process_host.h @@ -43,7 +43,6 @@ class WorkerProcessHost : public BrowserChildProcessHost { int parent_process_id, int parent_appcache_host_id, int64 main_resource_appcache_id, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext& resource_context); // Used for pending instances. Rest of the parameters are ignored. WorkerInstance(const GURL& url, @@ -97,9 +96,6 @@ class WorkerProcessHost : public BrowserChildProcessHost { WorkerDocumentSet* worker_document_set() const { return worker_document_set_; } - net::URLRequestContextGetter* request_context_getter() const { - return request_context_getter_; - } const content::ResourceContext& resource_context() const { return *resource_context_; } @@ -115,14 +111,12 @@ class WorkerProcessHost : public BrowserChildProcessHost { int parent_process_id_; int parent_appcache_host_id_; int64 main_resource_appcache_id_; - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; FilterList filters_; scoped_refptr<WorkerDocumentSet> worker_document_set_; const content::ResourceContext* const resource_context_; }; WorkerProcessHost( - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext* resource_context, ResourceDispatcherHost* resource_dispatcher_host); ~WorkerProcessHost(); @@ -187,8 +181,6 @@ class WorkerProcessHost : public BrowserChildProcessHost { Instances instances_; - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; - const content::ResourceContext* const resource_context_; // A reference to the filter associated with this worker process. We need to diff --git a/content/browser/worker_host/worker_service.cc b/content/browser/worker_host/worker_service.cc index 4ff737f..4e663e1 100644 --- a/content/browser/worker_host/worker_service.cc +++ b/content/browser/worker_host/worker_service.cc @@ -11,6 +11,7 @@ #include "base/sys_info.h" #include "base/threading/thread.h" #include "chrome/common/chrome_switches.h" +#include "content/browser/resource_context.h" #include "content/browser/worker_host/worker_message_filter.h" #include "content/browser/worker_host/worker_process_host.h" #include "content/common/view_messages.h" @@ -73,11 +74,10 @@ void WorkerService::CreateWorker( const ViewHostMsg_CreateWorker_Params& params, int route_id, WorkerMessageFilter* filter, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext& resource_context) { // TODO(willchan): Eliminate the need for this downcast. - ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( - request_context_getter->GetURLRequestContext()); + bool is_incognito = static_cast<ChromeURLRequestContext*>( + resource_context.request_context())->is_incognito(); // Generate a unique route id for the browser-worker communication that's // unique among all worker processes. That way when the worker process sends @@ -86,13 +86,12 @@ void WorkerService::CreateWorker( WorkerProcessHost::WorkerInstance instance( params.url, params.is_shared, - context->is_incognito(), + is_incognito, params.name, next_worker_route_id(), params.is_shared ? 0 : filter->render_process_id(), params.is_shared ? 0 : params.parent_appcache_host_id, params.is_shared ? params.script_resource_appcache_id : 0, - request_context_getter, resource_context); instance.AddFilter(filter, route_id); instance.worker_document_set()->Add( @@ -312,7 +311,6 @@ bool WorkerService::CreateWorkerFromInstance( if (!worker) { WorkerMessageFilter* first_filter = instance.filters().begin()->first; worker = new WorkerProcessHost( - instance.request_context_getter(), &instance.resource_context(), first_filter->resource_dispatcher_host()); // TODO(atwilson): This won't work if the message is from a worker process. diff --git a/content/browser/worker_host/worker_service.h b/content/browser/worker_host/worker_service.h index 0648107..ff64d43 100644 --- a/content/browser/worker_host/worker_service.h +++ b/content/browser/worker_host/worker_service.h @@ -30,7 +30,6 @@ class WorkerService { void CreateWorker(const ViewHostMsg_CreateWorker_Params& params, int route_id, WorkerMessageFilter* filter, - net::URLRequestContextGetter* request_context_getter, const content::ResourceContext& resource_context); void LookupSharedWorker(const ViewHostMsg_CreateWorker_Params& params, int route_id, |