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

Unified Diff: chrome/test/testing_profile.cc

Issue 7464029: Adding QuotaManager logic to TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Uglay. Created 9 years, 5 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
« no previous file with comments | « chrome/test/testing_profile.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/testing_profile.cc
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 4778a9846be69ec82b22ecd7e033a913230f61f5..4251b16dd786a13c152ddefff57e1ce74fee58ce 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"
@@ -121,6 +122,11 @@ ProfileKeyedService* CreateTestDesktopNotificationService(Profile* profile) {
return new DesktopNotificationService(profile, NULL);
}
+void CreateResourceContextOnIOThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ content::MockResourceContext::GetInstance();
+};
+
} // namespace
TestingProfile::TestingProfile()
@@ -128,6 +134,7 @@ TestingProfile::TestingProfile()
testing_prefs_(NULL),
incognito_(false),
last_session_exited_cleanly_(true),
+ appcache_service_init_finished_(false),
profile_dependency_manager_(ProfileDependencyManager::GetInstance()) {
#ifndef NDEBUG
profile_dependency_manager_->ProfileNowExists(this);
@@ -392,21 +399,33 @@ Profile* TestingProfile::GetOriginalProfile() {
return this;
}
-void TestingProfile::SetAppCacheService(
- ChromeAppCacheService* appcache_service) {
- appcache_service_ = appcache_service;
-}
-
ChromeAppCacheService* TestingProfile::GetAppCacheService() {
+ CreateQuotaManagerAndClients();
+ if (!appcache_service_init_finished_) {
+ // Ensure that this is posted before GetResourceContext() is called below,
+ // otherwise it's entirely possible that things will be exploded.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableFunction(&CreateResourceContextOnIOThread));
+
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ appcache_service_.get(),
+ &ChromeAppCacheService::InitializeOnIOThread,
+ IsOffTheRecord()
+ ? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
+ &GetResourceContext(),
+ make_scoped_refptr(GetExtensionSpecialStoragePolicy()),
+ false));
+
+ appcache_service_init_finished_ = true;
+ }
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 +553,51 @@ 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());
}
BrowserSignin* TestingProfile::GetBrowserSignin() {
@@ -692,12 +739,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_;
}
« no previous file with comments | « chrome/test/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698