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/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" |
12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
13 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 18 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
18 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
20 #include "chrome/browser/net/chrome_net_log.h" | 21 #include "chrome/browser/net/chrome_net_log.h" |
21 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
(...skipping 15 matching lines...) Expand all Loading... |
37 #include "content/browser/in_process_webkit/webkit_context.h" | 38 #include "content/browser/in_process_webkit/webkit_context.h" |
38 #include "content/browser/user_metrics.h" | 39 #include "content/browser/user_metrics.h" |
39 #include "content/common/notification_source.h" | 40 #include "content/common/notification_source.h" |
40 #include "net/base/cookie_monster.h" | 41 #include "net/base/cookie_monster.h" |
41 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
42 #include "net/base/transport_security_state.h" | 43 #include "net/base/transport_security_state.h" |
43 #include "net/disk_cache/disk_cache.h" | 44 #include "net/disk_cache/disk_cache.h" |
44 #include "net/http/http_cache.h" | 45 #include "net/http/http_cache.h" |
45 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
46 #include "net/url_request/url_request_context_getter.h" | 47 #include "net/url_request/url_request_context_getter.h" |
47 #include "webkit/database/database_tracker.h" | 48 #include "webkit/quota/quota_manager.h" |
48 #include "webkit/database/database_util.h" | 49 #include "webkit/quota/quota_types.h" |
49 #include "webkit/fileapi/file_system_context.h" | |
50 #include "webkit/fileapi/file_system_operation_context.h" | |
51 #include "webkit/fileapi/sandbox_mount_point_provider.h" | |
52 | 50 |
53 // Done so that we can use PostTask on BrowsingDataRemovers and not have | 51 // Done so that we can use PostTask on BrowsingDataRemovers and not have |
54 // BrowsingDataRemover implement RefCounted. | 52 // BrowsingDataRemover implement RefCounted. |
55 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); | 53 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); |
56 | 54 |
57 bool BrowsingDataRemover::removing_ = false; | 55 bool BrowsingDataRemover::removing_ = false; |
58 | 56 |
59 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 57 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
60 base::Time delete_begin, | 58 base::Time delete_begin, |
61 base::Time delete_end) | 59 base::Time delete_end) |
62 : profile_(profile), | 60 : profile_(profile), |
| 61 quota_manager_(NULL), |
63 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 62 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
64 delete_begin_(delete_begin), | 63 delete_begin_(delete_begin), |
65 delete_end_(delete_end), | 64 delete_end_(delete_end), |
66 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | |
67 this, &BrowsingDataRemover::OnClearedDatabases)), | |
68 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 65 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
69 this, &BrowsingDataRemover::DoClearCache)), | 66 this, &BrowsingDataRemover::DoClearCache)), |
70 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | |
71 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | |
72 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | |
73 this, &BrowsingDataRemover::OnAppCacheDeleted)), | |
74 appcaches_to_be_deleted_count_(0), | |
75 next_cache_state_(STATE_NONE), | 67 next_cache_state_(STATE_NONE), |
76 cache_(NULL), | 68 cache_(NULL), |
77 main_context_getter_(profile->GetRequestContext()), | 69 main_context_getter_(profile->GetRequestContext()), |
78 media_context_getter_(profile->GetRequestContextForMedia()), | 70 media_context_getter_(profile->GetRequestContextForMedia()), |
79 waiting_for_clear_databases_(false), | |
80 waiting_for_clear_history_(false), | 71 waiting_for_clear_history_(false), |
| 72 waiting_for_clear_quota_managed_data_(false), |
81 waiting_for_clear_networking_history_(false), | 73 waiting_for_clear_networking_history_(false), |
82 waiting_for_clear_cache_(false), | 74 waiting_for_clear_cache_(false), |
83 waiting_for_clear_appcache_(false), | 75 waiting_for_clear_lso_data_(false) { |
84 waiting_for_clear_gears_data_(false), | |
85 waiting_for_clear_file_systems_(false) { | |
86 DCHECK(profile); | 76 DCHECK(profile); |
87 } | 77 } |
88 | 78 |
89 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 79 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
90 TimePeriod time_period, | 80 TimePeriod time_period, |
91 base::Time delete_end) | 81 base::Time delete_end) |
92 : profile_(profile), | 82 : profile_(profile), |
| 83 quota_manager_(NULL), |
93 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 84 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
94 delete_begin_(CalculateBeginDeleteTime(time_period)), | 85 delete_begin_(CalculateBeginDeleteTime(time_period)), |
95 delete_end_(delete_end), | 86 delete_end_(delete_end), |
96 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | |
97 this, &BrowsingDataRemover::OnClearedDatabases)), | |
98 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 87 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
99 this, &BrowsingDataRemover::DoClearCache)), | 88 this, &BrowsingDataRemover::DoClearCache)), |
100 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | |
101 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | |
102 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | |
103 this, &BrowsingDataRemover::OnAppCacheDeleted)), | |
104 appcaches_to_be_deleted_count_(0), | |
105 next_cache_state_(STATE_NONE), | 89 next_cache_state_(STATE_NONE), |
106 cache_(NULL), | 90 cache_(NULL), |
107 main_context_getter_(profile->GetRequestContext()), | 91 main_context_getter_(profile->GetRequestContext()), |
108 media_context_getter_(profile->GetRequestContextForMedia()), | 92 media_context_getter_(profile->GetRequestContextForMedia()), |
109 waiting_for_clear_databases_(false), | |
110 waiting_for_clear_history_(false), | 93 waiting_for_clear_history_(false), |
| 94 waiting_for_clear_quota_managed_data_(false), |
111 waiting_for_clear_networking_history_(false), | 95 waiting_for_clear_networking_history_(false), |
112 waiting_for_clear_cache_(false), | 96 waiting_for_clear_cache_(false), |
113 waiting_for_clear_appcache_(false), | 97 waiting_for_clear_lso_data_(false) { |
114 waiting_for_clear_lso_data_(false), | |
115 waiting_for_clear_gears_data_(false), | |
116 waiting_for_clear_file_systems_(false) { | |
117 DCHECK(profile); | 98 DCHECK(profile); |
118 } | 99 } |
119 | 100 |
120 BrowsingDataRemover::~BrowsingDataRemover() { | 101 BrowsingDataRemover::~BrowsingDataRemover() { |
121 DCHECK(all_done()); | 102 DCHECK(all_done()); |
122 } | 103 } |
123 | 104 |
124 void BrowsingDataRemover::Remove(int remove_mask) { | 105 void BrowsingDataRemover::Remove(int remove_mask) { |
125 DCHECK(!removing_); | 106 DCHECK(!removing_); |
126 removing_ = true; | 107 removing_ = true; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); | 189 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); |
209 | 190 |
210 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure | 191 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure |
211 // to remove other data such local databases, STS state, etc. These only can | 192 // to remove other data such local databases, STS state, etc. These only can |
212 // be removed if a WEBKIT thread exists, so check that first: | 193 // be removed if a WEBKIT thread exists, so check that first: |
213 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { | 194 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { |
214 // We assume the end time is now. | 195 // We assume the end time is now. |
215 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 196 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
216 } | 197 } |
217 | 198 |
218 database_tracker_ = profile_->GetDatabaseTracker(); | 199 // We'll start by using the quota system to clear out AppCaches, WebSQL DBs, |
219 if (database_tracker_.get()) { | 200 // and File Systems. |
220 waiting_for_clear_databases_ = true; | 201 quota_manager_ = profile_->GetQuotaManager(); |
221 BrowserThread::PostTask( | 202 if (quota_manager_) { |
222 BrowserThread::FILE, FROM_HERE, | 203 waiting_for_clear_quota_managed_data_ = true; |
223 NewRunnableMethod( | |
224 this, | |
225 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | |
226 } | |
227 | |
228 appcache_service_ = profile_->GetAppCacheService(); | |
229 if (appcache_service_.get()) { | |
230 waiting_for_clear_appcache_ = true; | |
231 BrowserThread::PostTask( | 204 BrowserThread::PostTask( |
232 BrowserThread::IO, FROM_HERE, | 205 BrowserThread::IO, FROM_HERE, |
233 NewRunnableMethod( | 206 NewRunnableMethod( |
234 this, | 207 this, |
235 &BrowsingDataRemover::ClearAppCacheOnIOThread)); | 208 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); |
236 } | 209 } |
237 | 210 |
238 waiting_for_clear_gears_data_ = true; | |
239 BrowserThread::PostTask( | |
240 BrowserThread::FILE, FROM_HERE, | |
241 NewRunnableMethod( | |
242 this, | |
243 &BrowsingDataRemover::ClearGearsDataOnFILEThread, | |
244 profile_->GetPath())); | |
245 | |
246 waiting_for_clear_file_systems_ = true; | |
247 BrowserThread::PostTask( | |
248 BrowserThread::FILE, FROM_HERE, | |
249 NewRunnableMethod( | |
250 this, | |
251 &BrowsingDataRemover::ClearFileSystemsOnFILEThread)); | |
252 | |
253 if (profile_->GetTransportSecurityState()) { | 211 if (profile_->GetTransportSecurityState()) { |
254 BrowserThread::PostTask( | 212 BrowserThread::PostTask( |
255 BrowserThread::IO, FROM_HERE, | 213 BrowserThread::IO, FROM_HERE, |
256 NewRunnableMethod( | 214 NewRunnableMethod( |
257 profile_->GetTransportSecurityState(), | 215 profile_->GetTransportSecurityState(), |
258 &net::TransportSecurityState::DeleteSince, | 216 &net::TransportSecurityState::DeleteSince, |
259 delete_begin_)); | 217 delete_begin_)); |
260 } | 218 } |
261 } | 219 } |
262 | 220 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 441 } |
484 default: { | 442 default: { |
485 NOTREACHED() << "bad state"; | 443 NOTREACHED() << "bad state"; |
486 next_cache_state_ = STATE_NONE; // Stop looping. | 444 next_cache_state_ = STATE_NONE; // Stop looping. |
487 break; | 445 break; |
488 } | 446 } |
489 } | 447 } |
490 } | 448 } |
491 } | 449 } |
492 | 450 |
493 void BrowsingDataRemover::OnClearedDatabases(int rv) { | 451 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { |
494 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
495 bool result = BrowserThread::PostTask( | 453 DCHECK(waiting_for_clear_quota_managed_data_); |
496 BrowserThread::UI, FROM_HERE, | 454 |
497 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedDatabases, rv)); | 455 // Ask the QuotaManager for all origins with temporary quota modified within |
498 DCHECK(result); | 456 // the user-specified timeframe, and deal with the resulting set in |
499 return; | 457 // OnGotQuotaManagedOrigins(). |
| 458 quota_managed_origins_to_delete_count_ = 0; |
| 459 quota_managed_storage_types_to_delete_count_ = 2; |
| 460 |
| 461 if (delete_begin_ == base::Time()) { |
| 462 // If we're deleting since the beginning of time, ask the QuotaManager for |
| 463 // all origins with persistent quota modified within the user-specified |
| 464 // timeframe, and deal with the resulting set in |
| 465 // OnGotPersistentQuotaManagedOrigins. |
| 466 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
| 467 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, |
| 468 &BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins)); |
| 469 } else { |
| 470 // Otherwise, we don't need to deal with persistent storage. |
| 471 --quota_managed_storage_types_to_delete_count_; |
500 } | 472 } |
501 // Notify the UI thread that we are done. | |
502 database_tracker_ = NULL; | |
503 waiting_for_clear_databases_ = false; | |
504 | 473 |
505 NotifyAndDeleteIfDone(); | 474 // Do the same for temporary quota, regardless, passing the resulting set into |
| 475 // OnGotTemporaryQuotaManagedOrigins. |
| 476 profile_->GetQuotaManager()->GetOriginsModifiedSince( |
| 477 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, |
| 478 &BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins)); |
506 } | 479 } |
507 | 480 |
508 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { | 481 void BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins( |
509 // This function should be called on the FILE thread. | 482 const std::set<GURL>& origins) { |
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 483 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); |
511 int rv = database_tracker_->DeleteDataModifiedSince( | 484 // Walk through the origins passed in, delete temporary quota from each that |
512 delete_begin_, &database_cleared_callback_); | 485 // isn't protected. |
513 if (rv != net::ERR_IO_PENDING) | 486 std::set<GURL>::const_iterator origin; |
514 OnClearedDatabases(rv); | 487 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
| 488 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
| 489 continue; |
| 490 ++quota_managed_origins_to_delete_count_; |
| 491 quota_manager_->DeleteOriginData(origin->GetOrigin(), |
| 492 quota::kStorageTypeTemporary, NewCallback(this, |
| 493 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); |
| 494 } |
| 495 |
| 496 --quota_managed_storage_types_to_delete_count_; |
| 497 if (quota_managed_storage_types_to_delete_count_ == 0 && |
| 498 quota_managed_origins_to_delete_count_ == 0) |
| 499 CheckQuotaManagedDataDeletionStatus(); |
515 } | 500 } |
516 | 501 |
517 void BrowsingDataRemover::OnClearedAppCache() { | 502 void BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins( |
518 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 503 const std::set<GURL>& origins) { |
519 bool result = BrowserThread::PostTask( | 504 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0); |
520 BrowserThread::UI, FROM_HERE, | 505 // Walk through the origins passed in, delete persistent quota from each that |
521 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedAppCache)); | 506 // isn't protected. |
522 DCHECK(result); | 507 std::set<GURL>::const_iterator origin; |
523 return; | 508 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
| 509 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
| 510 continue; |
| 511 ++quota_managed_origins_to_delete_count_; |
| 512 quota_manager_->DeleteOriginData(origin->GetOrigin(), |
| 513 quota::kStorageTypePersistent, NewCallback(this, |
| 514 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); |
524 } | 515 } |
525 waiting_for_clear_appcache_ = false; | 516 |
526 NotifyAndDeleteIfDone(); | 517 --quota_managed_storage_types_to_delete_count_; |
| 518 if (quota_managed_storage_types_to_delete_count_ == 0 && |
| 519 quota_managed_origins_to_delete_count_ == 0) |
| 520 CheckQuotaManagedDataDeletionStatus(); |
527 } | 521 } |
528 | 522 |
529 void BrowsingDataRemover::ClearAppCacheOnIOThread() { | 523 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( |
530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 524 quota::QuotaStatusCode status) { |
531 DCHECK(waiting_for_clear_appcache_); | 525 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); |
532 appcache_info_ = new appcache::AppCacheInfoCollection; | 526 if (status != quota::kQuotaStatusOk) { |
533 appcache_service_->GetAllAppCacheInfo( | 527 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty |
534 appcache_info_, &appcache_got_info_callback_); | 528 // worthless error message otherwise. |
535 // continues in OnGotAppCacheInfo. | 529 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; |
| 530 } |
| 531 |
| 532 --quota_managed_origins_to_delete_count_; |
| 533 if (quota_managed_storage_types_to_delete_count_ == 0 && |
| 534 quota_managed_origins_to_delete_count_ == 0) |
| 535 CheckQuotaManagedDataDeletionStatus(); |
536 } | 536 } |
537 | 537 |
538 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { | 538 void BrowsingDataRemover::CheckQuotaManagedDataDeletionStatus() { |
539 using appcache::AppCacheInfoVector; | 539 DCHECK_EQ(quota_managed_origins_to_delete_count_, 0); |
540 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 540 DCHECK_EQ(quota_managed_storage_types_to_delete_count_, 0); |
| 541 DCHECK(waiting_for_clear_quota_managed_data_); |
541 | 542 |
542 for (InfoByOrigin::const_iterator origin = | 543 waiting_for_clear_quota_managed_data_ = false; |
543 appcache_info_->infos_by_origin.begin(); | |
544 origin != appcache_info_->infos_by_origin.end(); ++origin) { | |
545 if (special_storage_policy_->IsStorageProtected(origin->first)) | |
546 continue; | |
547 for (AppCacheInfoVector::const_iterator info = origin->second.begin(); | |
548 info != origin->second.end(); ++info) { | |
549 if (info->creation_time > delete_begin_) { | |
550 ++appcaches_to_be_deleted_count_; | |
551 appcache_service_->DeleteAppCacheGroup( | |
552 info->manifest_url, &appcache_deleted_callback_); | |
553 } | |
554 } | |
555 } | |
556 | |
557 if (!appcaches_to_be_deleted_count_) | |
558 OnClearedAppCache(); | |
559 // else continues in OnAppCacheDeleted | |
560 } | |
561 | |
562 void BrowsingDataRemover::OnAppCacheDeleted(int rv) { | |
563 --appcaches_to_be_deleted_count_; | |
564 if (!appcaches_to_be_deleted_count_) | |
565 OnClearedAppCache(); | |
566 } | |
567 | |
568 void BrowsingDataRemover::ClearFileSystemsOnFILEThread() { | |
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
570 DCHECK(waiting_for_clear_file_systems_); | |
571 scoped_refptr<fileapi::FileSystemContext> | |
572 fs_context(profile_->GetFileSystemContext()); | |
573 scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator> | |
574 origin_enumerator(fs_context->path_manager()->sandbox_provider()-> | |
575 CreateOriginEnumerator()); | |
576 | |
577 GURL origin; | |
578 while (!(origin = origin_enumerator->Next()).is_empty()) { | |
579 if (special_storage_policy_->IsStorageProtected(origin)) | |
580 continue; | |
581 if (delete_begin_ == base::Time()) { | |
582 // If the user chooses to delete browsing data "since the beginning of | |
583 // time" remove both temporary and persistent file systems entirely. | |
584 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | |
585 fileapi::kFileSystemTypeTemporary); | |
586 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | |
587 fileapi::kFileSystemTypePersistent); | |
588 } | |
589 // TODO(mkwst): Else? Decide what to do for time-based deletion: crbug/63700 | |
590 } | |
591 | |
592 BrowserThread::PostTask( | 544 BrowserThread::PostTask( |
593 BrowserThread::UI, FROM_HERE, | 545 BrowserThread::UI, FROM_HERE, |
594 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedFileSystems)); | 546 NewRunnableMethod( |
595 } | 547 this, |
596 | 548 &BrowsingDataRemover::NotifyAndDeleteIfDone)); |
597 void BrowsingDataRemover::OnClearedFileSystems() { | |
598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
599 waiting_for_clear_file_systems_ = false; | |
600 NotifyAndDeleteIfDone(); | |
601 } | |
602 | |
603 // static | |
604 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { | |
605 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); | |
606 if (file_util::DirectoryExists(plugin_data)) | |
607 file_util::Delete(plugin_data, true); | |
608 } | |
609 | |
610 void BrowsingDataRemover::OnClearedGearsData() { | |
611 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
612 bool result = BrowserThread::PostTask( | |
613 BrowserThread::UI, FROM_HERE, | |
614 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedGearsData)); | |
615 DCHECK(result); | |
616 return; | |
617 } | |
618 waiting_for_clear_gears_data_ = false; | |
619 NotifyAndDeleteIfDone(); | |
620 } | |
621 | |
622 void BrowsingDataRemover::ClearGearsDataOnFILEThread( | |
623 const FilePath& profile_dir) { | |
624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
625 DCHECK(waiting_for_clear_gears_data_); | |
626 | |
627 ClearGearsData(profile_dir); | |
628 OnClearedGearsData(); | |
629 } | 549 } |
630 | 550 |
631 void BrowsingDataRemover::OnWaitableEventSignaled( | 551 void BrowsingDataRemover::OnWaitableEventSignaled( |
632 base::WaitableEvent* waitable_event) { | 552 base::WaitableEvent* waitable_event) { |
633 waiting_for_clear_lso_data_ = false; | 553 waiting_for_clear_lso_data_ = false; |
634 NotifyAndDeleteIfDone(); | 554 NotifyAndDeleteIfDone(); |
635 } | 555 } |
OLD | NEW |