| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/storage_partition_impl.h" | 5 #include "content/browser/storage_partition_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "content/browser/browser_main_loop.h" | 17 #include "content/browser/browser_main_loop.h" |
| 17 #include "content/browser/fileapi/browser_file_system_helper.h" | 18 #include "content/browser/fileapi/browser_file_system_helper.h" |
| 18 #include "content/browser/geofencing/geofencing_manager.h" | 19 #include "content/browser/geofencing/geofencing_manager.h" |
| 19 #include "content/browser/gpu/shader_disk_cache.h" | 20 #include "content/browser/gpu/shader_disk_cache.h" |
| 20 #include "content/browser/host_zoom_map_impl.h" | 21 #include "content/browser/host_zoom_map_impl.h" |
| 21 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" | 22 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" |
| 22 #include "content/browser/notifications/platform_notification_context_impl.h" | 23 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 23 #include "content/common/dom_storage/dom_storage_types.h" | 24 #include "content/common/dom_storage/dom_storage_types.h" |
| 24 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/dom_storage_context.h" | 27 #include "content/public/browser/dom_storage_context.h" |
| 27 #include "content/public/browser/indexed_db_context.h" | 28 #include "content/public/browser/indexed_db_context.h" |
| 28 #include "content/public/browser/local_storage_usage_info.h" | 29 #include "content/public/browser/local_storage_usage_info.h" |
| 29 #include "content/public/browser/session_storage_usage_info.h" | 30 #include "content/public/browser/session_storage_usage_info.h" |
| 30 #include "net/base/completion_callback.h" | 31 #include "net/base/completion_callback.h" |
| 31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 33 #include "net/cookies/canonical_cookie.h" |
| 32 #include "net/cookies/cookie_monster.h" | 34 #include "net/cookies/cookie_monster.h" |
| 33 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 34 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
| 35 #include "storage/browser/database/database_tracker.h" | 37 #include "storage/browser/database/database_tracker.h" |
| 36 #include "storage/browser/quota/quota_manager.h" | 38 #include "storage/browser/quota/quota_manager.h" |
| 37 | 39 |
| 38 namespace content { | 40 namespace content { |
| 39 | 41 |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 44 bool DoesCookieMatchHost(const std::string& host, |
| 45 const net::CanonicalCookie& cookie) { |
| 46 return cookie.IsHostCookie() && cookie.IsDomainMatch(host); |
| 47 } |
| 48 |
| 42 void OnClearedCookies(const base::Closure& callback, int num_deleted) { | 49 void OnClearedCookies(const base::Closure& callback, int num_deleted) { |
| 43 // The final callback needs to happen from UI thread. | 50 // The final callback needs to happen from UI thread. |
| 44 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 51 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 45 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 46 BrowserThread::UI, FROM_HERE, | 53 BrowserThread::UI, FROM_HERE, |
| 47 base::Bind(&OnClearedCookies, callback, num_deleted)); | 54 base::Bind(&OnClearedCookies, callback, num_deleted)); |
| 48 return; | 55 return; |
| 49 } | 56 } |
| 50 | 57 |
| 51 callback.Run(); | 58 callback.Run(); |
| 52 } | 59 } |
| 53 | 60 |
| 54 void ClearCookiesOnIOThread( | 61 void ClearCookiesOnIOThread( |
| 55 const scoped_refptr<net::URLRequestContextGetter>& rq_context, | 62 const scoped_refptr<net::URLRequestContextGetter>& rq_context, |
| 56 const base::Time begin, | 63 const base::Time begin, |
| 57 const base::Time end, | 64 const base::Time end, |
| 58 const GURL& storage_origin, | 65 const GURL& storage_origin, |
| 59 const base::Closure& callback) { | 66 const base::Closure& callback) { |
| 60 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 61 net::CookieStore* cookie_store = rq_context-> | 68 net::CookieStore* cookie_store = rq_context-> |
| 62 GetURLRequestContext()->cookie_store(); | 69 GetURLRequestContext()->cookie_store(); |
| 63 if (storage_origin.is_empty()) { | 70 if (storage_origin.is_empty()) { |
| 64 cookie_store->DeleteAllCreatedBetweenAsync( | 71 cookie_store->DeleteAllCreatedBetweenAsync( |
| 65 begin, | 72 begin, |
| 66 end, | 73 end, |
| 67 base::Bind(&OnClearedCookies, callback)); | 74 base::Bind(&OnClearedCookies, callback)); |
| 68 } else { | 75 } else { |
| 69 cookie_store->DeleteAllCreatedBetweenForHostAsync( | 76 // TODO(mkwst): It's not clear whether removing host cookies is the correct |
| 70 begin, | 77 // behavior. We might want to remove all domain-matching cookies instead. |
| 71 end, | 78 // Also, this code path may be dead anyways. |
| 72 storage_origin, base::Bind(&OnClearedCookies, callback)); | 79 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
| 80 begin, end, |
| 81 StoragePartitionImpl::CreatePredicateForHostCookies(storage_origin), |
| 82 base::Bind(&OnClearedCookies, callback)); |
| 73 } | 83 } |
| 74 } | 84 } |
| 75 | 85 |
| 76 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, | 86 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, |
| 77 const base::Closure& callback) { | 87 const base::Closure& callback) { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 88 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 79 if (*deletion_task_count == 0) { | 89 if (*deletion_task_count == 0) { |
| 80 delete deletion_task_count; | 90 delete deletion_task_count; |
| 81 callback.Run(); | 91 callback.Run(); |
| 82 } | 92 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) | 225 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) |
| 216 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; | 226 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; |
| 217 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) | 227 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) |
| 218 quota_client_mask |= storage::QuotaClient::kServiceWorker; | 228 quota_client_mask |= storage::QuotaClient::kServiceWorker; |
| 219 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) | 229 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) |
| 220 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; | 230 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; |
| 221 | 231 |
| 222 return quota_client_mask; | 232 return quota_client_mask; |
| 223 } | 233 } |
| 224 | 234 |
| 235 // static |
| 236 net::CookieStore::CookiePredicate |
| 237 StoragePartitionImpl::CreatePredicateForHostCookies(const GURL& url) { |
| 238 return base::Bind(&DoesCookieMatchHost, url.host()); |
| 239 } |
| 240 |
| 225 // Helper for deleting quota managed data from a partition. | 241 // Helper for deleting quota managed data from a partition. |
| 226 // | 242 // |
| 227 // Most of the operations in this class are done on IO thread. | 243 // Most of the operations in this class are done on IO thread. |
| 228 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { | 244 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { |
| 229 QuotaManagedDataDeletionHelper(uint32_t remove_mask, | 245 QuotaManagedDataDeletionHelper(uint32_t remove_mask, |
| 230 uint32_t quota_storage_remove_mask, | 246 uint32_t quota_storage_remove_mask, |
| 231 const GURL& storage_origin, | 247 const GURL& storage_origin, |
| 232 const base::Closure& callback) | 248 const base::Closure& callback) |
| 233 : remove_mask(remove_mask), | 249 : remove_mask(remove_mask), |
| 234 quota_storage_remove_mask(quota_storage_remove_mask), | 250 quota_storage_remove_mask(quota_storage_remove_mask), |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 net::URLRequestContextGetter* url_request_context) { | 925 net::URLRequestContextGetter* url_request_context) { |
| 910 url_request_context_ = url_request_context; | 926 url_request_context_ = url_request_context; |
| 911 } | 927 } |
| 912 | 928 |
| 913 void StoragePartitionImpl::SetMediaURLRequestContext( | 929 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 914 net::URLRequestContextGetter* media_url_request_context) { | 930 net::URLRequestContextGetter* media_url_request_context) { |
| 915 media_url_request_context_ = media_url_request_context; | 931 media_url_request_context_ = media_url_request_context; |
| 916 } | 932 } |
| 917 | 933 |
| 918 } // namespace content | 934 } // namespace content |
| OLD | NEW |