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

Unified Diff: content/browser/storage_partition_impl.cc

Issue 12317062: Expose StoragePartition clear methods for Android WebView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GetDefaultStoragePartition Created 7 years, 10 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 | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/storage_partition_impl.cc
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index d4ab7735ca4441ea5b1bb4af2b660da4ad3428d1..fbee33d70bea79670fb3dcafe08856453e5cdea8 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -30,7 +30,7 @@ void DoNothingStatusCallback(quota::QuotaStatusCode status) {
void ClearQuotaManagedOriginsOnIOThread(
const scoped_refptr<quota::QuotaManager>& quota_manager,
const std::set<GURL>& origins,
- quota::StorageType type) {
+ quota::StorageType quota_storage_type) {
// The QuotaManager manages all storage other than cookies, LocalStorage,
// and SessionStorage. This loop wipes out most HTML5 storage for the given
// origins.
@@ -38,54 +38,70 @@ void ClearQuotaManagedOriginsOnIOThread(
std::set<GURL>::const_iterator origin;
for (std::set<GURL>::const_iterator origin = origins.begin();
origin != origins.end(); ++origin) {
- quota_manager->DeleteOriginData(*origin, type,
+ quota_manager->DeleteOriginData(*origin, quota_storage_type,
quota::QuotaClient::kAllClientsMask,
base::Bind(&DoNothingStatusCallback));
}
}
void ClearOriginOnIOThread(
+ uint32 storage_mask,
const GURL& storage_origin,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
const scoped_refptr<quota::QuotaManager>& quota_manager) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- // Handle the cookies.
- net::CookieMonster* cookie_monster =
- request_context->GetURLRequestContext()->cookie_store()->
- GetCookieMonster();
- if (cookie_monster)
- cookie_monster->DeleteAllForHostAsync(
- storage_origin, net::CookieMonster::DeleteCallback());
+ if (storage_mask & StoragePartition::kCookies) {
+ // Handle the cookies.
+ net::CookieMonster* cookie_monster =
+ request_context->GetURLRequestContext()->cookie_store()->
+ GetCookieMonster();
+ if (cookie_monster)
+ cookie_monster->DeleteAllForHostAsync(
+ storage_origin, net::CookieMonster::DeleteCallback());
+ }
// Handle all HTML5 storage other than DOMStorageContext.
std::set<GURL> origins;
origins.insert(storage_origin);
- ClearQuotaManagedOriginsOnIOThread(quota_manager, origins,
- quota::kStorageTypePersistent);
- ClearQuotaManagedOriginsOnIOThread(quota_manager, origins,
- quota::kStorageTypeTemporary);
+ if (storage_mask & StoragePartition::kQuotaManagedTemporaryStorage) {
+ ClearQuotaManagedOriginsOnIOThread(quota_manager,
+ origins,
+ quota::kStorageTypeTemporary);
+ }
+ if (storage_mask & StoragePartition::kQuotaManagedPersistentStorage) {
+ ClearQuotaManagedOriginsOnIOThread(quota_manager,
+ origins,
+ quota::kStorageTypePersistent);
+ }
}
void ClearAllDataOnIOThread(
+ uint32 storage_mask,
const scoped_refptr<net::URLRequestContextGetter>& request_context,
const scoped_refptr<quota::QuotaManager>& quota_manager) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- // Handle the cookies.
- net::CookieMonster* cookie_monster =
- request_context->GetURLRequestContext()->cookie_store()->
- GetCookieMonster();
- if (cookie_monster)
- cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
+ if (storage_mask & StoragePartition::kCookies) {
+ // Handle the cookies.
+ net::CookieMonster* cookie_monster =
+ request_context->GetURLRequestContext()->cookie_store()->
+ GetCookieMonster();
+ if (cookie_monster)
+ cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
+ }
// Handle all HTML5 storage other than DOMStorageContext.
- quota_manager->GetOriginsModifiedSince(
- quota::kStorageTypePersistent, base::Time(),
- base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager));
- quota_manager->GetOriginsModifiedSince(
- quota::kStorageTypeTemporary, base::Time(),
- base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager));
+ if (storage_mask & StoragePartition::kQuotaManagedTemporaryStorage) {
+ quota_manager->GetOriginsModifiedSince(
+ quota::kStorageTypeTemporary, base::Time(),
+ base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager));
+ }
+ if (storage_mask & StoragePartition::kQuotaManagedPersistentStorage) {
+ quota_manager->GetOriginsModifiedSince(
+ quota::kStorageTypePersistent, base::Time(),
+ base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager));
+ }
}
void OnLocalStorageUsageInfo(
@@ -237,6 +253,7 @@ IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
}
void StoragePartitionImpl::AsyncClearDataForOrigin(
+ uint32 storage_mask,
const GURL& storage_origin,
net::URLRequestContextGetter* request_context_getter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -244,27 +261,36 @@ void StoragePartitionImpl::AsyncClearDataForOrigin(
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ClearOriginOnIOThread,
+ storage_mask,
storage_origin,
make_scoped_refptr(request_context_getter),
quota_manager_));
- GetDOMStorageContext()->DeleteLocalStorage(storage_origin);
+ if (storage_mask & kLocalDomStorage)
+ GetDOMStorageContext()->DeleteLocalStorage(storage_origin);
}
-void StoragePartitionImpl::AsyncClearAllData() {
+void StoragePartitionImpl::AsyncClearData(uint32 storage_mask) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// We ignore the media request context because it shares the same cookie store
// as the main request context.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ClearAllDataOnIOThread, url_request_context_,
+ base::Bind(&ClearAllDataOnIOThread,
+ storage_mask,
+ url_request_context_,
quota_manager_));
- dom_storage_context_->GetLocalStorageUsage(
- base::Bind(&OnLocalStorageUsageInfo, dom_storage_context_));
- dom_storage_context_->GetSessionStorageUsage(
- base::Bind(&OnSessionStorageUsageInfo, dom_storage_context_));
+ if (storage_mask & kLocalDomStorage) {
+ dom_storage_context_->GetLocalStorageUsage(
+ base::Bind(&OnLocalStorageUsageInfo, dom_storage_context_));
+ }
+
+ if (storage_mask & kSessionDomStorage) {
+ dom_storage_context_->GetSessionStorageUsage(
+ base::Bind(&OnSessionStorageUsageInfo, dom_storage_context_));
+ }
}
void StoragePartitionImpl::SetURLRequestContext(
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698