Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 12500009: Add the ability to clear the shader disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/webdata/web_data_service.h" 44 #include "chrome/browser/webdata/web_data_service.h"
45 #include "chrome/common/chrome_notification_types.h" 45 #include "chrome/common/chrome_notification_types.h"
46 #include "chrome/common/pref_names.h" 46 #include "chrome/common/pref_names.h"
47 #include "chrome/common/url_constants.h" 47 #include "chrome/common/url_constants.h"
48 #include "components/autofill/browser/personal_data_manager.h" 48 #include "components/autofill/browser/personal_data_manager.h"
49 #include "content/public/browser/browser_thread.h" 49 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/dom_storage_context.h" 50 #include "content/public/browser/dom_storage_context.h"
51 #include "content/public/browser/download_manager.h" 51 #include "content/public/browser/download_manager.h"
52 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
53 #include "content/public/browser/plugin_data_remover.h" 53 #include "content/public/browser/plugin_data_remover.h"
54 #include "content/public/browser/shader_disk_cache.h"
54 #include "content/public/browser/storage_partition.h" 55 #include "content/public/browser/storage_partition.h"
55 #include "content/public/browser/user_metrics.h" 56 #include "content/public/browser/user_metrics.h"
56 #include "net/base/net_errors.h" 57 #include "net/base/net_errors.h"
57 #include "net/cookies/cookie_store.h" 58 #include "net/cookies/cookie_store.h"
58 #include "net/disk_cache/disk_cache.h" 59 #include "net/disk_cache/disk_cache.h"
59 #include "net/http/http_cache.h" 60 #include "net/http/http_cache.h"
60 #include "net/http/infinite_cache.h" 61 #include "net/http/infinite_cache.h"
61 #include "net/http/transport_security_state.h" 62 #include "net/http/transport_security_state.h"
62 #include "net/ssl/server_bound_cert_service.h" 63 #include "net/ssl/server_bound_cert_service.h"
63 #include "net/ssl/server_bound_cert_store.h" 64 #include "net/ssl/server_bound_cert_store.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 waiting_for_clear_history_(false), 142 waiting_for_clear_history_(false),
142 waiting_for_clear_hostname_resolution_cache_(false), 143 waiting_for_clear_hostname_resolution_cache_(false),
143 waiting_for_clear_local_storage_(false), 144 waiting_for_clear_local_storage_(false),
144 waiting_for_clear_nacl_cache_(false), 145 waiting_for_clear_nacl_cache_(false),
145 waiting_for_clear_network_predictor_(false), 146 waiting_for_clear_network_predictor_(false),
146 waiting_for_clear_networking_history_(false), 147 waiting_for_clear_networking_history_(false),
147 waiting_for_clear_plugin_data_(false), 148 waiting_for_clear_plugin_data_(false),
148 waiting_for_clear_quota_managed_data_(false), 149 waiting_for_clear_quota_managed_data_(false),
149 waiting_for_clear_server_bound_certs_(false), 150 waiting_for_clear_server_bound_certs_(false),
150 waiting_for_clear_session_storage_(false), 151 waiting_for_clear_session_storage_(false),
152 waiting_for_clear_shader_cache_(false),
151 remove_mask_(0), 153 remove_mask_(0),
152 remove_origin_(GURL()), 154 remove_origin_(GURL()),
153 origin_set_mask_(0) { 155 origin_set_mask_(0) {
154 DCHECK(profile); 156 DCHECK(profile);
155 // crbug.com/140910: Many places were calling this with base::Time() as 157 // crbug.com/140910: Many places were calling this with base::Time() as
156 // delete_end, even though they should've used base::Time::Max(). Work around 158 // delete_end, even though they should've used base::Time::Max(). Work around
157 // it here. New code should use base::Time::Max(). 159 // it here. New code should use base::Time::Max().
158 DCHECK(delete_end_ != base::Time()); 160 DCHECK(delete_end_ != base::Time());
159 if (delete_end_ == base::Time()) 161 if (delete_end_ == base::Time())
160 delete_end_ = base::Time::Max(); 162 delete_end_ = base::Time::Max();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 waiting_for_clear_content_licenses_ = true; 501 waiting_for_clear_content_licenses_ = true;
500 if (!pepper_flash_settings_manager_.get()) { 502 if (!pepper_flash_settings_manager_.get()) {
501 pepper_flash_settings_manager_.reset( 503 pepper_flash_settings_manager_.reset(
502 new PepperFlashSettingsManager(this, profile_)); 504 new PepperFlashSettingsManager(this, profile_));
503 } 505 }
504 deauthorize_content_licenses_request_id_ = 506 deauthorize_content_licenses_request_id_ =
505 pepper_flash_settings_manager_->DeauthorizeContentLicenses(); 507 pepper_flash_settings_manager_->DeauthorizeContentLicenses();
506 } 508 }
507 #endif 509 #endif
508 510
511 if (remove_mask & REMOVE_SHADER_CACHE) {
512 waiting_for_clear_shader_cache_ = true;
513 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache"));
514
515 BrowserThread::PostTask(
516 BrowserThread::IO, FROM_HERE,
517 base::Bind(&BrowsingDataRemover::ClearShaderCacheOnIOThread,
518 base::Unretained(this), profile_->GetPath(), delete_begin_,
519 delete_end_));
520 }
521
509 // Always wipe accumulated network related data (TransportSecurityState and 522 // Always wipe accumulated network related data (TransportSecurityState and
510 // HttpServerPropertiesManager data). 523 // HttpServerPropertiesManager data).
511 waiting_for_clear_networking_history_ = true; 524 waiting_for_clear_networking_history_ = true;
512 profile_->ClearNetworkingHistorySince( 525 profile_->ClearNetworkingHistorySince(
513 delete_begin_, 526 delete_begin_,
514 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory, 527 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory,
515 base::Unretained(this))); 528 base::Unretained(this)));
516 } 529 }
517 530
518 void BrowsingDataRemover::AddObserver(Observer* observer) { 531 void BrowsingDataRemover::AddObserver(Observer* observer) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 !waiting_for_clear_history_ && 581 !waiting_for_clear_history_ &&
569 !waiting_for_clear_local_storage_ && 582 !waiting_for_clear_local_storage_ &&
570 !waiting_for_clear_session_storage_ && 583 !waiting_for_clear_session_storage_ &&
571 !waiting_for_clear_networking_history_ && 584 !waiting_for_clear_networking_history_ &&
572 !waiting_for_clear_server_bound_certs_ && 585 !waiting_for_clear_server_bound_certs_ &&
573 !waiting_for_clear_plugin_data_ && 586 !waiting_for_clear_plugin_data_ &&
574 !waiting_for_clear_quota_managed_data_ && 587 !waiting_for_clear_quota_managed_data_ &&
575 !waiting_for_clear_content_licenses_ && 588 !waiting_for_clear_content_licenses_ &&
576 !waiting_for_clear_form_ && 589 !waiting_for_clear_form_ &&
577 !waiting_for_clear_hostname_resolution_cache_ && 590 !waiting_for_clear_hostname_resolution_cache_ &&
578 !waiting_for_clear_network_predictor_; 591 !waiting_for_clear_network_predictor_ &&
592 !waiting_for_clear_shader_cache_;
579 } 593 }
580 594
581 void BrowsingDataRemover::Observe(int type, 595 void BrowsingDataRemover::Observe(int type,
582 const content::NotificationSource& source, 596 const content::NotificationSource& source,
583 const content::NotificationDetails& details) { 597 const content::NotificationDetails& details) {
584 // TODO(brettw) bug 1139736: This should also observe session 598 // TODO(brettw) bug 1139736: This should also observe session
585 // clearing (what about other things such as passwords, etc.?) and wait for 599 // clearing (what about other things such as passwords, etc.?) and wait for
586 // them to complete before continuing. 600 // them to complete before continuing.
587 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); 601 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
588 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr(); 602 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 775 }
762 default: { 776 default: {
763 NOTREACHED() << "bad state"; 777 NOTREACHED() << "bad state";
764 next_cache_state_ = STATE_NONE; // Stop looping. 778 next_cache_state_ = STATE_NONE; // Stop looping.
765 break; 779 break;
766 } 780 }
767 } 781 }
768 } 782 }
769 } 783 }
770 784
785 void BrowsingDataRemover::ClearedShaderCache() {
786 // This function should be called on the UI thread.
787 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
788
789 waiting_for_clear_shader_cache_ = false;
790 NotifyAndDeleteIfDone();
791 }
792
793 void BrowsingDataRemover::ClearedShaderCacheOnIOThread() {
794 // This function should be called on the IO thread.
795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
796
797 // Notify the UI thread that we are done.
798 BrowserThread::PostTask(
799 BrowserThread::UI, FROM_HERE,
800 base::Bind(&BrowsingDataRemover::ClearedShaderCache,
801 base::Unretained(this)));
802 }
803
804 void BrowsingDataRemover::ClearShaderCacheOnIOThread(
805 const base::FilePath path, const base::Time delete_begin,
806 const base::Time delete_end) {
807 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
808
809 content::ShaderCacheFactory::GetInstance()->ClearByPath(
810 path, delete_begin, delete_end,
811 base::Bind(&BrowsingDataRemover::ClearedShaderCacheOnIOThread,
812 base::Unretained(this)));
813 }
814
771 #if !defined(DISABLE_NACL) 815 #if !defined(DISABLE_NACL)
772 void BrowsingDataRemover::ClearedNaClCache() { 816 void BrowsingDataRemover::ClearedNaClCache() {
773 // This function should be called on the UI thread. 817 // This function should be called on the UI thread.
774 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 818 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
775 819
776 waiting_for_clear_nacl_cache_ = false; 820 waiting_for_clear_nacl_cache_ = false;
777 821
778 NotifyAndDeleteIfDone(); 822 NotifyAndDeleteIfDone();
779 } 823 }
780 824
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 BrowserThread::UI, FROM_HERE, 1067 BrowserThread::UI, FROM_HERE,
1024 base::Bind(&BrowsingDataRemover::OnClearedFormData, 1068 base::Bind(&BrowsingDataRemover::OnClearedFormData,
1025 base::Unretained(this))); 1069 base::Unretained(this)));
1026 } 1070 }
1027 1071
1028 void BrowsingDataRemover::OnClearedFormData() { 1072 void BrowsingDataRemover::OnClearedFormData() {
1029 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1073 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1030 waiting_for_clear_form_ = false; 1074 waiting_for_clear_form_ = false;
1031 NotifyAndDeleteIfDone(); 1075 NotifyAndDeleteIfDone();
1032 } 1076 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698