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

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

Issue 2173443002: Fix a race condition in BrowsingDataRemover. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <string> 9 #include <string>
10 10
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 const BrowsingDataFilterBuilder& filter_builder) { 373 const BrowsingDataFilterBuilder& filter_builder) {
374 RemoveImpl(time_range, remove_mask, filter_builder, origin_type_mask); 374 RemoveImpl(time_range, remove_mask, filter_builder, origin_type_mask);
375 } 375 }
376 376
377 void BrowsingDataRemover::RemoveImpl( 377 void BrowsingDataRemover::RemoveImpl(
378 const TimeRange& time_range, 378 const TimeRange& time_range,
379 int remove_mask, 379 int remove_mask,
380 const BrowsingDataFilterBuilder& filter_builder, 380 const BrowsingDataFilterBuilder& filter_builder,
381 int origin_type_mask) { 381 int origin_type_mask) {
382 DCHECK_CURRENTLY_ON(BrowserThread::UI); 382 DCHECK_CURRENTLY_ON(BrowserThread::UI);
383 waiting_for_synchronous_clear_operations_ = true;
383 384
384 // crbug.com/140910: Many places were calling this with base::Time() as 385 // crbug.com/140910: Many places were calling this with base::Time() as
385 // delete_end, even though they should've used base::Time::Max(). 386 // delete_end, even though they should've used base::Time::Max().
386 DCHECK_NE(base::Time(), time_range.end); 387 DCHECK_NE(base::Time(), time_range.end);
387 388
388 SetRemoving(true); 389 SetRemoving(true);
389 delete_begin_ = time_range.begin; 390 delete_begin_ = time_range.begin;
390 delete_end_ = time_range.end; 391 delete_end_ = time_range.end;
391 remove_mask_ = remove_mask; 392 remove_mask_ = remove_mask;
392 origin_type_mask_ = origin_type_mask; 393 origin_type_mask_ = origin_type_mask;
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; 1033 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE;
1033 if (remove_mask & REMOVE_COOKIES && 1034 if (remove_mask & REMOVE_COOKIES &&
1034 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { 1035 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
1035 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE 1036 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE
1036 : ONLY_COOKIES; 1037 : ONLY_COOKIES;
1037 } else if (remove_mask & REMOVE_CACHE) { 1038 } else if (remove_mask & REMOVE_CACHE) {
1038 choice = ONLY_CACHE; 1039 choice = ONLY_CACHE;
1039 } 1040 }
1040 1041
1041 // Notify in case all actions taken were synchronous. 1042 // Notify in case all actions taken were synchronous.
1043 waiting_for_synchronous_clear_operations_ = false;
1042 NotifyIfDone(); 1044 NotifyIfDone();
1043 1045
1044 UMA_HISTOGRAM_ENUMERATION( 1046 UMA_HISTOGRAM_ENUMERATION(
1045 "History.ClearBrowsingData.UserDeletedCookieOrCache", 1047 "History.ClearBrowsingData.UserDeletedCookieOrCache",
1046 choice, MAX_CHOICE_VALUE); 1048 choice, MAX_CHOICE_VALUE);
1047 } 1049 }
1048 1050
1049 void BrowsingDataRemover::AddObserver(Observer* observer) { 1051 void BrowsingDataRemover::AddObserver(Observer* observer) {
1050 observer_list_.AddObserver(observer); 1052 observer_list_.AddObserver(observer);
1051 } 1053 }
(...skipping 26 matching lines...) Expand all
1078 for (const ContentSettingPatternSource& setting : settings) { 1080 for (const ContentSettingPatternSource& setting : settings) {
1079 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { 1081 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) {
1080 content_settings_map->SetWebsiteSettingCustomScope( 1082 content_settings_map->SetWebsiteSettingCustomScope(
1081 setting.primary_pattern, setting.secondary_pattern, content_type, 1083 setting.primary_pattern, setting.secondary_pattern, content_type,
1082 std::string(), nullptr); 1084 std::string(), nullptr);
1083 } 1085 }
1084 } 1086 }
1085 } 1087 }
1086 1088
1087 bool BrowsingDataRemover::AllDone() { 1089 bool BrowsingDataRemover::AllDone() {
1088 return !waiting_for_clear_autofill_origin_urls_ && 1090 return !waiting_for_synchronous_clear_operations_ &&
1091 !waiting_for_clear_autofill_origin_urls_ &&
1089 !waiting_for_clear_cache_ && 1092 !waiting_for_clear_cache_ &&
1090 !waiting_for_clear_flash_content_licenses_ && 1093 !waiting_for_clear_flash_content_licenses_ &&
1091 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && 1094 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ &&
1092 !waiting_for_clear_domain_reliability_monitor_ && 1095 !waiting_for_clear_domain_reliability_monitor_ &&
1093 !waiting_for_clear_form_ && !waiting_for_clear_history_ && 1096 !waiting_for_clear_form_ && !waiting_for_clear_history_ &&
1094 !waiting_for_clear_hostname_resolution_cache_ && 1097 !waiting_for_clear_hostname_resolution_cache_ &&
1095 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && 1098 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ &&
1096 !waiting_for_clear_network_predictor_ && 1099 !waiting_for_clear_network_predictor_ &&
1097 !waiting_for_clear_networking_history_ && 1100 !waiting_for_clear_networking_history_ &&
1098 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && 1101 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ &&
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 waiting_for_clear_domain_reliability_monitor_ = false; 1323 waiting_for_clear_domain_reliability_monitor_ = false;
1321 NotifyIfDone(); 1324 NotifyIfDone();
1322 } 1325 }
1323 1326
1324 // static 1327 // static
1325 BrowsingDataRemover::CallbackSubscription 1328 BrowsingDataRemover::CallbackSubscription
1326 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 1329 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1327 const BrowsingDataRemover::Callback& callback) { 1330 const BrowsingDataRemover::Callback& callback) {
1328 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); 1331 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
1329 } 1332 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698