| Index: chrome/test/testing_profile.cc
|
| diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
|
| index 4778a9846be69ec82b22ecd7e033a913230f61f5..d318d6f031a434195f31fb80f0c635eeb029d1e8 100644
|
| --- a/chrome/test/testing_profile.cc
|
| +++ b/chrome/test/testing_profile.cc
|
| @@ -51,6 +51,7 @@
|
| #include "chrome/test/testing_pref_service.h"
|
| #include "chrome/test/ui_test_utils.h"
|
| #include "content/browser/browser_thread.h"
|
| +#include "content/browser/file_system/browser_file_system_helper.h"
|
| #include "content/browser/in_process_webkit/webkit_context.h"
|
| #include "content/browser/mock_resource_context.h"
|
| #include "content/common/notification_service.h"
|
| @@ -392,21 +393,13 @@ Profile* TestingProfile::GetOriginalProfile() {
|
| return this;
|
| }
|
|
|
| -void TestingProfile::SetAppCacheService(
|
| - ChromeAppCacheService* appcache_service) {
|
| - appcache_service_ = appcache_service;
|
| -}
|
| -
|
| ChromeAppCacheService* TestingProfile::GetAppCacheService() {
|
| + CreateQuotaManagerAndClients();
|
| return appcache_service_.get();
|
| }
|
|
|
| webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() {
|
| - if (!db_tracker_) {
|
| - db_tracker_ = new webkit_database::DatabaseTracker(
|
| - GetPath(), false, false, GetExtensionSpecialStoragePolicy(),
|
| - NULL, NULL);
|
| - }
|
| + CreateQuotaManagerAndClients();
|
| return db_tracker_;
|
| }
|
|
|
| @@ -534,23 +527,65 @@ PersonalDataManager* TestingProfile::GetPersonalDataManager() {
|
| }
|
|
|
| fileapi::FileSystemContext* TestingProfile::GetFileSystemContext() {
|
| - if (!file_system_context_) {
|
| - file_system_context_ = new fileapi::FileSystemContext(
|
| - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
|
| - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
| - GetExtensionSpecialStoragePolicy(),
|
| - NULL,
|
| - GetPath(),
|
| - IsOffTheRecord(),
|
| - true, // Allow file access from files.
|
| - true, // Unlimited quota.
|
| - NULL);
|
| - }
|
| + CreateQuotaManagerAndClients();
|
| return file_system_context_.get();
|
| }
|
|
|
| quota::QuotaManager* TestingProfile::GetQuotaManager() {
|
| - return NULL;
|
| + CreateQuotaManagerAndClients();
|
| + return quota_manager_.get();
|
| +}
|
| +
|
| +void TestingProfile::CreateQuotaManagerAndClients() {
|
| + if (quota_manager_.get()) {
|
| + DCHECK(appcache_service_.get());
|
| + DCHECK(db_tracker_.get());
|
| + DCHECK(file_system_context_.get());
|
| + DCHECK(webkit_context_.get());
|
| + return;
|
| + }
|
| +
|
| + // All the clients have to be created and registered with the
|
| + // quota manager prior to the manager being used. So, we do them
|
| + // all together here prior to handing our a reference to anything
|
| + // that uses the quota manager.
|
| + quota_manager_ = new quota::QuotaManager(
|
| + IsOffTheRecord(),
|
| + GetPath(),
|
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
|
| + GetExtensionSpecialStoragePolicy());
|
| +
|
| + // Each consumer is responsible for registering its QuotaClient during
|
| + // its construction.
|
| + file_system_context_ = CreateFileSystemContext(
|
| + GetPath(), IsOffTheRecord(),
|
| + GetExtensionSpecialStoragePolicy(),
|
| + quota_manager_->proxy());
|
| + db_tracker_ = new webkit_database::DatabaseTracker(
|
| + GetPath(), IsOffTheRecord(), false,
|
| + GetExtensionSpecialStoragePolicy(),
|
| + quota_manager_->proxy(),
|
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
|
| + webkit_context_ = new WebKitContext(
|
| + IsOffTheRecord(), GetPath(), GetExtensionSpecialStoragePolicy(),
|
| + false, quota_manager_->proxy(),
|
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT));
|
| + appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO, FROM_HERE,
|
| + NewRunnableMethod(
|
| + appcache_service_.get(),
|
| + &ChromeAppCacheService::InitializeOnIOThread,
|
| + IsOffTheRecord()
|
| + ? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
|
| + &GetResourceContext(),
|
| + make_scoped_refptr(GetExtensionSpecialStoragePolicy()),
|
| + false));
|
| +
|
| + // Block until the posted task is finished, otherwise the appcache service
|
| + // won't be properly initialized.
|
| + MessageLoop::current()->RunAllPending();
|
| }
|
|
|
| BrowserSignin* TestingProfile::GetBrowserSignin() {
|
| @@ -692,12 +727,7 @@ SpellCheckHost* TestingProfile::GetSpellCheckHost() {
|
| }
|
|
|
| WebKitContext* TestingProfile::GetWebKitContext() {
|
| - if (webkit_context_ == NULL) {
|
| - webkit_context_ = new WebKitContext(
|
| - IsOffTheRecord(), GetPath(),
|
| - GetExtensionSpecialStoragePolicy(),
|
| - false, NULL, NULL);
|
| - }
|
| + CreateQuotaManagerAndClients();
|
| return webkit_context_;
|
| }
|
|
|
|
|