diff options
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/browser_context.cc | 10 | ||||
-rw-r--r-- | content/browser/in_process_webkit/dom_storage_context_impl.cc | 42 | ||||
-rw-r--r-- | content/browser/in_process_webkit/dom_storage_context_impl.h | 11 |
3 files changed, 48 insertions, 15 deletions
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 94d0661..da137f4 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc @@ -72,11 +72,11 @@ void CreateQuotaManagerAndClients(BrowserContext* context) { new UserDataAdapter<DatabaseTracker>(db_tracker)); FilePath path = context->IsOffTheRecord() ? FilePath() : context->GetPath(); - scoped_refptr<DOMStorageContext> dom_storage_context = + scoped_refptr<DOMStorageContextImpl> dom_storage_context = new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); context->SetUserData( kDOMStorageContextKeyName, - new UserDataAdapter<DOMStorageContext>(dom_storage_context)); + new UserDataAdapter<DOMStorageContextImpl>(dom_storage_context)); scoped_refptr<IndexedDBContext> indexed_db_context = new IndexedDBContextImpl( path, context->GetSpecialStoragePolicy(), quota_manager->proxy(), @@ -138,7 +138,7 @@ QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { DOMStorageContext* BrowserContext::GetDOMStorageContext( BrowserContext* context) { CreateQuotaManagerAndClients(context); - return UserDataAdapter<DOMStorageContext>::Get( + return UserDataAdapter<DOMStorageContextImpl>::Get( context, kDOMStorageContextKeyName); } @@ -250,8 +250,8 @@ BrowserContext::~BrowserContext() { if (GetUserData(kDOMStorageContextKeyName) && BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { - DOMStorageContext* dom_storage_context = - (static_cast<UserDataAdapter<DOMStorageContext>*>( + DOMStorageContextImpl* dom_storage_context = + (static_cast<UserDataAdapter<DOMStorageContextImpl>*>( GetUserData(kDOMStorageContextKeyName)))->release(); BrowserThread::ReleaseSoon( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context); 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 1be7c3f..8120fb5 100644 --- a/content/browser/in_process_webkit/dom_storage_context_impl.cc +++ b/content/browser/in_process_webkit/dom_storage_context_impl.cc @@ -204,6 +204,14 @@ void DOMStorageContextImpl::PurgeMemory() { } void DOMStorageContextImpl::DeleteDataModifiedSince(const base::Time& cutoff) { + if (!webkit_message_loop_->RunsTasksOnCurrentThread()) { + webkit_message_loop_->PostTask( + FROM_HERE, + base::Bind( + &DOMStorageContextImpl::DeleteDataModifiedSince, this, cutoff)); + return; + } + // Make sure that we don't delete a database that's currently being accessed // by unloading all of the databases temporarily. PurgeMemory(); @@ -226,7 +234,13 @@ void DOMStorageContextImpl::DeleteDataModifiedSince(const base::Time& cutoff) { } void DOMStorageContextImpl::DeleteLocalStorageFile(const FilePath& file_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); + if (!webkit_message_loop_->RunsTasksOnCurrentThread()) { + webkit_message_loop_->PostTask( + FROM_HERE, + base::Bind( + &DOMStorageContextImpl::DeleteLocalStorageFile, this, file_path)); + return; + } // Make sure that we don't delete a database that's currently being accessed // by unloading all of the databases temporarily. @@ -238,7 +252,6 @@ void DOMStorageContextImpl::DeleteLocalStorageFile(const FilePath& file_path) { } void DOMStorageContextImpl::DeleteForOrigin(const string16& origin_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); DeleteLocalStorageFile(GetFilePath(origin_id)); } @@ -295,11 +308,16 @@ void DOMStorageContextImpl::CompleteCloningSessionStorage( RegisterStorageNamespace(existing_namespace->Copy(clone_id)); } -base::SequencedTaskRunner* DOMStorageContextImpl::task_runner() const { - return webkit_message_loop_; -} +void DOMStorageContextImpl::GetAllStorageFiles( + const GetAllStorageFilesCallback& callback) { + if (!webkit_message_loop_->RunsTasksOnCurrentThread()) { + webkit_message_loop_->PostTask( + FROM_HERE, + base::Bind( + &DOMStorageContextImpl::GetAllStorageFiles, this, callback)); + return; + } -std::vector<FilePath> DOMStorageContextImpl::GetAllStorageFiles() { std::vector<FilePath> files; file_util::FileEnumerator file_enumerator( data_path_.Append(kLocalStorageDirectory), false, @@ -309,7 +327,17 @@ std::vector<FilePath> DOMStorageContextImpl::GetAllStorageFiles() { if (file_path.Extension() == kLocalStorageExtension) files.push_back(file_path); } - return files; + + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&DOMStorageContextImpl::RunAllStorageFilesCallback, + this, files, callback)); +} + +void DOMStorageContextImpl::RunAllStorageFilesCallback( + const std::vector<FilePath>& files, + const GetAllStorageFilesCallback& callback) { + callback.Run(files); } FilePath DOMStorageContextImpl::GetFilePath(const string16& origin_id) const { 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 2cd84f5..44120d6 100644 --- a/content/browser/in_process_webkit/dom_storage_context_impl.h +++ b/content/browser/in_process_webkit/dom_storage_context_impl.h @@ -12,6 +12,7 @@ #include "base/compiler_specific.h" #include "base/file_path.h" #include "base/gtest_prod_util.h" +#include "base/memory/ref_counted.h" #include "base/time.h" #include "content/public/browser/dom_storage_context.h" @@ -34,7 +35,8 @@ class SpecialStoragePolicy; // and in StorageNamespace and StorageArea. Everything is only to be accessed // on the WebKit thread unless noted otherwise. class CONTENT_EXPORT DOMStorageContextImpl : - NON_EXPORTED_BASE(public content::DOMStorageContext) { + NON_EXPORTED_BASE(public content::DOMStorageContext), + public base::RefCountedThreadSafe<DOMStorageContextImpl> { public: // If |data_path| is empty, nothing will be saved to disk. DOMStorageContextImpl(const FilePath& data_path, @@ -42,8 +44,8 @@ class CONTENT_EXPORT DOMStorageContextImpl : virtual ~DOMStorageContextImpl(); // DOMStorageContext implementation: - virtual base::SequencedTaskRunner* task_runner() const OVERRIDE; - virtual std::vector<FilePath> GetAllStorageFiles() OVERRIDE; + virtual void GetAllStorageFiles( + const GetAllStorageFilesCallback& callback) OVERRIDE; virtual FilePath GetFilePath(const string16& origin_id) const OVERRIDE; virtual void DeleteForOrigin(const string16& origin_id) OVERRIDE; virtual void DeleteLocalStorageFile(const FilePath& file_path) OVERRIDE; @@ -126,6 +128,9 @@ class CONTENT_EXPORT DOMStorageContextImpl : // The WebKit thread half of CloneSessionStorage above. void CompleteCloningSessionStorage(int64 existing_id, int64 clone_id); + void RunAllStorageFilesCallback(const std::vector<FilePath>& files, + const GetAllStorageFilesCallback& callback); + // The last used storage_area_id and storage_namespace_id's. For the storage // namespaces, IDs allocated on the UI thread are positive and count up while // IDs allocated on the IO thread are negative and count down. This allows us |