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

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

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 ssl_config_service_->RemoveObserver(this); 510 ssl_config_service_->RemoveObserver(this);
511 } 511 }
512 512
513 int ChannelIDCount() { return channel_id_service_->channel_id_count(); } 513 int ChannelIDCount() { return channel_id_service_->channel_id_count(); }
514 514
515 // Add a server bound cert for |server| with specific creation and expiry 515 // Add a server bound cert for |server| with specific creation and expiry
516 // times. The cert and key data will be filled with dummy values. 516 // times. The cert and key data will be filled with dummy values.
517 void AddChannelIDWithTimes(const std::string& server_identifier, 517 void AddChannelIDWithTimes(const std::string& server_identifier,
518 base::Time creation_time) { 518 base::Time creation_time) {
519 GetChannelIDStore()->SetChannelID( 519 GetChannelIDStore()->SetChannelID(
520 base::WrapUnique(new net::ChannelIDStore::ChannelID( 520 base::MakeUnique<net::ChannelIDStore::ChannelID>(
521 server_identifier, creation_time, crypto::ECPrivateKey::Create()))); 521 server_identifier, creation_time, crypto::ECPrivateKey::Create()));
522 } 522 }
523 523
524 // Add a server bound cert for |server|, with the current time as the 524 // Add a server bound cert for |server|, with the current time as the
525 // creation time. The cert and key data will be filled with dummy values. 525 // creation time. The cert and key data will be filled with dummy values.
526 void AddChannelID(const std::string& server_identifier) { 526 void AddChannelID(const std::string& server_identifier) {
527 base::Time now = base::Time::Now(); 527 base::Time now = base::Time::Now();
528 AddChannelIDWithTimes(server_identifier, now); 528 AddChannelIDWithTimes(server_identifier, now);
529 } 529 }
530 530
531 void GetChannelIDList(net::ChannelIDStore::ChannelIDList* channel_ids) { 531 void GetChannelIDList(net::ChannelIDStore::ChannelIDList* channel_ids) {
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 BrowsingDataRemover::REMOVE_PASSWORDS, 2582 BrowsingDataRemover::REMOVE_PASSWORDS,
2583 false); 2583 false);
2584 } 2584 }
2585 2585
2586 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { 2586 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) {
2587 // Add our settings. 2587 // Add our settings.
2588 HostContentSettingsMap* host_content_settings_map = 2588 HostContentSettingsMap* host_content_settings_map =
2589 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 2589 HostContentSettingsMapFactory::GetForProfile(GetProfile());
2590 host_content_settings_map->SetWebsiteSettingDefaultScope( 2590 host_content_settings_map->SetWebsiteSettingDefaultScope(
2591 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), 2591 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(),
2592 base::WrapUnique(new base::DictionaryValue())); 2592 base::MakeUnique<base::DictionaryValue>());
2593 host_content_settings_map->SetWebsiteSettingDefaultScope( 2593 host_content_settings_map->SetWebsiteSettingDefaultScope(
2594 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), 2594 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(),
2595 base::WrapUnique(new base::DictionaryValue())); 2595 base::MakeUnique<base::DictionaryValue>());
2596 host_content_settings_map->SetWebsiteSettingDefaultScope( 2596 host_content_settings_map->SetWebsiteSettingDefaultScope(
2597 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), 2597 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(),
2598 base::WrapUnique(new base::DictionaryValue())); 2598 base::MakeUnique<base::DictionaryValue>());
2599 host_content_settings_map->SetWebsiteSettingDefaultScope( 2599 host_content_settings_map->SetWebsiteSettingDefaultScope(
2600 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), 2600 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(),
2601 base::WrapUnique(new base::DictionaryValue())); 2601 base::MakeUnique<base::DictionaryValue>());
2602 2602
2603 // Clear all except for origin1 and origin3. 2603 // Clear all except for origin1 and origin3.
2604 RegistrableDomainFilterBuilder filter( 2604 RegistrableDomainFilterBuilder filter(
2605 RegistrableDomainFilterBuilder::BLACKLIST); 2605 RegistrableDomainFilterBuilder::BLACKLIST);
2606 filter.AddRegisterableDomain(kTestRegisterableDomain1); 2606 filter.AddRegisterableDomain(kTestRegisterableDomain1);
2607 filter.AddRegisterableDomain(kTestRegisterableDomain3); 2607 filter.AddRegisterableDomain(kTestRegisterableDomain3);
2608 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, 2608 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR,
2609 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, 2609 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA,
2610 filter); 2610 filter);
2611 2611
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 new RegistrableDomainFilterBuilder( 2878 new RegistrableDomainFilterBuilder(
2879 RegistrableDomainFilterBuilder::BLACKLIST)); 2879 RegistrableDomainFilterBuilder::BLACKLIST));
2880 filter_builder_2->AddRegisterableDomain("example.com"); 2880 filter_builder_2->AddRegisterableDomain("example.com");
2881 2881
2882 MultipleTasksObserver observer(remover); 2882 MultipleTasksObserver observer(remover);
2883 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; 2883 BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
2884 2884
2885 // Test several tasks with various configuration of masks, filters, and target 2885 // Test several tasks with various configuration of masks, filters, and target
2886 // observers. 2886 // observers.
2887 std::list<BrowsingDataRemover::RemovalTask> tasks; 2887 std::list<BrowsingDataRemover::RemovalTask> tasks;
2888 tasks.emplace_back( 2888 tasks.emplace_back(BrowsingDataRemover::Unbounded(),
2889 BrowsingDataRemover::Unbounded(), 2889 BrowsingDataRemover::REMOVE_HISTORY,
2890 BrowsingDataRemover::REMOVE_HISTORY, 2890 BrowsingDataHelper::UNPROTECTED_WEB,
2891 BrowsingDataHelper::UNPROTECTED_WEB, 2891 base::MakeUnique<RegistrableDomainFilterBuilder>(
2892 base::WrapUnique(new RegistrableDomainFilterBuilder( 2892 RegistrableDomainFilterBuilder::BLACKLIST),
2893 RegistrableDomainFilterBuilder::BLACKLIST)), 2893 observer.target_a());
2894 observer.target_a()); 2894 tasks.emplace_back(BrowsingDataRemover::Unbounded(),
2895 tasks.emplace_back( 2895 BrowsingDataRemover::REMOVE_COOKIES,
2896 BrowsingDataRemover::Unbounded(), 2896 BrowsingDataHelper::PROTECTED_WEB,
2897 BrowsingDataRemover::REMOVE_COOKIES, 2897 base::MakeUnique<RegistrableDomainFilterBuilder>(
2898 BrowsingDataHelper::PROTECTED_WEB, 2898 RegistrableDomainFilterBuilder::BLACKLIST),
2899 base::WrapUnique(new RegistrableDomainFilterBuilder( 2899 nullptr);
2900 RegistrableDomainFilterBuilder::BLACKLIST)),
2901 nullptr);
2902 tasks.emplace_back( 2900 tasks.emplace_back(
2903 BrowsingDataRemover::TimeRange(base::Time::Now(), base::Time::Max()), 2901 BrowsingDataRemover::TimeRange(base::Time::Now(), base::Time::Max()),
2904 BrowsingDataRemover::REMOVE_PASSWORDS, 2902 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL,
2905 BrowsingDataHelper::ALL, 2903 base::MakeUnique<RegistrableDomainFilterBuilder>(
2906 base::WrapUnique(new RegistrableDomainFilterBuilder( 2904 RegistrableDomainFilterBuilder::BLACKLIST),
2907 RegistrableDomainFilterBuilder::BLACKLIST)),
2908 observer.target_b()); 2905 observer.target_b());
2909 tasks.emplace_back( 2906 tasks.emplace_back(
2910 BrowsingDataRemover::TimeRange(base::Time(), base::Time::UnixEpoch()), 2907 BrowsingDataRemover::TimeRange(base::Time(), base::Time::UnixEpoch()),
2911 BrowsingDataRemover::REMOVE_WEBSQL, 2908 BrowsingDataRemover::REMOVE_WEBSQL,
2912 BrowsingDataHelper::UNPROTECTED_WEB, 2909 BrowsingDataHelper::UNPROTECTED_WEB,
2913 std::move(filter_builder_1), 2910 std::move(filter_builder_1),
2914 observer.target_b()); 2911 observer.target_b());
2915 tasks.emplace_back( 2912 tasks.emplace_back(
2916 BrowsingDataRemover::TimeRange( 2913 BrowsingDataRemover::TimeRange(
2917 base::Time::UnixEpoch(), base::Time::Now()), 2914 base::Time::UnixEpoch(), base::Time::Now()),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 EXPECT_TRUE(remover->is_removing()); 2998 EXPECT_TRUE(remover->is_removing());
3002 2999
3003 // Add one more deletion and wait for it. 3000 // Add one more deletion and wait for it.
3004 BlockUntilBrowsingDataRemoved( 3001 BlockUntilBrowsingDataRemoved(
3005 browsing_data::ALL_TIME, 3002 browsing_data::ALL_TIME,
3006 BrowsingDataRemover::REMOVE_COOKIES, 3003 BrowsingDataRemover::REMOVE_COOKIES,
3007 BrowsingDataHelper::UNPROTECTED_WEB); 3004 BrowsingDataHelper::UNPROTECTED_WEB);
3008 3005
3009 EXPECT_FALSE(remover->is_removing()); 3006 EXPECT_FALSE(remover->is_removing());
3010 } 3007 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.cc ('k') | chrome/browser/browsing_data/hosted_apps_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698