| Index: content/browser/storage_partition_impl.cc
|
| diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
|
| index ec092d20c12b88f14da77b3f0dec77007d886826..416802f4b2a7e756dc966edb995ffb8ca7ada542 100644
|
| --- a/content/browser/storage_partition_impl.cc
|
| +++ b/content/browser/storage_partition_impl.cc
|
| @@ -11,8 +11,10 @@
|
| #include "content/browser/gpu/shader_disk_cache.h"
|
| #include "content/public/browser/browser_context.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/cookie_store_map.h"
|
| #include "content/public/browser/dom_storage_context.h"
|
| #include "content/public/browser/indexed_db_context.h"
|
| +#include "content/public/common/url_constants.h"
|
| #include "net/base/completion_callback.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/cookies/cookie_monster.h"
|
| @@ -50,18 +52,17 @@ void ClearQuotaManagedOriginsOnIOThread(
|
| void ClearOriginOnIOThread(
|
| uint32 storage_mask,
|
| const GURL& storage_origin,
|
| - const scoped_refptr<net::URLRequestContextGetter>& request_context,
|
| + const scoped_refptr<net::CookieStore>& cookie_store,
|
| const scoped_refptr<quota::QuotaManager>& quota_manager) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
|
| - if (storage_mask & StoragePartition::kCookies) {
|
| + if (storage_mask & StoragePartition::kCookies && cookie_store.get()) {
|
| // Handle the cookies.
|
| - net::CookieMonster* cookie_monster =
|
| - request_context->GetURLRequestContext()->cookie_store()->
|
| - GetCookieMonster();
|
| - if (cookie_monster)
|
| + net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
|
| + if (cookie_monster) {
|
| cookie_monster->DeleteAllForHostAsync(
|
| storage_origin, net::CookieMonster::DeleteCallback());
|
| + }
|
| }
|
|
|
| // Handle all HTML5 storage other than DOMStorageContext.
|
| @@ -86,15 +87,13 @@ void ClearOriginOnIOThread(
|
|
|
| void ClearAllDataOnIOThread(
|
| uint32 storage_mask,
|
| - const scoped_refptr<net::URLRequestContextGetter>& request_context,
|
| - const scoped_refptr<quota::QuotaManager>& quota_manager) {
|
| + const scoped_refptr<quota::QuotaManager>& quota_manager,
|
| + const scoped_refptr<net::CookieStore>& cookie_store) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
|
| - if (storage_mask & StoragePartition::kCookies) {
|
| + if (storage_mask & StoragePartition::kCookies && cookie_store.get()) {
|
| // Handle the cookies.
|
| - net::CookieMonster* cookie_monster =
|
| - request_context->GetURLRequestContext()->cookie_store()->
|
| - GetCookieMonster();
|
| + net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
|
| if (cookie_monster)
|
| cookie_monster->DeleteAllAsync(net::CookieMonster::DeleteCallback());
|
| }
|
| @@ -160,6 +159,7 @@ StoragePartitionImpl::StoragePartitionImpl(
|
| webkit_database::DatabaseTracker* database_tracker,
|
| DOMStorageContextImpl* dom_storage_context,
|
| IndexedDBContextImpl* indexed_db_context,
|
| + scoped_ptr<CookieStoreMap> cookie_store_map,
|
| scoped_ptr<WebRTCIdentityStore> webrtc_identity_store)
|
| : partition_path_(partition_path),
|
| quota_manager_(quota_manager),
|
| @@ -168,7 +168,9 @@ StoragePartitionImpl::StoragePartitionImpl(
|
| database_tracker_(database_tracker),
|
| dom_storage_context_(dom_storage_context),
|
| indexed_db_context_(indexed_db_context),
|
| - webrtc_identity_store_(webrtc_identity_store.Pass()) {}
|
| + cookie_store_map_(cookie_store_map.Pass()),
|
| + webrtc_identity_store_(webrtc_identity_store.Pass()) {
|
| +}
|
|
|
| StoragePartitionImpl::~StoragePartitionImpl() {
|
| // These message loop checks are just to avoid leaks in unittests.
|
| @@ -189,7 +191,8 @@ StoragePartitionImpl::~StoragePartitionImpl() {
|
| StoragePartitionImpl* StoragePartitionImpl::Create(
|
| BrowserContext* context,
|
| bool in_memory,
|
| - const base::FilePath& partition_path) {
|
| + const base::FilePath& partition_path,
|
| + scoped_ptr<CookieStoreMap> cookie_store_map) {
|
| // Ensure that these methods are called on the UI thread, except for
|
| // unittests where a UI thread might not have been created.
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
|
| @@ -253,6 +256,7 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
|
| database_tracker.get(),
|
| dom_storage_context.get(),
|
| indexed_db_context.get(),
|
| + cookie_store_map.Pass(),
|
| webrtc_identity_store.Pass());
|
| }
|
|
|
| @@ -293,18 +297,20 @@ IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
|
| return indexed_db_context_.get();
|
| }
|
|
|
| +const CookieStoreMap& StoragePartitionImpl::GetCookieStoreMap() {
|
| + return *cookie_store_map_;
|
| +}
|
| +
|
| void StoragePartitionImpl::AsyncClearDataForOrigin(
|
| uint32 storage_mask,
|
| - const GURL& storage_origin,
|
| - net::URLRequestContextGetter* request_context_getter) {
|
| + const GURL& storage_origin) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&ClearOriginOnIOThread,
|
| - storage_mask,
|
| - storage_origin,
|
| - make_scoped_refptr(request_context_getter),
|
| + base::Bind(&ClearOriginOnIOThread, storage_mask, storage_origin,
|
| + make_scoped_refptr(GetCookieStoreMap().GetForScheme(
|
| + storage_origin.scheme())),
|
| quota_manager_));
|
|
|
| if (storage_mask & kLocalDomStorage)
|
| @@ -314,14 +320,18 @@ void StoragePartitionImpl::AsyncClearDataForOrigin(
|
| 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.
|
| + // We ignore the media request context because it shares the same cookie
|
| + // store as the main request context.
|
| + //
|
| + // TODO(ajwong): Do we need to remove data for all things in the map? This is
|
| + // different from old behavior.
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| base::Bind(&ClearAllDataOnIOThread,
|
| storage_mask,
|
| - url_request_context_,
|
| - quota_manager_));
|
| + quota_manager_,
|
| + make_scoped_refptr(
|
| + GetCookieStoreMap().GetForScheme(chrome::kHttpScheme))));
|
|
|
| if (storage_mask & kLocalDomStorage) {
|
| dom_storage_context_->GetLocalStorageUsage(
|
|
|