diff options
42 files changed, 145 insertions, 250 deletions
diff --git a/base/supports_user_data.h b/base/supports_user_data.h index 1c90e01..d1c6c9a 100644 --- a/base/supports_user_data.h +++ b/base/supports_user_data.h @@ -55,6 +55,7 @@ class UserDataAdapter : public base::SupportsUserData::Data { } UserDataAdapter(T* object) : object_(object) {} + T* release() { return object_.release(); } private: scoped_refptr<T> object_; diff --git a/chrome/browser/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data_indexed_db_helper.cc index b673e98..fea3b26 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.cc +++ b/chrome/browser/browsing_data_indexed_db_helper.cc @@ -64,7 +64,7 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { BrowsingDataIndexedDBHelperImpl::BrowsingDataIndexedDBHelperImpl( Profile* profile) - : indexed_db_context_(IndexedDBContext::GetForBrowserContext(profile)), + : indexed_db_context_(BrowserContext::GetIndexedDBContext(profile)), is_fetching_(false) { DCHECK(indexed_db_context_.get()); } diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc index 92a6421..57305d8 100644 --- a/chrome/browser/browsing_data_local_storage_helper.cc +++ b/chrome/browser/browsing_data_local_storage_helper.cc @@ -50,7 +50,7 @@ BrowsingDataLocalStorageHelper::LocalStorageInfo::~LocalStorageInfo() {} BrowsingDataLocalStorageHelper::BrowsingDataLocalStorageHelper( Profile* profile) - : dom_storage_context_(DOMStorageContext::GetForBrowserContext(profile)), + : dom_storage_context_(BrowserContext::GetDOMStorageContext(profile)), is_fetching_(false) { DCHECK(dom_storage_context_.get()); } diff --git a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc index f2ace6f..e7af14a 100644 --- a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc +++ b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc @@ -22,6 +22,7 @@ #include "content/public/browser/dom_storage_context.h" #include "testing/gtest/include/gtest/gtest.h" +using content::BrowserContext; using content::BrowserThread; using content::DOMStorageContext; @@ -58,7 +59,7 @@ class BrowsingDataLocalStorageHelperTest : public InProcessBrowserTest { } FilePath GetLocalStoragePathForTestingProfile() { - return DOMStorageContext::GetForBrowserContext(browser()->profile())-> + return BrowserContext::GetDOMStorageContext(browser()->profile())-> GetFilePath(ASCIIToUTF16("blah")).DirName(); } }; diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 8653ef0..1adc128 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -303,8 +303,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask, if (remove_mask & REMOVE_LOCAL_STORAGE && BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { - DOMStorageContext* context = - DOMStorageContext::GetForBrowserContext(profile_); + DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind(&BrowsingDataRemover::ClearDOMStorageOnWebKitThread, diff --git a/chrome/browser/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data_remover_unittest.cc index 9e8f1c2..fa3cb45 100644 --- a/chrome/browser/browsing_data_remover_unittest.cc +++ b/chrome/browser/browsing_data_remover_unittest.cc @@ -349,7 +349,7 @@ class BrowsingDataRemoverTest : public testing::Test, } void TearDown() { - // TestingProfile contains a WebKitContext. WebKitContext's destructor + // TestingProfile contains a DOMStorageContext. BrowserContext's destructor // posts a message to the WEBKIT thread to delete some of its member // variables. We need to ensure that the profile is destroyed, and that // the message loop is cleared out, before destroying the threads and loop. diff --git a/chrome/browser/extensions/extension_data_deleter.cc b/chrome/browser/extensions/extension_data_deleter.cc index ad97271..3cae231 100644 --- a/chrome/browser/extensions/extension_data_deleter.cc +++ b/chrome/browser/extensions/extension_data_deleter.cc @@ -52,14 +52,13 @@ void ExtensionDataDeleter::StartDeleting( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind( &ExtensionDataDeleter::DeleteLocalStorageOnWebkitThread, deleter, - make_scoped_refptr(DOMStorageContext::GetForBrowserContext( - profile)))); + make_scoped_refptr(BrowserContext::GetDOMStorageContext(profile)))); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind( &ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread, deleter, - make_scoped_refptr(IndexedDBContext::GetForBrowserContext(profile)))); + make_scoped_refptr(BrowserContext::GetIndexedDBContext(profile)))); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index cb59225..bcc2ae0 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -3089,7 +3089,7 @@ TEST_F(ExtensionServiceTest, ClearExtensionData) { // Create local storage. We only simulate this by creating the backing file // since webkit is not initialized. - DOMStorageContext* context = DOMStorageContext::GetForBrowserContext( + DOMStorageContext* context = BrowserContext::GetDOMStorageContext( profile_.get()); FilePath lso_path = context->GetFilePath(origin_id); EXPECT_TRUE(file_util::CreateDirectory(lso_path.DirName())); @@ -3098,7 +3098,7 @@ TEST_F(ExtensionServiceTest, ClearExtensionData) { // Create indexed db. Similarly, it is enough to only simulate this by // creating the directory on the disk. - IndexedDBContext* idb_context = IndexedDBContext::GetForBrowserContext( + IndexedDBContext* idb_context = BrowserContext::GetIndexedDBContext( profile_.get()); FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); EXPECT_TRUE(file_util::CreateDirectory(idb_path)); @@ -3199,7 +3199,7 @@ TEST_F(ExtensionServiceTest, ClearAppData) { // Create local storage. We only simulate this by creating the backing file // since webkit is not initialized. - DOMStorageContext* context = DOMStorageContext::GetForBrowserContext( + DOMStorageContext* context = BrowserContext::GetDOMStorageContext( profile_.get()); FilePath lso_path = context->GetFilePath(origin_id); EXPECT_TRUE(file_util::CreateDirectory(lso_path.DirName())); @@ -3208,7 +3208,7 @@ TEST_F(ExtensionServiceTest, ClearAppData) { // Create indexed db. Similarly, it is enough to only simulate this by // creating the directory on the disk. - IndexedDBContext* idb_context = IndexedDBContext::GetForBrowserContext( + IndexedDBContext* idb_context = BrowserContext::GetIndexedDBContext( profile_.get()); FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); EXPECT_TRUE(file_util::CreateDirectory(idb_path)); diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 2e2d929..a823f41 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -47,7 +47,6 @@ #include "chrome/test/base/test_url_request_context_getter.h" #include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/mock_resource_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" @@ -691,10 +690,6 @@ ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { return protocol_handler_registry_.get(); } -WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { - return NULL; -} - FilePath TestingProfile::last_selected_directory() { return last_selected_directory_; } diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 32e96de..b44ffc3 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -47,7 +47,6 @@ class ProfileDependencyManager; class ProfileSyncService; class TemplateURLService; class TestingPrefService; -class WebKitContext; class TestingProfile : public Profile { public: @@ -241,7 +240,6 @@ class TestingProfile : public Profile { virtual bool IsSameProfile(Profile *p) OVERRIDE; virtual base::Time GetStartTime() const OVERRIDE; virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; - virtual WebKitContext* GetOffTheRecordWebKitContext(); virtual void MarkAsCleanShutdown() OVERRIDE {} virtual void InitExtensions(bool extensions_enabled) OVERRIDE {} virtual void InitPromoResources() OVERRIDE {} diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 4bfc9e7..4f27824 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc @@ -8,7 +8,6 @@ #include "content/browser/file_system/browser_file_system_helper.h" #include "content/browser/in_process_webkit/dom_storage_context_impl.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.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" @@ -28,17 +27,19 @@ using webkit_database::DatabaseTracker; // Key names on BrowserContext. static const char* kAppCacheServicKeyName = "content_appcache_service_tracker"; static const char* kDatabaseTrackerKeyName = "content_database_tracker"; +static const char* kDOMStorageContextKeyName = "content_dom_storage_context"; static const char* kFileSystemContextKeyName = "content_file_system_context"; +static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; static const char* kQuotaManagerKeyName = "content_quota_manager"; -static const char* kWebKitContextKeyName = "content_webkit_context"; namespace content { void CreateQuotaManagerAndClients(BrowserContext* context) { if (context->GetUserData(kQuotaManagerKeyName)) { DCHECK(context->GetUserData(kDatabaseTrackerKeyName)); + DCHECK(context->GetUserData(kDOMStorageContextKeyName)); DCHECK(context->GetUserData(kFileSystemContextKeyName)); - DCHECK(context->GetUserData(kWebKitContextKeyName)); + DCHECK(context->GetUserData(kIndexedDBContextKeyName)); return; } @@ -70,13 +71,20 @@ void CreateQuotaManagerAndClients(BrowserContext* context) { context->SetUserData(kDatabaseTrackerKeyName, new UserDataAdapter<DatabaseTracker>(db_tracker)); - scoped_refptr<WebKitContext> webkit_context = new WebKitContext( - context->IsOffTheRecord(), context->GetPath(), - context->GetSpecialStoragePolicy(), quota_manager->proxy(), + FilePath path = context->IsOffTheRecord() ? FilePath() : context->GetPath(); + scoped_refptr<DOMStorageContext> dom_storage_context = + new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); + context->SetUserData( + kDOMStorageContextKeyName, + new UserDataAdapter<DOMStorageContext>(dom_storage_context)); + + scoped_refptr<IndexedDBContext> indexed_db_context = new IndexedDBContextImpl( + path, context->GetSpecialStoragePolicy(), quota_manager->proxy(), BrowserThread::GetMessageLoopProxyForThread( BrowserThread::WEBKIT_DEPRECATED)); - context->SetUserData(kWebKitContextKeyName, - new UserDataAdapter<WebKitContext>(webkit_context)); + context->SetUserData( + kIndexedDBContextKeyName, + new UserDataAdapter<IndexedDBContext>(indexed_db_context)); scoped_refptr<ChromeAppCacheService> appcache_service = new ChromeAppCacheService(quota_manager->proxy()); @@ -127,9 +135,17 @@ QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); } -WebKitContext* BrowserContext::GetWebKitContext(BrowserContext* context) { +DOMStorageContext* BrowserContext::GetDOMStorageContext( + BrowserContext* context) { CreateQuotaManagerAndClients(context); - return UserDataAdapter<WebKitContext>::Get(context, kWebKitContextKeyName); + return UserDataAdapter<DOMStorageContext>::Get( + context, kDOMStorageContextKeyName); +} + +IndexedDBContext* BrowserContext::GetIndexedDBContext(BrowserContext* context) { + CreateQuotaManagerAndClients(context); + return UserDataAdapter<IndexedDBContext>::Get( + context, kIndexedDBContextKeyName); } DatabaseTracker* BrowserContext::GetDatabaseTracker(BrowserContext* context) { @@ -168,9 +184,9 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) { if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>( - DOMStorageContextImpl::GetForBrowserContext(browser_context)); + GetDOMStorageContext(browser_context)); IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( - IndexedDBContext::GetForBrowserContext(browser_context)); + GetIndexedDBContext(browser_context)); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind(&SaveSessionStateOnWebkitThread, @@ -181,11 +197,11 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) { void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) { DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>( - DOMStorageContextImpl::GetForBrowserContext(browser_context)); + GetDOMStorageContext(browser_context)); dom_context->set_clear_local_state_on_exit(true); IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( - IndexedDBContext::GetForBrowserContext(browser_context)); + GetIndexedDBContext(browser_context)); indexed_db->set_clear_local_state_on_exit(true); GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true); @@ -208,7 +224,7 @@ void BrowserContext::PurgeMemory(BrowserContext* browser_context) { if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>( - DOMStorageContextImpl::GetForBrowserContext(browser_context)); + GetDOMStorageContext(browser_context)); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind(&PurgeMemoryOnWebkitThread, @@ -217,6 +233,7 @@ void BrowserContext::PurgeMemory(BrowserContext* browser_context) { } BrowserContext::~BrowserContext() { + // These message loop checks are just to avoid leaks in unittests. if (GetUserData(kDatabaseTrackerKeyName) && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { BrowserThread::PostTask( @@ -224,6 +241,15 @@ BrowserContext::~BrowserContext() { base::Bind(&webkit_database::DatabaseTracker::Shutdown, GetDatabaseTracker(this))); } + + if (GetUserData(kDOMStorageContextKeyName) && + BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { + DOMStorageContext* dom_storage_context = + (static_cast<UserDataAdapter<DOMStorageContext>*>( + GetUserData(kDOMStorageContextKeyName)))->release(); + BrowserThread::ReleaseSoon( + BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context); + } } } // namespace content diff --git a/content/browser/in_process_webkit/dom_storage_area.h b/content/browser/in_process_webkit/dom_storage_area.h index be4520f..2414a43 100644 --- a/content/browser/in_process_webkit/dom_storage_area.h +++ b/content/browser/in_process_webkit/dom_storage_area.h @@ -50,7 +50,7 @@ class DOMStorageArea { // The storage area we wrap. scoped_ptr<WebKit::WebStorageArea> storage_area_; - // Our storage area id. Unique to our parent WebKitContext. + // Our storage area id. Unique to our parent DOMStorageContext. int64 id_; // The DOMStorageNamespace that owns us. diff --git a/content/browser/in_process_webkit/dom_storage_browsertest.cc b/content/browser/in_process_webkit/dom_storage_browsertest.cc index 922e96f..9f335fc 100644 --- a/content/browser/in_process_webkit/dom_storage_browsertest.cc +++ b/content/browser/in_process_webkit/dom_storage_browsertest.cc @@ -8,7 +8,6 @@ #include "base/test/thread_test_helper.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/browser/in_process_webkit/dom_storage_context_impl.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" #include "content/test/test_browser_context.h" @@ -82,11 +81,11 @@ IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, MAYBE_ClearLocalState) { { TestBrowserContext browser_context; browser_context.SetSpecialStoragePolicy(new TestSpecialStoragePolicy()); - WebKitContext* webkit_context = BrowserContext::GetWebKitContext( - &browser_context); - webkit_context->dom_storage_context()-> - set_data_path_for_testing(temp_dir.path()); - webkit_context->dom_storage_context()->set_clear_local_state_on_exit(true); + DOMStorageContextImpl* dom_storage_context = + static_cast<DOMStorageContextImpl*>( + BrowserContext::GetDOMStorageContext(&browser_context)); + dom_storage_context->set_data_path_for_testing(temp_dir.path()); + dom_storage_context->set_clear_local_state_on_exit(true); } // Make sure we wait until the destructor has run. scoped_refptr<base::ThreadTestHelper> helper( diff --git a/content/browser/in_process_webkit/dom_storage_context_impl.cc b/content/browser/in_process_webkit/dom_storage_context_impl.cc index 4f9cbde..b4d3bf6 100644 --- a/content/browser/in_process_webkit/dom_storage_context_impl.cc +++ b/content/browser/in_process_webkit/dom_storage_context_impl.cc @@ -12,16 +12,13 @@ #include "base/string_util.h" #include "content/browser/in_process_webkit/dom_storage_area.h" #include "content/browser/in_process_webkit/dom_storage_namespace.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/common/dom_storage_common.h" -#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "webkit/glue/webkit_glue.h" #include "webkit/quota/special_storage_policy.h" -using content::BrowserContext; using content::BrowserThread; using content::DOMStorageContext; using WebKit::WebSecurityOrigin; @@ -59,13 +56,8 @@ void ClearLocalState(const FilePath& domstorage_path, } // namespace -DOMStorageContext* DOMStorageContext::GetForBrowserContext( - BrowserContext* context) { - return BrowserContext::GetWebKitContext(context)->dom_storage_context(); -} - DOMStorageContextImpl::DOMStorageContextImpl( - WebKitContext* webkit_context, + const FilePath& data_path, quota::SpecialStoragePolicy* special_storage_policy) : last_storage_area_id_(0), last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId), @@ -73,7 +65,7 @@ DOMStorageContextImpl::DOMStorageContextImpl( clear_local_state_on_exit_(false), save_session_state_(false), special_storage_policy_(special_storage_policy) { - data_path_ = webkit_context->data_path(); + data_path_ = data_path; } DOMStorageContextImpl::~DOMStorageContextImpl() { diff --git a/content/browser/in_process_webkit/dom_storage_context_impl.h b/content/browser/in_process_webkit/dom_storage_context_impl.h index 2b1a6ba..701b68a 100644 --- a/content/browser/in_process_webkit/dom_storage_context_impl.h +++ b/content/browser/in_process_webkit/dom_storage_context_impl.h @@ -18,13 +18,12 @@ class DOMStorageArea; class DOMStorageMessageFilter; class DOMStorageNamespace; -class WebKitContext; namespace quota { class SpecialStoragePolicy; } -// This is owned by WebKitContext and is all the dom storage information that's +// This is owned by BrowserContext and is all the dom storage information that's // shared by all the DOMStorageMessageFilters that share the same browser // context. The specifics of responsibilities are fairly well documented here // and in StorageNamespace and StorageArea. Everything is only to be accessed @@ -32,7 +31,8 @@ class SpecialStoragePolicy; class CONTENT_EXPORT DOMStorageContextImpl : NON_EXPORTED_BASE(public content::DOMStorageContext) { public: - DOMStorageContextImpl(WebKitContext* webkit_context, + // If |data_path| is empty, nothing will be saved to disk. + DOMStorageContextImpl(const FilePath& data_path, quota::SpecialStoragePolicy* special_storage_policy); virtual ~DOMStorageContextImpl(); diff --git a/content/browser/in_process_webkit/dom_storage_message_filter.cc b/content/browser/in_process_webkit/dom_storage_message_filter.cc index 844d0c0..39a53fe 100644 --- a/content/browser/in_process_webkit/dom_storage_message_filter.cc +++ b/content/browser/in_process_webkit/dom_storage_message_filter.cc @@ -43,8 +43,8 @@ ScopedStorageEventContext::~ScopedStorageEventContext() { } DOMStorageMessageFilter::DOMStorageMessageFilter( - int process_id, WebKitContext* webkit_context) - : webkit_context_(webkit_context), + int process_id, DOMStorageContextImpl* dom_storage_context) + : dom_storage_context_(dom_storage_context), process_id_(process_id) { } diff --git a/content/browser/in_process_webkit/dom_storage_message_filter.h b/content/browser/in_process_webkit/dom_storage_message_filter.h index 1d44aba..406b1ad 100644 --- a/content/browser/in_process_webkit/dom_storage_message_filter.h +++ b/content/browser/in_process_webkit/dom_storage_message_filter.h @@ -10,7 +10,6 @@ #include "base/message_loop_helpers.h" #include "base/process.h" #include "content/browser/in_process_webkit/dom_storage_area.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/common/dom_storage_common.h" #include "content/public/browser/browser_message_filter.h" @@ -24,7 +23,8 @@ struct DOMStorageMsg_Event_Params; class DOMStorageMessageFilter : public content::BrowserMessageFilter { public: // Only call the constructor from the UI thread. - DOMStorageMessageFilter(int process_id, WebKitContext* webkit_context); + DOMStorageMessageFilter(int process_id, + DOMStorageContextImpl* dom_storage_context); // content::BrowserMessageFilter implementation virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; @@ -65,9 +65,7 @@ class DOMStorageMessageFilter : public content::BrowserMessageFilter { void OnStorageEvent(const DOMStorageMsg_Event_Params& params); // A shortcut for accessing our context. - DOMStorageContextImpl* Context() { - return webkit_context_->dom_storage_context(); - } + DOMStorageContextImpl* Context() { return dom_storage_context_; } // Use whenever there's a chance OnStorageEvent will be called. class ScopedStorageEventContext { @@ -82,8 +80,7 @@ class DOMStorageMessageFilter : public content::BrowserMessageFilter { static DOMStorageMessageFilter* storage_event_message_filter; static const GURL* storage_event_url_; - // Data shared between renderer processes with the same browser context. - scoped_refptr<WebKitContext> webkit_context_; + scoped_refptr<DOMStorageContextImpl> dom_storage_context_; // Used to dispatch messages to the correct view host. int process_id_; diff --git a/content/browser/in_process_webkit/dom_storage_namespace.h b/content/browser/in_process_webkit/dom_storage_namespace.h index 989cafc..208a6d9 100644 --- a/content/browser/in_process_webkit/dom_storage_namespace.h +++ b/content/browser/in_process_webkit/dom_storage_namespace.h @@ -68,7 +68,7 @@ class DOMStorageNamespace { // The WebKit storage namespace we manage. scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_; - // Our id. Unique to our parent WebKitContext class. + // Our id. Unique to our parent DOMStorageContext class. int64 id_; // The path used to create us, so we can recreate our WebStorageNamespace on diff --git a/content/browser/in_process_webkit/dom_storage_unittest.cc b/content/browser/in_process_webkit/dom_storage_unittest.cc index b8e26d9..1b0f41f 100644 --- a/content/browser/in_process_webkit/dom_storage_unittest.cc +++ b/content/browser/in_process_webkit/dom_storage_unittest.cc @@ -5,7 +5,6 @@ #include "base/file_path.h" #include "base/file_util.h" #include "content/browser/browser_thread_impl.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/in_process_webkit/dom_storage_context_impl.h" #include "content/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" @@ -57,8 +56,10 @@ TEST_F(DOMStorageTest, SessionOnly) { ASSERT_EQ(1, file_util::WriteFile(permanent_database_path, ".", 1)); // Inject MockSpecialStoragePolicy into DOMStorageContext. - BrowserContext::GetWebKitContext(browser_context.get())-> - dom_storage_context()->special_storage_policy_ = special_storage_policy; + DOMStorageContextImpl* dom_storage_context = + static_cast<DOMStorageContextImpl*>( + BrowserContext::GetDOMStorageContext(browser_context.get())); + dom_storage_context->special_storage_policy_ = special_storage_policy; // Delete the TestBrowserContext but own the temp dir. This way the // temporary data directory stays alive long enough to conduct the test. @@ -103,8 +104,8 @@ TEST_F(DOMStorageTest, SaveSessionState) { // Inject MockSpecialStoragePolicy into DOMStorageContext. DOMStorageContextImpl* dom_storage_context = - BrowserContext::GetWebKitContext(browser_context.get())-> - dom_storage_context(); + static_cast<DOMStorageContextImpl*>( + BrowserContext::GetDOMStorageContext(browser_context.get())); dom_storage_context->special_storage_policy_ = special_storage_policy; dom_storage_context->set_clear_local_state_on_exit(true); diff --git a/content/browser/in_process_webkit/indexed_db_browsertest.cc b/content/browser/in_process_webkit/indexed_db_browsertest.cc index 0e134f6..f4108e3 100644 --- a/content/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/content/browser/in_process_webkit/indexed_db_browsertest.cc @@ -15,7 +15,6 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/ui_test_utils.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/common/content_switches.h" #include "webkit/database/database_util.h" @@ -161,8 +160,9 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, MAYBE_ClearLocalState) { // Create some indexedDB paths. // With the levelDB backend, these are directories. - WebKitContext* webkit_context = BrowserContext::GetWebKitContext(&profile); - IndexedDBContextImpl* idb_context = webkit_context->indexed_db_context(); + IndexedDBContextImpl* idb_context = + static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(&profile)); idb_context->set_data_path_for_testing(temp_dir.path()); protected_path = idb_context->GetFilePathForTesting( DatabaseUtil::GetOriginIdentifier(kProtectedOrigin)); @@ -214,8 +214,9 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, // Create some indexedDB paths. // With the levelDB backend, these are directories. - WebKitContext* webkit_context = BrowserContext::GetWebKitContext(&profile); - IndexedDBContextImpl* idb_context = webkit_context->indexed_db_context(); + IndexedDBContextImpl* idb_context = + static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(&profile)); // Override the storage policy with our own. idb_context->special_storage_policy_ = special_storage_policy; @@ -270,8 +271,9 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, MAYBE_SaveSessionState) { // Create some indexedDB paths. // With the levelDB backend, these are directories. - WebKitContext* webkit_context = BrowserContext::GetWebKitContext(&profile); - IndexedDBContextImpl* idb_context = webkit_context->indexed_db_context(); + IndexedDBContextImpl* idb_context = + static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(&profile)); // Override the storage policy with our own. idb_context->special_storage_policy_ = special_storage_policy; diff --git a/content/browser/in_process_webkit/indexed_db_context_impl.cc b/content/browser/in_process_webkit/indexed_db_context_impl.cc index 4c841a0..2d0c1ff 100644 --- a/content/browser/in_process_webkit/indexed_db_context_impl.cc +++ b/content/browser/in_process_webkit/indexed_db_context_impl.cc @@ -12,8 +12,6 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "content/browser/in_process_webkit/indexed_db_quota_client.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 "content/public/common/content_switches.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" @@ -26,7 +24,6 @@ #include "webkit/quota/quota_manager.h" #include "webkit/quota/special_storage_policy.h" -using content::BrowserContext; using content::BrowserThread; using content::IndexedDBContext; using webkit_database::DatabaseUtil; @@ -91,13 +88,8 @@ void ClearLocalState( } // namespace -IndexedDBContext* IndexedDBContext::GetForBrowserContext( - BrowserContext* context) { - return BrowserContext::GetWebKitContext(context)->indexed_db_context(); -} - IndexedDBContextImpl::IndexedDBContextImpl( - WebKitContext* webkit_context, + const FilePath& data_path, quota::SpecialStoragePolicy* special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, base::MessageLoopProxy* webkit_thread_loop) @@ -105,8 +97,8 @@ IndexedDBContextImpl::IndexedDBContextImpl( save_session_state_(false), special_storage_policy_(special_storage_policy), quota_manager_proxy_(quota_manager_proxy) { - if (!webkit_context->is_incognito()) - data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); + if (!data_path.empty()) + data_path_ = data_path.Append(kIndexedDBDirectory); if (quota_manager_proxy && !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { quota_manager_proxy->RegisterClient( diff --git a/content/browser/in_process_webkit/indexed_db_context_impl.h b/content/browser/in_process_webkit/indexed_db_context_impl.h index 14833ea..f2714c0 100644 --- a/content/browser/in_process_webkit/indexed_db_context_impl.h +++ b/content/browser/in_process_webkit/indexed_db_context_impl.h @@ -19,7 +19,6 @@ class GURL; class FilePath; -class WebKitContext; namespace WebKit { class WebIDBFactory; @@ -37,7 +36,8 @@ class SpecialStoragePolicy; class CONTENT_EXPORT IndexedDBContextImpl : NON_EXPORTED_BASE(public content::IndexedDBContext) { public: - IndexedDBContextImpl(WebKitContext* webkit_context, + // If |data_path| is empty, nothing will be saved to disk. + IndexedDBContextImpl(const FilePath& data_path, quota::SpecialStoragePolicy* special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, base::MessageLoopProxy* webkit_thread_loop); @@ -78,6 +78,8 @@ class CONTENT_EXPORT IndexedDBContextImpl quota::QuotaManagerProxy* quota_manager_proxy(); + FilePath data_path() const { return data_path_; } + // For unit tests allow to override the |data_path_|. void set_data_path_for_testing(const FilePath& data_path) { data_path_ = data_path; diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc index dc3f9d3..20d8bb4 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -61,8 +61,8 @@ void DeleteOnWebKitThread(T* obj) { } IndexedDBDispatcherHost::IndexedDBDispatcherHost( - int process_id, WebKitContext* webkit_context) - : webkit_context_(webkit_context), + int process_id, IndexedDBContextImpl* indexed_db_context) + : indexed_db_context_(indexed_db_context), ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( new DatabaseDispatcherHost(this))), ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( @@ -74,7 +74,7 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost( ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( new TransactionDispatcherHost(this))), process_id_(process_id) { - DCHECK(webkit_context_.get()); + DCHECK(indexed_db_context_.get()); } IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { @@ -206,7 +206,7 @@ WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); - FilePath base_path = webkit_context_->data_path(); + FilePath base_path = indexed_db_context_->data_path(); FilePath indexed_db_path; if (!base_path.empty()) { indexed_db_path = base_path.Append( @@ -232,7 +232,7 @@ void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( void IndexedDBDispatcherHost::OnIDBFactoryOpen( const IndexedDBHostMsg_FactoryOpen_Params& params) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); - FilePath base_path = webkit_context_->data_path(); + FilePath base_path = indexed_db_context_->data_path(); FilePath indexed_db_path; if (!base_path.empty()) { indexed_db_path = base_path.Append( @@ -260,7 +260,7 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { - FilePath base_path = webkit_context_->data_path(); + FilePath base_path = indexed_db_context_->data_path(); FilePath indexed_db_path; if (!base_path.empty()) { indexed_db_path = base_path.Append( diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h index fd89dd8..d4ee9c9d 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -8,11 +8,11 @@ #include "base/basictypes.h" #include "base/id_map.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/public/browser/browser_message_filter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" class GURL; +class IndexedDBContextImpl; class IndexedDBKey; class IndexedDBKeyRange; class NullableString16; @@ -44,7 +44,8 @@ class SerializedScriptValue; class IndexedDBDispatcherHost : public content::BrowserMessageFilter { public: // Only call the constructor from the UI thread. - IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context); + IndexedDBDispatcherHost(int process_id, + IndexedDBContextImpl* indexed_db_context); // content::BrowserMessageFilter implementation. virtual void OnChannelClosing() OVERRIDE; @@ -57,9 +58,7 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { void TransactionComplete(int32 transaction_id); // A shortcut for accessing our context. - IndexedDBContextImpl* Context() { - return webkit_context_->indexed_db_context(); - } + IndexedDBContextImpl* Context() { return indexed_db_context_; } // The various IndexedDBCallbacks children call these methods to add the // results into the applicable map. See below for more details. @@ -308,8 +307,7 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { WebIDBTransactionIDToSizeMap transaction_size_map_; }; - // Data shared between renderer processes with the same browser context. - scoped_refptr<WebKitContext> webkit_context_; + scoped_refptr<IndexedDBContextImpl> indexed_db_context_; // Only access on WebKit thread. scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 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 8b98dd8..d77e127 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 @@ -13,7 +13,6 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.h" #include "content/browser/in_process_webkit/indexed_db_quota_client.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/database/database_util.h" @@ -49,8 +48,8 @@ class IndexedDBQuotaClientTest : public testing::Test { BrowserThread::FILE_USER_BLOCKING, &message_loop_), io_thread_(BrowserThread::IO, &message_loop_) { browser_context_.reset(new TestBrowserContext()); - idb_context_ = BrowserContext::GetWebKitContext(browser_context_.get())-> - indexed_db_context(); + idb_context_ = static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(browser_context_.get())); message_loop_.RunAllPending(); setup_temp_dir(); } diff --git a/content/browser/in_process_webkit/webkit_context.cc b/content/browser/in_process_webkit/webkit_context.cc deleted file mode 100644 index 678f903..0000000 --- a/content/browser/in_process_webkit/webkit_context.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2011 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/in_process_webkit/webkit_context.h" - -#include "base/bind.h" -#include "base/command_line.h" -#include "content/browser/in_process_webkit/dom_storage_context_impl.h" -#include "content/browser/in_process_webkit/indexed_db_context_impl.h" -#include "content/public/browser/browser_thread.h" - -using content::BrowserThread; - -WebKitContext::WebKitContext( - bool is_incognito, const FilePath& data_path, - quota::SpecialStoragePolicy* special_storage_policy, - quota::QuotaManagerProxy* quota_manager_proxy, - base::MessageLoopProxy* webkit_thread_loop) - : data_path_(is_incognito ? FilePath() : data_path), - is_incognito_(is_incognito), - ALLOW_THIS_IN_INITIALIZER_LIST( - dom_storage_context_(new DOMStorageContextImpl( - this, special_storage_policy))), - ALLOW_THIS_IN_INITIALIZER_LIST( - indexed_db_context_(new IndexedDBContextImpl( - this, special_storage_policy, quota_manager_proxy, - webkit_thread_loop))) { -} - -WebKitContext::~WebKitContext() { - // If the WebKit thread was ever spun up, delete the object there. The task - // will just get deleted if the WebKit thread isn't created (which only - // happens during testing). - DOMStorageContextImpl* dom_storage_context = dom_storage_context_.release(); - if (!BrowserThread::ReleaseSoon( - BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context)) { - // The WebKit thread wasn't created, and the task got deleted without - // freeing the DOMStorageContext, so delete it manually. - dom_storage_context->Release(); - } -} diff --git a/content/browser/in_process_webkit/webkit_context.h b/content/browser/in_process_webkit/webkit_context.h deleted file mode 100644 index 286235e..0000000 --- a/content/browser/in_process_webkit/webkit_context.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2011 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_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ -#define CONTENT_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ -#pragma once - -#include <vector> - -#include "base/file_path.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "content/common/content_export.h" - -class DOMStorageContextImpl; -class IndexedDBContextImpl; - -namespace base { -class MessageLoopProxy; -} - -namespace quota { -class QuotaManagerProxy; -class SpecialStoragePolicy; -} - -// There's one WebKitContext per browser context. Various DispatcherHost -// classes have a pointer to the Context to store shared state. Unfortunately, -// this class has become a bit of a dumping ground for calls made on the UI -// thread that need to be proxied over to the WebKit thread. -// -// This class is created on the UI thread and accessed on the UI, IO, and WebKit -// threads. -class CONTENT_EXPORT WebKitContext - : public base::RefCountedThreadSafe<WebKitContext> { - public: - WebKitContext(bool is_incognito, const FilePath& data_path, - quota::SpecialStoragePolicy* special_storage_policy, - quota::QuotaManagerProxy* quota_manager_proxy, - base::MessageLoopProxy* webkit_thread_loop); - - const FilePath& data_path() const { return data_path_; } - bool is_incognito() const { return is_incognito_; } - - DOMStorageContextImpl* dom_storage_context() { return dom_storage_context_; } - IndexedDBContextImpl* indexed_db_context() { return indexed_db_context_; } - - private: - friend class base::RefCountedThreadSafe<WebKitContext>; - virtual ~WebKitContext(); - - // Copies of browser context data that can be accessed on any thread. - const FilePath data_path_; - const bool is_incognito_; - - scoped_refptr<DOMStorageContextImpl> dom_storage_context_; - scoped_refptr<IndexedDBContextImpl> indexed_db_context_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(WebKitContext); -}; - -#endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CONTEXT_H_ diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 5cbaae8..143eec4 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -275,7 +275,8 @@ RenderMessageFilter::RenderMessageFilter( resource_context_(browser_context->GetResourceContext()), render_widget_helper_(render_widget_helper), incognito_(browser_context->IsOffTheRecord()), - webkit_context_(BrowserContext::GetWebKitContext(browser_context)), + dom_storage_context_(static_cast<DOMStorageContextImpl*>( + BrowserContext::GetDOMStorageContext(browser_context))), render_process_id_(render_process_id), cpu_usage_(0) { DCHECK(request_context_); @@ -408,7 +409,7 @@ void RenderMessageFilter::OnMsgCreateWindow( } *cloned_session_storage_namespace_id = - webkit_context_->dom_storage_context()->CloneSessionStorage( + dom_storage_context_->CloneSessionStorage( params.session_storage_namespace_id); render_widget_helper_->CreateNewWindow(params, peer_handle(), diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index ab01f80..bc0e0c9 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h @@ -19,16 +19,16 @@ #include "base/shared_memory.h" #include "base/string16.h" #include "build/build_config.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/public/browser/browser_message_filter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/surface/transport_dib.h" -struct FontDescriptor; +class DOMStorageContextImpl; class PluginServiceImpl; class RenderWidgetHelper; +struct FontDescriptor; struct ViewHostMsg_CreateWindow_Params; namespace WebKit { @@ -253,7 +253,7 @@ class RenderMessageFilter : public content::BrowserMessageFilter { // Initialized to 0, accessed on FILE thread only. base::TimeTicks last_plugin_refresh_time_; - scoped_refptr<WebKitContext> webkit_context_; + scoped_refptr<DOMStorageContextImpl> dom_storage_context_; int render_process_id_; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 416f68d..eba35b7 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -50,8 +50,10 @@ #include "content/browser/geolocation/geolocation_dispatcher_host.h" #include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_process_host.h" +#include "content/browser/in_process_webkit/dom_storage_context_impl.h" #include "content/browser/in_process_webkit/dom_storage_message_filter.h" #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" +#include "content/browser/in_process_webkit/indexed_db_context_impl.h" #include "content/browser/mime_registry_message_filter.h" #include "content/browser/plugin_service_impl.h" #include "content/browser/profiler_message_filter.h" @@ -473,9 +475,11 @@ void RenderProcessHostImpl::CreateMessageFilters() { GetID())); channel_->AddFilter(new ClipboardMessageFilter()); channel_->AddFilter(new DOMStorageMessageFilter(GetID(), - BrowserContext::GetWebKitContext(browser_context))); + static_cast<DOMStorageContextImpl*>( + BrowserContext::GetDOMStorageContext(browser_context)))); channel_->AddFilter(new IndexedDBDispatcherHost(GetID(), - BrowserContext::GetWebKitContext(browser_context))); + static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(browser_context)))); channel_->AddFilter(GeolocationDispatcherHost::New( GetID(), browser_context->GetGeolocationPermissionContext())); channel_->AddFilter(new GpuMessageFilter(GetID(), widget_helper_.get())); diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index ebacbb2..e193dc2 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -141,7 +141,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { if (!session_storage_namespace_) { DOMStorageContext* dom_storage_context = - DOMStorageContext::GetForBrowserContext(process()->GetBrowserContext()); + BrowserContext::GetDOMStorageContext(process()->GetBrowserContext()); session_storage_namespace_ = new SessionStorageNamespaceImpl( static_cast<DOMStorageContextImpl*>(dom_storage_context)); } diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index 8a2adfb3..2b99185 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc @@ -7,8 +7,8 @@ #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/host_zoom_map_impl.h" +#include "content/browser/in_process_webkit/indexed_db_context_impl.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "webkit/database/database_tracker.h" @@ -18,8 +18,8 @@ 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* kIndexedDBContextKeyName = "content_indexed_db_context"; static const char* kHostZoomMapKeyName = "content_host_zoom_map"; -static const char* kWebKitContextKeyName = "content_webkit_context"; using appcache::AppCacheService; using base::UserDataAdapter; @@ -62,10 +62,10 @@ DatabaseTracker* GetDatabaseTrackerForResourceContext( resource_context, kDatabaseTrackerKeyName); } -WebKitContext* GetWebKitContextForResourceContext( +IndexedDBContextImpl* GetIndexedDBContextForResourceContext( ResourceContext* resource_context) { - return UserDataAdapter<WebKitContext>::Get( - resource_context, kWebKitContextKeyName); + return UserDataAdapter<IndexedDBContextImpl>::Get( + resource_context, kIndexedDBContextKeyName); } ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( @@ -81,14 +81,20 @@ HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) { void EnsureResourceContextInitialized(BrowserContext* browser_context) { ResourceContext* resource_context = browser_context->GetResourceContext(); - - if (resource_context->GetUserData(kWebKitContextKeyName)) + if (resource_context->GetUserData(kIndexedDBContextKeyName)) { + DCHECK(resource_context->GetUserData(kAppCacheServicKeyName)); + DCHECK(resource_context->GetUserData(kBlobStorageContextKeyName)); + DCHECK(resource_context->GetUserData(kDatabaseTrackerKeyName)); + DCHECK(resource_context->GetUserData(kFileSystemContextKeyName)); + DCHECK(resource_context->GetUserData(kHostZoomMapKeyName)); return; + } resource_context->SetUserData( - kWebKitContextKeyName, - new UserDataAdapter<WebKitContext>( - BrowserContext::GetWebKitContext(browser_context))); + kIndexedDBContextKeyName, + new UserDataAdapter<IndexedDBContextImpl>( + static_cast<IndexedDBContextImpl*>( + BrowserContext::GetIndexedDBContext(browser_context)))); resource_context->SetUserData( kDatabaseTrackerKeyName, new UserDataAdapter<webkit_database::DatabaseTracker>( diff --git a/content/browser/resource_context_impl.h b/content/browser/resource_context_impl.h index 984456a..9e92eaf 100644 --- a/content/browser/resource_context_impl.h +++ b/content/browser/resource_context_impl.h @@ -7,8 +7,8 @@ #include "content/public/browser/resource_context.h" +class IndexedDBContextImpl; class ChromeBlobStorageContext; -class WebKitContext; namespace webkit_database { class DatabaseTracker; @@ -24,7 +24,7 @@ class HostZoomMap; // public API. webkit_database::DatabaseTracker* GetDatabaseTrackerForResourceContext( ResourceContext* resource_context); -WebKitContext* GetWebKitContextForResourceContext( +IndexedDBContextImpl* GetIndexedDBContextForResourceContext( ResourceContext* resource_context); ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext( ResourceContext* resource_context); diff --git a/content/browser/tab_contents/navigation_controller_impl.cc b/content/browser/tab_contents/navigation_controller_impl.cc index a7b6224..e8d722d 100644 --- a/content/browser/tab_contents/navigation_controller_impl.cc +++ b/content/browser/tab_contents/navigation_controller_impl.cc @@ -187,7 +187,7 @@ NavigationControllerImpl::NavigationControllerImpl( if (!session_storage_namespace_) { session_storage_namespace_ = new SessionStorageNamespaceImpl( static_cast<DOMStorageContextImpl*>( - DOMStorageContext::GetForBrowserContext(browser_context_))); + BrowserContext::GetDOMStorageContext(browser_context_))); } } diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index ec4cd08..da2e586 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -284,7 +284,7 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { new content::WorkerDevToolsMessageFilter(process_->GetData().id)); process_->GetHost()->AddFilter(new IndexedDBDispatcherHost( process_->GetData().id, - content::GetWebKitContextForResourceContext(resource_context_))); + content::GetIndexedDBContextForResourceContext(resource_context_))); } void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 6532bee..c59ec09 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -366,8 +366,6 @@ 'browser/in_process_webkit/indexed_db_transaction_callbacks.h', 'browser/in_process_webkit/session_storage_namespace_impl.cc', 'browser/in_process_webkit/session_storage_namespace_impl.h', - 'browser/in_process_webkit/webkit_context.cc', - 'browser/in_process_webkit/webkit_context.h', 'browser/in_process_webkit/webkit_thread.cc', 'browser/in_process_webkit/webkit_thread.h', 'browser/intents/intent_injector.cc', diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 5a93af0..874f450 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -32,12 +32,13 @@ class DatabaseTracker; } class FilePath; -class WebKitContext; namespace content { +class DOMStorageContext; class DownloadManager; class GeolocationPermissionContext; +class IndexedDBContext; class ResourceContext; class SpeechInputPreferences; @@ -45,9 +46,10 @@ class SpeechInputPreferences; // It lives on the UI thread. class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { public: - // Getter for the QuotaManager associated with the given BrowserContext. static quota::QuotaManager* GetQuotaManager(BrowserContext* browser_context); - static WebKitContext* GetWebKitContext(BrowserContext* browser_context); + static DOMStorageContext* GetDOMStorageContext( + BrowserContext* browser_context); + static IndexedDBContext* GetIndexedDBContext(BrowserContext* browser_context); static webkit_database::DatabaseTracker* GetDatabaseTracker( BrowserContext* browser_context); static appcache::AppCacheService* GetAppCacheService( diff --git a/content/public/browser/dom_storage_context.h b/content/public/browser/dom_storage_context.h index d94aa21..68415f1 100644 --- a/content/public/browser/dom_storage_context.h +++ b/content/public/browser/dom_storage_context.h @@ -28,9 +28,6 @@ class DOMStorageContext : public base::RefCountedThreadSafe<DOMStorageContext> { public: virtual ~DOMStorageContext() {} - CONTENT_EXPORT static DOMStorageContext* GetForBrowserContext( - BrowserContext* browser_context); - // Returns all the file paths of local storage files. virtual std::vector<FilePath> GetAllStorageFiles() = 0; diff --git a/content/public/browser/indexed_db_context.h b/content/public/browser/indexed_db_context.h index 79de40f..91b8664 100644 --- a/content/public/browser/indexed_db_context.h +++ b/content/public/browser/indexed_db_context.h @@ -20,17 +20,12 @@ class Time; namespace content { -class BrowserContext; - // Represents the per-BrowserContext IndexedDB data. // Call these methods only on the WebKit thread. class IndexedDBContext : public base::RefCountedThreadSafe<IndexedDBContext> { public: virtual ~IndexedDBContext() {} - CONTENT_EXPORT static IndexedDBContext* GetForBrowserContext( - BrowserContext* browser_context); - // Methods used in response to QuotaManager requests. virtual std::vector<GURL> GetAllOrigins() = 0; virtual int64 GetOriginDiskUsage(const GURL& origin_url) = 0; diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index c4e2e8a..201c0d6 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -11,7 +11,6 @@ #include "base/path_service.h" #include "base/threading/thread.h" #include "content/browser/download/download_manager_impl.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/geolocation_permission_context.h" #include "content/public/browser/speech_input_preferences.h" diff --git a/content/test/test_browser_context.cc b/content/test/test_browser_context.cc index b3dc416..f5830be 100644 --- a/content/test/test_browser_context.cc +++ b/content/test/test_browser_context.cc @@ -5,7 +5,6 @@ #include "content/test/test_browser_context.h" #include "base/file_path.h" -#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/mock_resource_context.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/quota/special_storage_policy.h" diff --git a/content/test/test_browser_context.h b/content/test/test_browser_context.h index ad2804e..2f878b9 100644 --- a/content/test/test_browser_context.h +++ b/content/test/test_browser_context.h @@ -14,8 +14,6 @@ #include "base/scoped_temp_dir.h" #include "content/public/browser/browser_context.h" -class WebKitContext; - namespace content { class MockResourceContext; } |