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 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
Mike West
2016/04/02 05:12:40
Nit: Can you add a "TODO(mkwst): It's not clear wh
dmurph
2016/04/04 18:28:32
Done.
| |
70 begin, | 77 begin, end, |
71 end, | 78 StoragePartitionImpl::CreatePredicateForHostCookies(storage_origin), |
72 storage_origin, base::Bind(&OnClearedCookies, callback)); | 79 base::Bind(&OnClearedCookies, callback)); |
73 } | 80 } |
74 } | 81 } |
75 | 82 |
76 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, | 83 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, |
77 const base::Closure& callback) { | 84 const base::Closure& callback) { |
78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 85 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
79 if (*deletion_task_count == 0) { | 86 if (*deletion_task_count == 0) { |
80 delete deletion_task_count; | 87 delete deletion_task_count; |
81 callback.Run(); | 88 callback.Run(); |
82 } | 89 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) | 222 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) |
216 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; | 223 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; |
217 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) | 224 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) |
218 quota_client_mask |= storage::QuotaClient::kServiceWorker; | 225 quota_client_mask |= storage::QuotaClient::kServiceWorker; |
219 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) | 226 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) |
220 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; | 227 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; |
221 | 228 |
222 return quota_client_mask; | 229 return quota_client_mask; |
223 } | 230 } |
224 | 231 |
232 // static | |
233 net::CookieStore::CookiePredicate | |
234 StoragePartitionImpl::CreatePredicateForHostCookies(const GURL& url) { | |
235 return base::Bind(&DoesCookieMatchHost, url.host()); | |
236 } | |
237 | |
225 // Helper for deleting quota managed data from a partition. | 238 // Helper for deleting quota managed data from a partition. |
226 // | 239 // |
227 // Most of the operations in this class are done on IO thread. | 240 // Most of the operations in this class are done on IO thread. |
228 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { | 241 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { |
229 QuotaManagedDataDeletionHelper(uint32_t remove_mask, | 242 QuotaManagedDataDeletionHelper(uint32_t remove_mask, |
230 uint32_t quota_storage_remove_mask, | 243 uint32_t quota_storage_remove_mask, |
231 const GURL& storage_origin, | 244 const GURL& storage_origin, |
232 const base::Closure& callback) | 245 const base::Closure& callback) |
233 : remove_mask(remove_mask), | 246 : remove_mask(remove_mask), |
234 quota_storage_remove_mask(quota_storage_remove_mask), | 247 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) { | 922 net::URLRequestContextGetter* url_request_context) { |
910 url_request_context_ = url_request_context; | 923 url_request_context_ = url_request_context; |
911 } | 924 } |
912 | 925 |
913 void StoragePartitionImpl::SetMediaURLRequestContext( | 926 void StoragePartitionImpl::SetMediaURLRequestContext( |
914 net::URLRequestContextGetter* media_url_request_context) { | 927 net::URLRequestContextGetter* media_url_request_context) { |
915 media_url_request_context_ = media_url_request_context; | 928 media_url_request_context_ = media_url_request_context; |
916 } | 929 } |
917 | 930 |
918 } // namespace content | 931 } // namespace content |
OLD | NEW |