summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc2
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc7
-rw-r--r--content/browser/browser_context.cc61
-rw-r--r--content/browser/chrome_blob_storage_context.cc34
-rw-r--r--content/browser/chrome_blob_storage_context.h25
-rw-r--r--content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc14
-rw-r--r--content/browser/mock_resource_context.cc24
-rw-r--r--content/browser/mock_resource_context.h6
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc8
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc7
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_unittest.cc40
-rw-r--r--content/browser/resource_context_impl.cc92
-rw-r--r--content/browser/resource_context_impl.h36
-rw-r--r--content/browser/worker_host/worker_process_host.cc34
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/public/browser/browser_context.h17
-rw-r--r--content/public/browser/resource_context.h44
-rw-r--r--content/shell/shell_browser_context.cc3
-rw-r--r--content/shell/shell_resource_context.cc32
-rw-r--r--content/shell/shell_resource_context.h11
-rw-r--r--content/test/test_browser_context.cc5
-rw-r--r--content/test/test_browser_context.h6
22 files changed, 325 insertions, 185 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index 9be6b05..14e6ed2 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -9,6 +9,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/resource_context.h"
#include "net/base/net_errors.h"
#include "webkit/quota/quota_manager.h"
@@ -28,6 +29,7 @@ void ChromeAppCacheService::InitializeOnIOThread(
cache_path_ = cache_path;
resource_context_ = resource_context;
+ set_request_context(resource_context->GetRequestContext());
registrar_.Add(
this, content::NOTIFICATION_PURGE_MEMORY,
content::NotificationService::AllSources());
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index 7e59dcb..29b7956 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -9,6 +9,7 @@
#include "base/scoped_temp_dir.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/test/test_browser_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/appcache/appcache_database.h"
#include "webkit/appcache/appcache_storage_impl.h"
@@ -65,6 +66,7 @@ class ChromeAppCacheServiceTest : public testing::Test {
BrowserThreadImpl file_user_blocking_thread_;
BrowserThreadImpl cache_thread_;
BrowserThreadImpl io_thread_;
+ TestBrowserContext browser_context_;
};
scoped_refptr<ChromeAppCacheService>
@@ -73,7 +75,6 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
bool init_storage) {
scoped_refptr<ChromeAppCacheService> appcache_service =
new ChromeAppCacheService(NULL);
- content::ResourceContext* resource_context = NULL;
scoped_refptr<quota::MockSpecialStoragePolicy> mock_policy =
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kProtectedManifestURL.GetOrigin());
@@ -81,8 +82,8 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
- appcache_service.get(), appcache_path, resource_context,
- mock_policy));
+ appcache_service.get(), appcache_path,
+ browser_context_.GetResourceContext(), mock_policy));
// Steps needed to initialize the storage of AppCache data.
message_loop_.RunAllPending();
if (init_storage) {
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 1461b14..d56e797 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -5,21 +5,23 @@
#include "content/public/browser/browser_context.h"
#include "content/browser/appcache/chrome_appcache_service.h"
-#include "content/browser/chrome_blob_storage_context.h"
#include "content/browser/file_system/browser_file_system_helper.h"
#include "content/browser/in_process_webkit/webkit_context.h"
+#include "content/browser/resource_context_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_constants.h"
#include "webkit/database/database_tracker.h"
#include "webkit/quota/quota_manager.h"
+using appcache::AppCacheService;
+using base::UserDataAdapter;
using content::BrowserThread;
using fileapi::FileSystemContext;
using quota::QuotaManager;
using webkit_database::DatabaseTracker;
+// Key names on BrowserContext.
static const char* kAppCacheServicKeyName = "content_appcache_service_tracker";
-static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
static const char* kDatabaseTrackerKeyName = "content_database_tracker";
static const char* kFileSystemContextKeyName = "content_file_system_context";
static const char* kQuotaManagerKeyName = "content_quota_manager";
@@ -27,25 +29,6 @@ static const char* kWebKitContextKeyName = "content_webkit_context";
namespace content {
-// Adapter class that releases a refcounted object when the
-// SupportsUserData::Data object is deleted.
-template <typename T>
-class UserDataAdapter : public base::SupportsUserData::Data {
- public:
- static T* Get(BrowserContext* context, const char* key) {
- UserDataAdapter* data =
- static_cast<UserDataAdapter*>(context->GetUserData(key));
- return static_cast<T*>(data->object_.get());
- }
-
- UserDataAdapter(T* object) : object_(object) {}
-
- private:
- scoped_refptr<T> object_;
-
- DISALLOW_COPY_AND_ASSIGN(UserDataAdapter);
-};
-
void CreateQuotaManagerAndClients(BrowserContext* context) {
if (context->GetUserData(kQuotaManagerKeyName)) {
DCHECK(context->GetUserData(kDatabaseTrackerKeyName));
@@ -96,16 +79,18 @@ void CreateQuotaManagerAndClients(BrowserContext* context) {
kAppCacheServicKeyName,
new UserDataAdapter<ChromeAppCacheService>(appcache_service));
+ InitializeResourceContext(context);
+
// Check first to avoid memory leak in unittests.
if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
- appcache_service,
- context->IsOffTheRecord() ? FilePath() :
- context->GetPath().Append(content::kAppCacheDirname),
- context->GetResourceContext(),
- make_scoped_refptr(context->GetSpecialStoragePolicy())));
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
+ appcache_service,
+ context->IsOffTheRecord() ? FilePath() :
+ context->GetPath().Append(content::kAppCacheDirname),
+ context->GetResourceContext(),
+ make_scoped_refptr(context->GetSpecialStoragePolicy())));
}
}
@@ -125,7 +110,7 @@ DatabaseTracker* BrowserContext::GetDatabaseTracker(BrowserContext* context) {
context, kDatabaseTrackerKeyName);
}
-ChromeAppCacheService* BrowserContext::GetAppCacheService(
+AppCacheService* BrowserContext::GetAppCacheService(
BrowserContext* browser_context) {
CreateQuotaManagerAndClients(browser_context);
return UserDataAdapter<ChromeAppCacheService>::Get(
@@ -139,20 +124,10 @@ FileSystemContext* BrowserContext::GetFileSystemContext(
browser_context, kFileSystemContextKeyName);
}
-ChromeBlobStorageContext* BrowserContext::GetBlobStorageContext(
- BrowserContext* context) {
- if (!context->GetUserData(kBlobStorageContextKeyName)) {
- scoped_refptr<ChromeBlobStorageContext> blob =
- new ChromeBlobStorageContext();
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, blob));
- context->SetUserData(kBlobStorageContextKeyName,
- new UserDataAdapter<ChromeBlobStorageContext>(blob));
- }
-
- return UserDataAdapter<ChromeBlobStorageContext>::Get(
- context, kBlobStorageContextKeyName);
+void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
+ if (context->GetResourceContext()->GetUserData(kWebKitContextKeyName))
+ return;
+ InitializeResourceContext(context);
}
BrowserContext::~BrowserContext() {
diff --git a/content/browser/chrome_blob_storage_context.cc b/content/browser/chrome_blob_storage_context.cc
index 85a706c..6f607f2 100644
--- a/content/browser/chrome_blob_storage_context.cc
+++ b/content/browser/chrome_blob_storage_context.cc
@@ -4,11 +4,36 @@
#include "content/browser/chrome_blob_storage_context.h"
+#include "base/bind.h"
+#include "content/public/browser/browser_context.h"
#include "webkit/blob/blob_storage_controller.h"
+using base::UserDataAdapter;
+using content::BrowserContext;
using content::BrowserThread;
using webkit_blob::BlobStorageController;
+static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
+
+ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor(
+ BrowserContext* context) {
+ if (!context->GetUserData(kBlobStorageContextKeyName)) {
+ scoped_refptr<ChromeBlobStorageContext> blob =
+ new ChromeBlobStorageContext();
+ context->SetUserData(kBlobStorageContextKeyName,
+ new UserDataAdapter<ChromeBlobStorageContext>(blob));
+ // Check first to avoid memory leak in unittests.
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread, blob));
+ }
+ }
+
+ return UserDataAdapter<ChromeBlobStorageContext>::Get(
+ context, kBlobStorageContextKeyName);
+}
+
ChromeBlobStorageContext::ChromeBlobStorageContext() {
}
@@ -20,3 +45,12 @@ void ChromeBlobStorageContext::InitializeOnIOThread() {
ChromeBlobStorageContext::~ChromeBlobStorageContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
+
+void ChromeBlobStorageContext::DeleteOnCorrectThread() const {
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
+ !BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
+ return;
+ }
+ delete this;
+}
diff --git a/content/browser/chrome_blob_storage_context.h b/content/browser/chrome_blob_storage_context.h
index e83271c..0b5c820 100644
--- a/content/browser/chrome_blob_storage_context.h
+++ b/content/browser/chrome_blob_storage_context.h
@@ -12,10 +12,16 @@
#include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h"
+namespace content {
+class BrowserContext;
+}
+
namespace webkit_blob {
class BlobStorageController;
}
+struct ChromeBlobStorageContextDeleter;
+
// A context class that keeps track of BlobStorageController used by the chrome.
// There is an instance associated with each BrowserContext. There could be
// multiple URLRequestContexts in the same browser context that refers to the
@@ -25,9 +31,13 @@ class BlobStorageController;
// the IO thread (unless specifically called out in doc comments).
class CONTENT_EXPORT ChromeBlobStorageContext
: public base::RefCountedThreadSafe<
- ChromeBlobStorageContext, content::BrowserThread::DeleteOnIOThread> {
+ ChromeBlobStorageContext, ChromeBlobStorageContextDeleter> {
public:
+ static ChromeBlobStorageContext* GetFor(
+ content::BrowserContext* browser_context);
+
ChromeBlobStorageContext();
+ virtual ~ChromeBlobStorageContext();
void InitializeOnIOThread();
@@ -36,14 +46,17 @@ class CONTENT_EXPORT ChromeBlobStorageContext
}
private:
- friend class base::RefCountedThreadSafe<
- ChromeBlobStorageContext, content::BrowserThread::DeleteOnIOThread>;
- friend class content::BrowserThread;
- friend class base::DeleteHelper<ChromeBlobStorageContext>;
+ friend struct ChromeBlobStorageContextDeleter;
- virtual ~ChromeBlobStorageContext();
+ void DeleteOnCorrectThread() const;
scoped_ptr<webkit_blob::BlobStorageController> controller_;
};
+struct ChromeBlobStorageContextDeleter {
+ static void Destruct(const ChromeBlobStorageContext* context) {
+ context->DeleteOnCorrectThread();
+ }
+};
+
#endif // CONTENT_BROWSER_CHROME_BLOB_STORAGE_CONTEXT_H_
diff --git a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc
index 0689eeb..c886c0d 100644
--- a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc
+++ b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc
@@ -42,12 +42,16 @@ class IndexedDBQuotaClientTest : public testing::Test {
usage_(0),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
message_loop_(MessageLoop::TYPE_IO),
+ db_thread_(BrowserThread::DB, &message_loop_),
webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_),
- file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_),
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ file_user_blocking_thread_(
+ BrowserThread::FILE_USER_BLOCKING, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_) {
- TestBrowserContext browser_context;
- idb_context_ = BrowserContext::GetWebKitContext(&browser_context)->
+ browser_context_.reset(new TestBrowserContext());
+ idb_context_ = BrowserContext::GetWebKitContext(browser_context_.get())->
indexed_db_context();
+ message_loop_.RunAllPending();
setup_temp_dir();
}
void setup_temp_dir() {
@@ -64,6 +68,7 @@ class IndexedDBQuotaClientTest : public testing::Test {
// class. Cause IndexedDBContext's destruction now to ensure that it
// doesn't outlive BrowserThread::WEBKIT_DEPRECATED.
idb_context_ = NULL;
+ browser_context_.reset();
MessageLoop::current()->RunAllPending();
}
@@ -160,9 +165,12 @@ class IndexedDBQuotaClientTest : public testing::Test {
scoped_refptr<IndexedDBContext> idb_context_;
base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_;
MessageLoop message_loop_;
+ BrowserThreadImpl db_thread_;
BrowserThreadImpl webkit_thread_;
BrowserThreadImpl file_thread_;
+ BrowserThreadImpl file_user_blocking_thread_;
BrowserThreadImpl io_thread_;
+ scoped_ptr<TestBrowserContext> browser_context_;
quota::QuotaStatusCode delete_status_;
};
diff --git a/content/browser/mock_resource_context.cc b/content/browser/mock_resource_context.cc
index 6baef2c..170b4e6 100644
--- a/content/browser/mock_resource_context.cc
+++ b/content/browser/mock_resource_context.cc
@@ -40,26 +40,6 @@ net::URLRequestContext* MockResourceContext::GetRequestContext() {
return test_request_context_;
}
-ChromeAppCacheService* MockResourceContext::GetAppCacheService() {
- return NULL;
-}
-
-webkit_database::DatabaseTracker* MockResourceContext::GetDatabaseTracker() {
- return NULL;
-}
-
-fileapi::FileSystemContext* MockResourceContext::GetFileSystemContext() {
- return NULL;
-}
-
-ChromeBlobStorageContext* MockResourceContext::GetBlobStorageContext() {
- return NULL;
-}
-
-quota::QuotaManager* MockResourceContext::GetQuotaManager() {
- return NULL;
-}
-
HostZoomMap* MockResourceContext::GetHostZoomMap() {
return NULL;
}
@@ -77,8 +57,4 @@ AudioManager* MockResourceContext::GetAudioManager() {
return audio_manager_;
}
-WebKitContext* MockResourceContext::GetWebKitContext() {
- return NULL;
-}
-
} // namespace content
diff --git a/content/browser/mock_resource_context.h b/content/browser/mock_resource_context.h
index 73be660..8841945 100644
--- a/content/browser/mock_resource_context.h
+++ b/content/browser/mock_resource_context.h
@@ -43,16 +43,10 @@ class MockResourceContext : public ResourceContext {
// ResourceContext implementation:
virtual net::HostResolver* GetHostResolver() OVERRIDE;
virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
- virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
- virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
- virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
- virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
- virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
virtual HostZoomMap* GetHostZoomMap() OVERRIDE;
virtual MediaObserver* GetMediaObserver() OVERRIDE;
virtual media_stream::MediaStreamManager* GetMediaStreamManager() OVERRIDE;
virtual AudioManager* GetAudioManager() OVERRIDE;
- virtual WebKitContext* GetWebKitContext() OVERRIDE;
private:
friend struct base::DefaultLazyInstanceTraits<MockResourceContext>;
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 0174d49..ef91b71 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -39,8 +39,10 @@
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
#include "content/browser/appcache/appcache_dispatcher_host.h"
+#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/browser_main.h"
#include "content/browser/child_process_security_policy_impl.h"
+#include "content/browser/chrome_blob_storage_context.h"
#include "content/browser/device_orientation/message_filter.h"
#include "content/browser/download/mhtml_generation_manager.h"
#include "content/browser/file_system/file_system_dispatcher_host.h"
@@ -461,7 +463,9 @@ void RenderProcessHostImpl::CreateMessageFilters() {
channel_->AddFilter(new AudioRendererHost(resource_context));
channel_->AddFilter(new VideoCaptureHost(resource_context));
channel_->AddFilter(new AppCacheDispatcherHost(
- BrowserContext::GetAppCacheService(browser_context), GetID()));
+ static_cast<ChromeAppCacheService*>(
+ BrowserContext::GetAppCacheService(browser_context)),
+ GetID()));
channel_->AddFilter(new ClipboardMessageFilter());
channel_->AddFilter(new DOMStorageMessageFilter(GetID(),
BrowserContext::GetWebKitContext(browser_context)));
@@ -483,7 +487,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
BrowserContext::GetFileSystemContext(browser_context)));
channel_->AddFilter(new device_orientation::MessageFilter());
channel_->AddFilter(new BlobMessageFilter(GetID(),
- BrowserContext::GetBlobStorageContext(browser_context)));
+ ChromeBlobStorageContext::GetFor(browser_context)));
channel_->AddFilter(new FileUtilitiesMessageFilter(GetID()));
channel_->AddFilter(new MimeRegistryMessageFilter());
channel_->AddFilter(new DatabaseMessageFilter(
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index 5b73ae8..dc1224e 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -90,6 +90,7 @@ using base::TimeDelta;
using base::TimeTicks;
using content::BrowserThread;
using content::GlobalRequestID;
+using content::ResourceContext;
using content::ResourceResponse;
using content::ResourceThrottle;
using content::ThrottlingResourceHandler;
@@ -541,7 +542,7 @@ void ResourceDispatcherHost::BeginRequest(
// Might need to resolve the blob references in the upload data.
if (request_data.upload_data) {
- resource_context->GetBlobStorageContext()->controller()->
+ ResourceContext::GetBlobStorageController(resource_context)->
ResolveBlobReferencesInUploadData(request_data.upload_data.get());
}
@@ -716,14 +717,14 @@ void ResourceDispatcherHost::BeginRequest(
// Hang on to a reference to ensure the blob is not released prior
// to the job being started.
webkit_blob::BlobStorageController* controller =
- resource_context->GetBlobStorageContext()->controller();
+ ResourceContext::GetBlobStorageController(resource_context);
extra_info->set_requested_blob_data(
controller->GetBlobDataFromUrl(request->url()));
}
// Have the appcache associate its extra info with the request.
appcache::AppCacheInterceptor::SetExtraRequestInfo(
- request, resource_context->GetAppCacheService(), child_id,
+ request, ResourceContext::GetAppCacheService(resource_context), child_id,
request_data.appcache_host_id, request_data.resource_type);
if (deferred_request) {
diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
index 3bf44bd..20d629a 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -26,6 +26,7 @@
#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/common/resource_response.h"
+#include "content/test/test_browser_context.h"
#include "net/base/net_errors.h"
#include "net/base/upload_data.h"
#include "net/http/http_util.h"
@@ -35,14 +36,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/appcache/appcache_interfaces.h"
-namespace content {
-class DownloadManager;
-} // namespace content
-
+using content::BrowserContext;
using content::BrowserThread;
using content::BrowserThreadImpl;
using content::ChildProcessHostImpl;
-using content::DownloadManager;
using content::GlobalRequestID;
// TODO(eroman): Write unit tests for SafeBrowsing that exercise
@@ -169,11 +166,12 @@ class MockURLRequestContextSelector
// messages to go to the same place, which is why this forwards.
class ForwardingFilter : public ResourceMessageFilter {
public:
- explicit ForwardingFilter(IPC::Message::Sender* dest)
+ explicit ForwardingFilter(IPC::Message::Sender* dest,
+ content::ResourceContext* resource_context)
: ResourceMessageFilter(
ChildProcessHostImpl::GenerateChildProcessUniqueId(),
content::PROCESS_TYPE_RENDERER,
- content::MockResourceContext::GetInstance(),
+ resource_context,
new MockURLRequestContextSelector(
content::MockResourceContext::GetInstance()->GetRequestContext())),
dest_(dest) {
@@ -334,10 +332,16 @@ class ResourceDispatcherHostTest : public testing::Test,
public:
ResourceDispatcherHostTest()
: ui_thread_(BrowserThread::UI, &message_loop_),
+ file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_),
+ cache_thread_(BrowserThread::CACHE, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_),
- ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))),
old_factory_(NULL),
resource_type_(ResourceType::SUB_RESOURCE) {
+ browser_context_.reset(new TestBrowserContext());
+ BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
+ message_loop_.RunAllPending();
+ filter_ = new ForwardingFilter(
+ this, browser_context_->GetResourceContext());
}
// IPC::Message::Sender implementation
virtual bool Send(IPC::Message* msg) {
@@ -376,6 +380,7 @@ class ResourceDispatcherHostTest : public testing::Test,
ChildProcessSecurityPolicyImpl::GetInstance()->Remove(0);
// Flush the message loop to make application verifiers happy.
+ browser_context_.reset();
message_loop_.RunAllPending();
}
@@ -457,7 +462,10 @@ class ResourceDispatcherHostTest : public testing::Test,
MessageLoopForIO message_loop_;
BrowserThreadImpl ui_thread_;
+ BrowserThreadImpl file_thread_;
+ BrowserThreadImpl cache_thread_;
BrowserThreadImpl io_thread_;
+ scoped_ptr<TestBrowserContext> browser_context_;
scoped_refptr<ForwardingFilter> filter_;
ResourceDispatcherHost host_;
ResourceIPCAccumulator accum_;
@@ -698,8 +706,8 @@ TEST_F(ResourceDispatcherHostTest, PausedCancel) {
// pending and some canceled.
class TestFilter : public ForwardingFilter {
public:
- TestFilter()
- : ForwardingFilter(NULL),
+ explicit TestFilter(content::ResourceContext* resource_context)
+ : ForwardingFilter(NULL, resource_context),
has_canceled_(false),
received_after_canceled_(0) {
}
@@ -718,7 +726,8 @@ class TestFilter : public ForwardingFilter {
// Tests CancelRequestsForProcess
TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
- scoped_refptr<TestFilter> test_filter = new TestFilter();
+ scoped_refptr<TestFilter> test_filter = new TestFilter(
+ browser_context_->GetResourceContext());
// request 1 goes to the test delegate
ResourceHostMsg_Request request = CreateResourceRequest(
@@ -871,7 +880,8 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
// Tests that blocked requests are canceled if their associated process dies.
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
// This second filter is used to emulate a second process.
- scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this);
+ scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
+ this, browser_context_->GetResourceContext());
EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id()));
EXPECT_EQ(0,
@@ -915,7 +925,8 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
// destructor to make sure the blocked requests are deleted.
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
// This second filter is used to emulate a second process.
- scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this);
+ scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
+ this, browser_context_->GetResourceContext());
host_.BlockRequestsForRoute(filter_->child_id(), 1);
host_.BlockRequestsForRoute(filter_->child_id(), 2);
@@ -1006,7 +1017,8 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
size_t kMaxRequests = kMaxCostPerProcess / kMemoryCostOfTest2Req;
// This second filter is used to emulate a second process.
- scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(this);
+ scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
+ this, browser_context_->GetResourceContext());
// Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequests; ++i) {
diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc
new file mode 100644
index 0000000..d7cbeab
--- /dev/null
+++ b/content/browser/resource_context_impl.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2012 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.
+
+#include "content/browser/resource_context_impl.h"
+
+#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/browser/chrome_blob_storage_context.h"
+#include "content/browser/file_system/browser_file_system_helper.h"
+#include "content/browser/in_process_webkit/webkit_context.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "webkit/database/database_tracker.h"
+
+// Key names on ResourceContext.
+static const char* kAppCacheServicKeyName = "content_appcache_service_tracker";
+static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
+static const char* kDatabaseTrackerKeyName = "content_database_tracker";
+static const char* kFileSystemContextKeyName = "content_file_system_context";
+static const char* kWebKitContextKeyName = "content_webkit_context";
+
+using appcache::AppCacheService;
+using base::UserDataAdapter;
+using content::BrowserThread;
+using fileapi::FileSystemContext;
+using webkit_blob::BlobStorageController;
+using webkit_database::DatabaseTracker;
+
+namespace content {
+
+AppCacheService* ResourceContext::GetAppCacheService(ResourceContext* context) {
+ return UserDataAdapter<ChromeAppCacheService>::Get(
+ context, kAppCacheServicKeyName);
+}
+
+FileSystemContext* ResourceContext::GetFileSystemContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<FileSystemContext>::Get(
+ resource_context, kFileSystemContextKeyName);
+}
+
+BlobStorageController* ResourceContext::GetBlobStorageController(
+ ResourceContext* resource_context) {
+ return GetChromeBlobStorageContextForResourceContext(resource_context)->
+ controller();
+}
+
+DatabaseTracker* GetDatabaseTrackerForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<DatabaseTracker>::Get(
+ resource_context, kDatabaseTrackerKeyName);
+}
+
+WebKitContext* GetWebKitContextForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<WebKitContext>::Get(
+ resource_context, kWebKitContextKeyName);
+}
+
+ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<ChromeBlobStorageContext>::Get(
+ resource_context, kBlobStorageContextKeyName);
+}
+
+void InitializeResourceContext(BrowserContext* browser_context) {
+ ResourceContext* resource_context = browser_context->GetResourceContext();
+ DCHECK(!resource_context->GetUserData(kWebKitContextKeyName));
+ resource_context->SetUserData(
+ kWebKitContextKeyName,
+ new UserDataAdapter<WebKitContext>(
+ BrowserContext::GetWebKitContext(browser_context)));
+ resource_context->SetUserData(
+ kDatabaseTrackerKeyName,
+ new UserDataAdapter<webkit_database::DatabaseTracker>(
+ BrowserContext::GetDatabaseTracker(browser_context)));
+ resource_context->SetUserData(
+ kAppCacheServicKeyName,
+ new UserDataAdapter<ChromeAppCacheService>(
+ static_cast<ChromeAppCacheService*>(
+ BrowserContext::GetAppCacheService(browser_context))));
+ resource_context->SetUserData(
+ kFileSystemContextKeyName,
+ new UserDataAdapter<FileSystemContext>(
+ BrowserContext::GetFileSystemContext(browser_context)));
+ resource_context->SetUserData(
+ kBlobStorageContextKeyName,
+ new UserDataAdapter<ChromeBlobStorageContext>(
+ ChromeBlobStorageContext::GetFor(browser_context)));
+}
+
+} // namespace content
diff --git a/content/browser/resource_context_impl.h b/content/browser/resource_context_impl.h
new file mode 100644
index 0000000..ba06635
--- /dev/null
+++ b/content/browser/resource_context_impl.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 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_RESOURCE_CONTEXT_IMPL_H_
+#define CONTENT_BROWSER_RESOURCE_CONTEXT_IMPL_H_
+
+#include "content/public/browser/resource_context.h"
+
+class ChromeBlobStorageContext;
+class WebKitContext;
+
+namespace webkit_database {
+class DatabaseTracker;
+}
+
+namespace content {
+
+class BrowserContext;
+
+// Getters for objects that are part of BrowserContext which are also used on
+// the IO thread. These are only accessed by content so they're not on the
+// public API.
+webkit_database::DatabaseTracker* GetDatabaseTrackerForResourceContext(
+ ResourceContext* resource_context);
+WebKitContext* GetWebKitContextForResourceContext(
+ ResourceContext* resource_context);
+ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext(
+ ResourceContext* resource_context);
+
+// Initialize the above data on the ResourceContext from a given BrowserContext.
+void InitializeResourceContext(BrowserContext* browser_context);
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RESOURCE_CONTEXT_IMPL_H_
diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc
index f74f64f..c9d3757 100644
--- a/content/browser/worker_host/worker_process_host.cc
+++ b/content/browser/worker_host/worker_process_host.cc
@@ -16,6 +16,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "content/browser/appcache/appcache_dispatcher_host.h"
+#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/debugger/worker_devtools_manager.h"
@@ -28,6 +29,7 @@
#include "content/browser/renderer_host/file_utilities_message_filter.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/socket_stream_dispatcher_host.h"
+#include "content/browser/resource_context_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"
@@ -38,7 +40,6 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_view_host_delegate.h"
-#include "content/public/browser/resource_context.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
@@ -53,6 +54,7 @@
using content::BrowserThread;
using content::ChildProcessData;
using content::ChildProcessHost;
+using content::ResourceContext;
using content::UserMetricsAction;
using content::WorkerDevToolsManager;
using content::WorkerServiceImpl;
@@ -194,6 +196,8 @@ bool WorkerProcessHost::Init(int render_process_id) {
#endif
cmd_line);
+ fileapi::FileSystemContext* file_system_context =
+ ResourceContext::GetFileSystemContext(resource_context_);
ChildProcessSecurityPolicyImpl::GetInstance()->AddWorker(
process_->GetData().id, render_process_id);
if (!CommandLine::ForCurrentProcess()->HasSwitch(
@@ -204,8 +208,8 @@ bool WorkerProcessHost::Init(int render_process_id) {
// requests them.
// This is for the filesystem sandbox.
ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
- process_->GetData().id, resource_context_->GetFileSystemContext()->
- sandbox_provider()->new_base_path(),
+ process_->GetData().id,
+ file_system_context->sandbox_provider()->new_base_path(),
base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_CREATE |
base::PLATFORM_FILE_OPEN_ALWAYS |
@@ -221,16 +225,16 @@ bool WorkerProcessHost::Init(int render_process_id) {
// This is so that we can read and move stuff out of the old filesystem
// sandbox.
ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
- process_->GetData().id, resource_context_->GetFileSystemContext()->
- sandbox_provider()->old_base_path(),
+ process_->GetData().id,
+ file_system_context->sandbox_provider()->old_base_path(),
base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE |
base::PLATFORM_FILE_WRITE_ATTRIBUTES |
base::PLATFORM_FILE_ENUMERATE);
// This is so that we can rename the old sandbox out of the way so that
// we know we've taken care of it.
ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile(
- process_->GetData().id, resource_context_->GetFileSystemContext()->
- sandbox_provider()->renamed_old_base_path(),
+ process_->GetData().id,
+ file_system_context->sandbox_provider()->renamed_old_base_path(),
base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS |
base::PLATFORM_FILE_WRITE);
}
@@ -255,16 +259,21 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
base::Unretained(WorkerServiceImpl::GetInstance())));
process_->GetHost()->AddFilter(worker_message_filter_);
process_->GetHost()->AddFilter(new AppCacheDispatcherHost(
- resource_context_->GetAppCacheService(), process_->GetData().id));
+ static_cast<ChromeAppCacheService*>(
+ ResourceContext::GetAppCacheService(resource_context_)),
+ process_->GetData().id));
process_->GetHost()->AddFilter(new FileSystemDispatcherHost(
- request_context, resource_context_->GetFileSystemContext()));
+ request_context,
+ ResourceContext::GetFileSystemContext(resource_context_)));
process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter(
process_->GetData().id));
process_->GetHost()->AddFilter(new BlobMessageFilter(
- process_->GetData().id, resource_context_->GetBlobStorageContext()));
+ process_->GetData().id,
+ content::GetChromeBlobStorageContextForResourceContext(
+ resource_context_)));
process_->GetHost()->AddFilter(new MimeRegistryMessageFilter());
process_->GetHost()->AddFilter(new DatabaseMessageFilter(
- resource_context_->GetDatabaseTracker()));
+ content::GetDatabaseTrackerForResourceContext(resource_context_)));
SocketStreamDispatcherHost* socket_stream_dispatcher_host =
new SocketStreamDispatcherHost(
@@ -273,7 +282,8 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
process_->GetHost()->AddFilter(
new content::WorkerDevToolsMessageFilter(process_->GetData().id));
process_->GetHost()->AddFilter(new IndexedDBDispatcherHost(
- process_->GetData().id, resource_context_->GetWebKitContext()));
+ process_->GetData().id,
+ content::GetWebKitContextForResourceContext(resource_context_)));
}
void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index ebcf8ed..37a09bb 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -580,6 +580,8 @@
'browser/renderer_host/x509_user_cert_resource_handler.h',
'browser/resolve_proxy_msg_helper.cc',
'browser/resolve_proxy_msg_helper.h',
+ 'browser/resource_context_impl.cc',
+ 'browser/resource_context_impl.h',
'browser/safe_util_win.cc',
'browser/safe_util_win.h',
'browser/sensors/sensors_provider_impl.cc',
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h
index dd00b4a..7a5e2e5 100644
--- a/content/public/browser/browser_context.h
+++ b/content/public/browser/browser_context.h
@@ -10,6 +10,10 @@
#include "base/supports_user_data.h"
#include "content/common/content_export.h"
+namespace appcache {
+class AppCacheService;
+}
+
namespace fileapi {
class FileSystemContext;
}
@@ -27,8 +31,6 @@ namespace webkit_database {
class DatabaseTracker;
}
-class ChromeAppCacheService;
-class ChromeBlobStorageContext;
class FilePath;
class WebKitContext;
@@ -49,12 +51,17 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
static WebKitContext* GetWebKitContext(BrowserContext* browser_context);
static webkit_database::DatabaseTracker* GetDatabaseTracker(
BrowserContext* browser_context);
- static ChromeAppCacheService* GetAppCacheService(
+ static appcache::AppCacheService* GetAppCacheService(
BrowserContext* browser_context);
static fileapi::FileSystemContext* GetFileSystemContext(
BrowserContext* browser_context);
- static ChromeBlobStorageContext* GetBlobStorageContext(
- BrowserContext* browser_context);
+
+ // Ensures that the corresponding ResourceContext is initialized. Normally the
+ // BrowserContext initializs the corresponding getters when its objects are
+ // created, but if the embedder wants to pass the ResourceContext to another
+ // thread before they use BrowserContext, they should call this to make sure
+ // that the ResourceContext is ready.
+ static void EnsureResourceContextInitialized(BrowserContext* browser_context);
virtual ~BrowserContext();
diff --git a/content/public/browser/resource_context.h b/content/public/browser/resource_context.h
index 7ad6097..94b36fc 100644
--- a/content/public/browser/resource_context.h
+++ b/content/public/browser/resource_context.h
@@ -6,28 +6,32 @@
#define CONTENT_PUBLIC_BROWSER_RESOURCE_CONTEXT_H_
#include "base/basictypes.h"
+#include "base/supports_user_data.h"
+#include "content/common/content_export.h"
class AudioManager;
-class ChromeAppCacheService;
-class ChromeBlobStorageContext;
class MediaObserver;
-class WebKitContext;
+
+namespace appcache {
+class AppCacheService;
+}
+
namespace fileapi {
class FileSystemContext;
-} // namespace fileapi
+}
+
namespace media_stream {
class MediaStreamManager;
-} // namespace media_stream
+}
+
namespace net {
class HostResolver;
class URLRequestContext;
-} // namespace net
-namespace quota {
-class QuotaManager;
-}; // namespace quota
-namespace webkit_database {
-class DatabaseTracker;
-} // namespace webkit_database
+}
+
+namespace webkit_blob {
+class BlobStorageController;
+}
namespace content {
@@ -36,22 +40,22 @@ class HostZoomMap;
// ResourceContext contains the relevant context information required for
// resource loading. It lives on the IO thread, although it is constructed on
// the UI thread.
-class ResourceContext {
+class CONTENT_EXPORT ResourceContext : public base::SupportsUserData {
public:
- virtual ~ResourceContext() {}
+ static appcache::AppCacheService* GetAppCacheService(
+ ResourceContext* resource_context);
+ static fileapi::FileSystemContext* GetFileSystemContext(
+ ResourceContext* resource_context);
+ static webkit_blob::BlobStorageController* GetBlobStorageController(
+ ResourceContext* resource_context);
+ virtual ~ResourceContext() {}
virtual net::HostResolver* GetHostResolver() = 0;
virtual net::URLRequestContext* GetRequestContext() = 0;
- virtual ChromeAppCacheService* GetAppCacheService() = 0;
- virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0;
- virtual fileapi::FileSystemContext* GetFileSystemContext() = 0;
- virtual ChromeBlobStorageContext* GetBlobStorageContext() = 0;
- virtual quota::QuotaManager* GetQuotaManager() = 0;
virtual HostZoomMap* GetHostZoomMap() = 0;
virtual MediaObserver* GetMediaObserver() = 0;
virtual media_stream::MediaStreamManager* GetMediaStreamManager() = 0;
virtual AudioManager* GetAudioManager() = 0;
- virtual WebKitContext* GetWebKitContext() = 0;
};
} // namespace content
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index b118413..f98c43f 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -158,8 +158,7 @@ net::URLRequestContextGetter*
ResourceContext* ShellBrowserContext::GetResourceContext() {
if (!resource_context_.get()) {
resource_context_.reset(new ShellResourceContext(
- static_cast<ShellURLRequestContextGetter*>(GetRequestContext()),
- BrowserContext::GetBlobStorageContext(this)));
+ static_cast<ShellURLRequestContextGetter*>(GetRequestContext())));
}
return resource_context_.get();
}
diff --git a/content/shell/shell_resource_context.cc b/content/shell/shell_resource_context.cc
index e58c397..d8c3f29 100644
--- a/content/shell/shell_resource_context.cc
+++ b/content/shell/shell_resource_context.cc
@@ -3,17 +3,13 @@
// found in the LICENSE file.
#include "content/shell/shell_resource_context.h"
-
-#include "content/browser/chrome_blob_storage_context.h"
#include "content/shell/shell_url_request_context_getter.h"
namespace content {
ShellResourceContext::ShellResourceContext(
- ShellURLRequestContextGetter* getter,
- ChromeBlobStorageContext* blob_storage_context)
- : getter_(getter),
- blob_storage_context_(blob_storage_context) {
+ ShellURLRequestContextGetter* getter)
+ : getter_(getter) {
}
ShellResourceContext::~ShellResourceContext() {
@@ -27,26 +23,6 @@ net::URLRequestContext* ShellResourceContext::GetRequestContext() {
return getter_->GetURLRequestContext();
}
-ChromeAppCacheService* ShellResourceContext::GetAppCacheService() {
- return NULL;
-}
-
-webkit_database::DatabaseTracker* ShellResourceContext::GetDatabaseTracker() {
- return NULL;
-}
-
-fileapi::FileSystemContext* ShellResourceContext::GetFileSystemContext() {
- return NULL;
-}
-
-ChromeBlobStorageContext* ShellResourceContext::GetBlobStorageContext() {
- return blob_storage_context_;
-}
-
-quota::QuotaManager* ShellResourceContext::GetQuotaManager() {
- return NULL;
-}
-
HostZoomMap* ShellResourceContext::GetHostZoomMap() {
return NULL;
}
@@ -64,8 +40,4 @@ AudioManager* ShellResourceContext::GetAudioManager() {
return NULL;
}
-WebKitContext* ShellResourceContext::GetWebKitContext() {
- return NULL;
-}
-
} // namespace content
diff --git a/content/shell/shell_resource_context.h b/content/shell/shell_resource_context.h
index ff2db50..91e76bf 100644
--- a/content/shell/shell_resource_context.h
+++ b/content/shell/shell_resource_context.h
@@ -18,28 +18,19 @@ class ShellURLRequestContextGetter;
class ShellResourceContext : public content::ResourceContext {
public:
- ShellResourceContext(
- ShellURLRequestContextGetter* getter,
- ChromeBlobStorageContext* blob_storage_context);
+ explicit ShellResourceContext(ShellURLRequestContextGetter* getter);
virtual ~ShellResourceContext();
private:
// ResourceContext implementation:
virtual net::HostResolver* GetHostResolver() OVERRIDE;
virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
- virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
- virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
- virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
- virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
- virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
virtual HostZoomMap* GetHostZoomMap() OVERRIDE;
virtual MediaObserver* GetMediaObserver() OVERRIDE;
virtual media_stream::MediaStreamManager* GetMediaStreamManager() OVERRIDE;
virtual AudioManager* GetAudioManager() OVERRIDE;
- virtual WebKitContext* GetWebKitContext() OVERRIDE;
scoped_refptr<ShellURLRequestContextGetter> getter_;
- scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
};
diff --git a/content/test/test_browser_context.cc b/content/test/test_browser_context.cc
index df3934e..bbd515e 100644
--- a/content/test/test_browser_context.cc
+++ b/content/test/test_browser_context.cc
@@ -49,8 +49,9 @@ net::URLRequestContextGetter* TestBrowserContext::GetRequestContextForMedia() {
}
content::ResourceContext* TestBrowserContext::GetResourceContext() {
- // TODO(phajdan.jr): Get rid of this nasty global.
- return content::MockResourceContext::GetInstance();
+ if (!resource_context_.get())
+ resource_context_.reset(new content::MockResourceContext());
+ return resource_context_.get();
}
HostZoomMap* TestBrowserContext::GetHostZoomMap() {
diff --git a/content/test/test_browser_context.h b/content/test/test_browser_context.h
index c0873c0..fb6159a 100644
--- a/content/test/test_browser_context.h
+++ b/content/test/test_browser_context.h
@@ -10,11 +10,16 @@
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
#include "content/public/browser/browser_context.h"
class WebKitContext;
+namespace content {
+class MockResourceContext;
+}
+
class TestBrowserContext : public content::BrowserContext {
public:
TestBrowserContext();
@@ -43,6 +48,7 @@ class TestBrowserContext : public content::BrowserContext {
FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly);
FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SaveSessionState);
+ scoped_ptr<content::MockResourceContext> resource_context_;
ScopedTempDir browser_context_dir_;
DISALLOW_COPY_AND_ASSIGN(TestBrowserContext);