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

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

Issue 2221143003: Formalize the restrictions of BrowsingDataRemover::RemoveWithFilter() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 DCHECK(observer); 342 DCHECK(observer);
343 RemoveInternal(time_range, remove_mask, origin_type_mask, 343 RemoveInternal(time_range, remove_mask, origin_type_mask,
344 std::unique_ptr<RegistrableDomainFilterBuilder>(), observer); 344 std::unique_ptr<RegistrableDomainFilterBuilder>(), observer);
345 } 345 }
346 346
347 void BrowsingDataRemover::RemoveWithFilter( 347 void BrowsingDataRemover::RemoveWithFilter(
348 const TimeRange& time_range, 348 const TimeRange& time_range,
349 int remove_mask, 349 int remove_mask,
350 int origin_type_mask, 350 int origin_type_mask,
351 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { 351 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) {
352 DCHECK_EQ(FILTERABLE_DATATYPES, remove_mask | FILTERABLE_DATATYPES);
Bernhard Bauer 2016/08/10 14:22:13 Nit: If you changed this to DCHECK_EQ(0, remove_ma
msramek 2016/08/11 13:11:01 Done. You will see the remaining bits as a decimal
352 DCHECK(filter_builder); 353 DCHECK(filter_builder);
353 RemoveInternal(time_range, remove_mask, origin_type_mask, 354 RemoveInternal(time_range, remove_mask, origin_type_mask,
354 std::move(filter_builder), nullptr); 355 std::move(filter_builder), nullptr);
355 } 356 }
356 357
357 void BrowsingDataRemover::RemoveWithFilterAndReply( 358 void BrowsingDataRemover::RemoveWithFilterAndReply(
358 const TimeRange& time_range, 359 const TimeRange& time_range,
359 int remove_mask, 360 int remove_mask,
360 int origin_type_mask, 361 int origin_type_mask,
361 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, 362 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder,
362 Observer* observer) { 363 Observer* observer) {
364 DCHECK_EQ(FILTERABLE_DATATYPES, remove_mask | FILTERABLE_DATATYPES);
363 DCHECK(filter_builder); 365 DCHECK(filter_builder);
364 DCHECK(observer); 366 DCHECK(observer);
365 RemoveInternal(time_range, remove_mask, origin_type_mask, 367 RemoveInternal(time_range, remove_mask, origin_type_mask,
366 std::move(filter_builder), observer); 368 std::move(filter_builder), observer);
367 } 369 }
368 370
369 void BrowsingDataRemover::RemoveInternal( 371 void BrowsingDataRemover::RemoveInternal(
370 const TimeRange& time_range, 372 const TimeRange& time_range,
371 int remove_mask, 373 int remove_mask,
372 int origin_type_mask, 374 int origin_type_mask,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 removal_task.remove_mask, 410 removal_task.remove_mask,
409 *removal_task.filter_builder, 411 *removal_task.filter_builder,
410 removal_task.origin_type_mask); 412 removal_task.origin_type_mask);
411 } 413 }
412 414
413 void BrowsingDataRemover::RemoveImpl( 415 void BrowsingDataRemover::RemoveImpl(
414 const TimeRange& time_range, 416 const TimeRange& time_range,
415 int remove_mask, 417 int remove_mask,
416 const BrowsingDataFilterBuilder& filter_builder, 418 const BrowsingDataFilterBuilder& filter_builder,
417 int origin_type_mask) { 419 int origin_type_mask) {
420 // =============== README before adding more storage backends ===============
421 //
422 // If you're adding a data storage backend that is included among
423 // RemoveDataMask::FILTERABLE_DATATYPES, you must do one of the following:
424 // 1. Support one of the filters generated by |filter_builder|.
425 // 2. Add a comment explaining why is it acceptable in your case to delete all
426 // data without filtering URLs / origins / domains.
427 // 3. Do not support partial deletion, i.e. only delete your data if
428 // |filter_builder.IsEmptyBlacklist()|. Add a comment explaining why this
429 // is acceptable.
418 DCHECK_CURRENTLY_ON(BrowserThread::UI); 430 DCHECK_CURRENTLY_ON(BrowserThread::UI);
419 waiting_for_synchronous_clear_operations_ = true; 431 waiting_for_synchronous_clear_operations_ = true;
420 432
421 // crbug.com/140910: Many places were calling this with base::Time() as 433 // crbug.com/140910: Many places were calling this with base::Time() as
422 // delete_end, even though they should've used base::Time::Max(). 434 // delete_end, even though they should've used base::Time::Max().
423 DCHECK_NE(base::Time(), time_range.end); 435 DCHECK_NE(base::Time(), time_range.end);
424 436
425 delete_begin_ = time_range.begin; 437 delete_begin_ = time_range.begin;
426 delete_end_ = time_range.end; 438 delete_end_ = time_range.end;
427 remove_mask_ = remove_mask; 439 remove_mask_ = remove_mask;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 cryptohome::Identification(user->GetAccountId()), 1024 cryptohome::Identification(user->GetAccountId()),
1013 chromeos::attestation::kContentProtectionKeyPrefix, 1025 chromeos::attestation::kContentProtectionKeyPrefix,
1014 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys, 1026 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys,
1015 weak_ptr_factory_.GetWeakPtr())); 1027 weak_ptr_factory_.GetWeakPtr()));
1016 waiting_for_clear_platform_keys_ = true; 1028 waiting_for_clear_platform_keys_ = true;
1017 } 1029 }
1018 #endif // defined(OS_CHROMEOS) 1030 #endif // defined(OS_CHROMEOS)
1019 #endif // defined(ENABLE_PLUGINS) 1031 #endif // defined(ENABLE_PLUGINS)
1020 } 1032 }
1021 1033
1022 // Remove omnibox zero-suggest cache results. 1034 // Remove omnibox zero-suggest cache results. Filtering is not supported.
1035 // This is not a problem, as deleting more data than necessary will just cause
1036 // another server round-trip; no data are actually lost.
Bernhard Bauer 2016/08/10 14:22:14 Nit: "no data is actually lost" :)
msramek 2016/08/11 13:11:01 *grumble* *grumble* Done. :) But yeah, I remember
Bernhard Bauer 2016/08/11 13:25:42 Yes, I think in this case you are not talking abou
1023 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES))) 1037 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES)))
1024 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); 1038 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string());
1025 1039
1026 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) { 1040 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) {
1027 domain_reliability::DomainReliabilityService* service = 1041 domain_reliability::DomainReliabilityService* service =
1028 domain_reliability::DomainReliabilityServiceFactory:: 1042 domain_reliability::DomainReliabilityServiceFactory::
1029 GetForBrowserContext(profile_); 1043 GetForBrowserContext(profile_);
1030 if (service) { 1044 if (service) {
1031 domain_reliability::DomainReliabilityClearMode mode; 1045 domain_reliability::DomainReliabilityClearMode mode;
1032 if (remove_mask & REMOVE_COOKIES) 1046 if (remove_mask & REMOVE_COOKIES)
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 waiting_for_clear_offline_page_data_ = false; 1422 waiting_for_clear_offline_page_data_ = false;
1409 NotifyIfDone(); 1423 NotifyIfDone();
1410 } 1424 }
1411 #endif 1425 #endif
1412 1426
1413 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { 1427 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() {
1414 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1428 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1415 waiting_for_clear_domain_reliability_monitor_ = false; 1429 waiting_for_clear_domain_reliability_monitor_ = false;
1416 NotifyIfDone(); 1430 NotifyIfDone();
1417 } 1431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698