OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "content/common/notification_source.h" | 43 #include "content/common/notification_source.h" |
44 #include "net/base/cookie_monster.h" | 44 #include "net/base/cookie_monster.h" |
45 #include "net/base/net_errors.h" | 45 #include "net/base/net_errors.h" |
46 #include "net/base/transport_security_state.h" | 46 #include "net/base/transport_security_state.h" |
47 #include "net/disk_cache/disk_cache.h" | 47 #include "net/disk_cache/disk_cache.h" |
48 #include "net/http/http_cache.h" | 48 #include "net/http/http_cache.h" |
49 #include "net/url_request/url_request_context.h" | 49 #include "net/url_request/url_request_context.h" |
50 #include "net/url_request/url_request_context_getter.h" | 50 #include "net/url_request/url_request_context_getter.h" |
51 #include "webkit/quota/quota_manager.h" | 51 #include "webkit/quota/quota_manager.h" |
52 #include "webkit/quota/quota_types.h" | 52 #include "webkit/quota/quota_types.h" |
53 #include "webkit/quota/quota_client.h" | |
54 | |
55 namespace { | |
56 | |
57 int generateQuotaClientMask(int remove_mask) { | |
Mike West
2011/09/07 14:43:19
I don't really think this needs to exist anywhere
jochen (gone - plz use gerrit)
2011/09/12 11:23:00
tests :)
kinuko
2011/09/26 09:43:48
The first letter should be capital?
| |
58 int quota_client_mask = quota::QuotaClient::kUnknown; | |
59 if (remove_mask & BrowsingDataRemover::REMOVE_FILE_SYSTEMS) | |
60 quota_client_mask |= quota::QuotaClient::kFileSystem; | |
61 if (remove_mask & BrowsingDataRemover::REMOVE_WEBSQL) | |
62 quota_client_mask |= quota::QuotaClient::kDatabase; | |
63 if (remove_mask & BrowsingDataRemover::REMOVE_APPCACHE) | |
64 quota_client_mask |= quota::QuotaClient::kAppcache; | |
65 if (remove_mask & BrowsingDataRemover::REMOVE_INDEXEDDB) | |
66 quota_client_mask |= quota::QuotaClient::kIndexedDatabase; | |
67 | |
68 return quota_client_mask; | |
69 } | |
70 | |
71 } | |
53 | 72 |
54 // Done so that we can use PostTask on BrowsingDataRemovers and not have | 73 // Done so that we can use PostTask on BrowsingDataRemovers and not have |
55 // BrowsingDataRemover implement RefCounted. | 74 // BrowsingDataRemover implement RefCounted. |
56 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); | 75 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); |
57 | 76 |
58 bool BrowsingDataRemover::removing_ = false; | 77 bool BrowsingDataRemover::removing_ = false; |
59 | 78 |
60 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 79 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
61 base::Time delete_begin, | 80 base::Time delete_begin, |
62 base::Time delete_end) | 81 base::Time delete_end) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 233 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
215 } | 234 } |
216 } | 235 } |
217 | 236 |
218 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || | 237 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || |
219 remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) { | 238 remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) { |
220 // TODO(mkwst): At the moment, we don't have the ability to pass a mask into | 239 // TODO(mkwst): At the moment, we don't have the ability to pass a mask into |
221 // QuotaManager. Until then, we'll clear all quota-managed data types if any | 240 // QuotaManager. Until then, we'll clear all quota-managed data types if any |
222 // ought to be cleared. | 241 // ought to be cleared. |
223 quota_manager_ = profile_->GetQuotaManager(); | 242 quota_manager_ = profile_->GetQuotaManager(); |
243 quota_client_mask_ = generateQuotaClientMask(remove_mask); | |
224 if (quota_manager_) { | 244 if (quota_manager_) { |
225 waiting_for_clear_quota_managed_data_ = true; | 245 waiting_for_clear_quota_managed_data_ = true; |
226 BrowserThread::PostTask( | 246 BrowserThread::PostTask( |
227 BrowserThread::IO, FROM_HERE, | 247 BrowserThread::IO, FROM_HERE, |
228 NewRunnableMethod( | 248 NewRunnableMethod( |
229 this, | 249 this, |
230 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); | 250 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); |
231 } | 251 } |
232 } | 252 } |
233 | 253 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 const std::set<GURL>& origins, quota::StorageType type) { | 524 const std::set<GURL>& origins, quota::StorageType type) { |
505 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); | 525 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); |
506 // Walk through the origins passed in, delete quota of |type| from each that | 526 // Walk through the origins passed in, delete quota of |type| from each that |
507 // isn't protected. | 527 // isn't protected. |
508 std::set<GURL>::const_iterator origin; | 528 std::set<GURL>::const_iterator origin; |
509 for (origin = origins.begin(); origin != origins.end(); ++origin) { | 529 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
510 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | 530 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
511 continue; | 531 continue; |
512 ++quota_managed_origins_to_delete_count_; | 532 ++quota_managed_origins_to_delete_count_; |
513 quota_manager_->DeleteOriginData(origin->GetOrigin(), | 533 quota_manager_->DeleteOriginData(origin->GetOrigin(), |
514 type, NewCallback(this, | 534 type, quota_client_mask_, |
515 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | 535 NewCallback(this, &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); |
516 } | 536 } |
517 | 537 |
518 --quota_managed_storage_types_to_delete_count_; | 538 --quota_managed_storage_types_to_delete_count_; |
519 CheckQuotaManagedDataDeletionStatus(); | 539 CheckQuotaManagedDataDeletionStatus(); |
520 } | 540 } |
521 | 541 |
522 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( | 542 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( |
523 quota::QuotaStatusCode status) { | 543 quota::QuotaStatusCode status) { |
524 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); | 544 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); |
525 if (status != quota::kQuotaStatusOk) { | 545 if (status != quota::kQuotaStatusOk) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 GetURLRequestContext()->cookie_store()->GetCookieMonster(); | 597 GetURLRequestContext()->cookie_store()->GetCookieMonster(); |
578 if (cookie_monster) { | 598 if (cookie_monster) { |
579 cookie_monster->DeleteAllCreatedBetweenAsync( | 599 cookie_monster->DeleteAllCreatedBetweenAsync( |
580 delete_begin_, delete_end_, true, | 600 delete_begin_, delete_end_, true, |
581 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 601 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
582 base::Unretained(this))); | 602 base::Unretained(this))); |
583 } else { | 603 } else { |
584 OnClearedCookies(0); | 604 OnClearedCookies(0); |
585 } | 605 } |
586 } | 606 } |
OLD | NEW |