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

Unified Diff: content/browser/worker_host/worker_process_host.cc

Issue 10916132: AppCache and StoragePartition'ing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months 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/worker_host/worker_process_host.cc
===================================================================
--- content/browser/worker_host/worker_process_host.cc (revision 154786)
+++ content/browser/worker_host/worker_process_host.cc (working copy)
@@ -23,6 +23,7 @@
#include "content/browser/debugger/worker_devtools_manager.h"
#include "content/browser/debugger/worker_devtools_message_filter.h"
#include "content/browser/fileapi/fileapi_message_filter.h"
+#include "content/browser/in_process_webkit/indexed_db_context_impl.h"
#include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
#include "content/browser/mime_registry_message_filter.h"
#include "content/browser/renderer_host/database_message_filter.h"
@@ -31,6 +32,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
#include "content/browser/resource_context_impl.h"
+#include "content/browser/storage_partition_impl.h"
#include "content/browser/worker_host/message_port_service.h"
#include "content/browser/worker_host/worker_message_filter.h"
#include "content/browser/worker_host/worker_service_impl.h"
@@ -58,6 +60,7 @@
using content::ResourceContext;
using content::ResourceMessageFilter;
using content::SocketStreamDispatcherHost;
+using content::StoragePartitionImpl;
using content::UserMetricsAction;
using content::WorkerDevToolsManager;
using content::WorkerServiceImpl;
@@ -94,10 +97,13 @@
host->GetDelegate()->WorkerCrashed();
}
-WorkerProcessHost::WorkerProcessHost(ResourceContext* resource_context)
- : resource_context_(resource_context) {
+WorkerProcessHost::WorkerProcessHost(ResourceContext* resource_context,
+ StoragePartitionImpl* storage_partition)
+ : resource_context_(resource_context),
+ storage_partition_(storage_partition) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(resource_context);
+ DCHECK(storage_partition);
process_.reset(
new BrowserChildProcessHostImpl(content::PROCESS_TYPE_WORKER, this));
}
@@ -201,7 +207,7 @@
cmd_line);
fileapi::FileSystemContext* file_system_context =
- GetFileSystemContextForResourceContext(resource_context_);
+ storage_partition_->GetFileSystemContext();
ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker(
process_->GetData().id, render_process_id);
if (!CommandLine::ForCurrentProcess()->HasSwitch(
@@ -249,34 +255,43 @@
}
void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
+ // TODO(michaeln): Put ChromeBlobStorageContext in StorageParition too.
+ ChromeBlobStorageContext* blob_storage_context =
+ content::GetChromeBlobStorageContextForResourceContext(
+ resource_context_);
+
+ // TODO(michaeln): this is not correct, workers will not be using the
+ // isolated/partitioned context.
net::URLRequestContext* request_context =
resource_context_->GetRequestContext();
ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_,
+ static_cast<ChromeAppCacheService*>(
awong 2012/09/06 22:29:27 Also unnecessary with covariant return...
+ storage_partition_->GetAppCacheService()),
+ blob_storage_context,
new URLRequestContextSelector(request_context));
process_->GetHost()->AddFilter(resource_message_filter);
worker_message_filter_ = new WorkerMessageFilter(
- render_process_id, resource_context_,
+ render_process_id, resource_context_, storage_partition_,
base::Bind(&WorkerServiceImpl::next_worker_route_id,
base::Unretained(WorkerServiceImpl::GetInstance())));
process_->GetHost()->AddFilter(worker_message_filter_);
process_->GetHost()->AddFilter(new AppCacheDispatcherHost(
static_cast<ChromeAppCacheService*>(
- ResourceContext::GetAppCacheService(resource_context_)),
+ storage_partition_->GetAppCacheService()),
process_->GetData().id));
process_->GetHost()->AddFilter(new FileAPIMessageFilter(
process_->GetData().id,
request_context,
- GetFileSystemContextForResourceContext(resource_context_),
- content::GetChromeBlobStorageContextForResourceContext(
- resource_context_)));
+ storage_partition_->GetFileSystemContext(),
+ blob_storage_context));
process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter(
process_->GetData().id));
process_->GetHost()->AddFilter(new MimeRegistryMessageFilter());
process_->GetHost()->AddFilter(new DatabaseMessageFilter(
- content::GetDatabaseTrackerForResourceContext(resource_context_)));
+ storage_partition_->GetDatabaseTracker()));
SocketStreamDispatcherHost* socket_stream_dispatcher_host =
new SocketStreamDispatcherHost(render_process_id,
@@ -286,7 +301,8 @@
new content::WorkerDevToolsMessageFilter(process_->GetData().id));
process_->GetHost()->AddFilter(new IndexedDBDispatcherHost(
process_->GetData().id,
- content::GetIndexedDBContextForResourceContext(resource_context_)));
+ static_cast<IndexedDBContextImpl*>(
+ storage_partition_->GetIndexedDBContext())));
}
void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
@@ -391,6 +407,8 @@
const string16& display_name,
unsigned long estimated_size,
bool* result) {
+ // FIXME: Should we introduce a SettingsContext abstraction for settings
+ // related things like this?
*result = content::GetContentClient()->browser()->AllowWorkerDatabase(
url, name, display_name, estimated_size, resource_context_,
GetRenderViewIDsForWorker(worker_route_id));
@@ -578,7 +596,8 @@
int worker_route_id,
int parent_process_id,
int64 main_resource_appcache_id,
- content::ResourceContext* resource_context)
+ content::ResourceContext* resource_context,
+ content::StoragePartitionImpl* storage_partition)
: url_(url),
closed_(false),
name_(name),
@@ -586,15 +605,18 @@
parent_process_id_(parent_process_id),
main_resource_appcache_id_(main_resource_appcache_id),
worker_document_set_(new WorkerDocumentSet()),
- resource_context_(resource_context) {
+ resource_context_(resource_context),
+ storage_partition_(storage_partition) {
DCHECK(resource_context_);
+ DCHECK(storage_partition_);
}
WorkerProcessHost::WorkerInstance::WorkerInstance(
const GURL& url,
bool shared,
const string16& name,
- content::ResourceContext* resource_context)
+ content::ResourceContext* resource_context,
+ content::StoragePartitionImpl* storage_partition)
: url_(url),
closed_(false),
name_(name),
@@ -602,8 +624,10 @@
parent_process_id_(0),
main_resource_appcache_id_(0),
worker_document_set_(new WorkerDocumentSet()),
- resource_context_(resource_context) {
+ resource_context_(resource_context),
+ storage_partition_(storage_partition) {
DCHECK(resource_context_);
+ DCHECK(storage_partition_);
}
WorkerProcessHost::WorkerInstance::~WorkerInstance() {
@@ -617,7 +641,8 @@
bool WorkerProcessHost::WorkerInstance::Matches(
const GURL& match_url,
const string16& match_name,
- content::ResourceContext* resource_context) const {
+ content::ResourceContext* resource_context,
+ content::StoragePartitionImpl* storage_partition) const {
// Only match open shared workers.
if (closed_)
return false;
@@ -627,6 +652,10 @@
if (resource_context_ != resource_context)
return false;
+ // Must be bound to the same storage partition too.
+ if (storage_partition_.get() != storage_partition)
+ return false;
+
if (url_.GetOrigin() != match_url.GetOrigin())
return false;

Powered by Google App Engine
This is Rietveld 408576698