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

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

Issue 666123002: Standardize usage of virtual/override/final in chrome/browser/browsing_data/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Horribleness Created 6 years, 2 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 base::Time remove_end; 126 base::Time remove_end;
127 StoragePartition::OriginMatcherFunction origin_matcher; 127 StoragePartition::OriginMatcherFunction origin_matcher;
128 128
129 StoragePartitionRemovalData() : remove_mask(0), 129 StoragePartitionRemovalData() : remove_mask(0),
130 quota_storage_remove_mask(0) {} 130 quota_storage_remove_mask(0) {}
131 }; 131 };
132 132
133 class TestStoragePartition : public StoragePartition { 133 class TestStoragePartition : public StoragePartition {
134 public: 134 public:
135 TestStoragePartition() {} 135 TestStoragePartition() {}
136 virtual ~TestStoragePartition() {} 136 ~TestStoragePartition() override {}
137 137
138 // content::StoragePartition implementation. 138 // content::StoragePartition implementation.
139 virtual base::FilePath GetPath() override { return base::FilePath(); } 139 base::FilePath GetPath() override { return base::FilePath(); }
140 virtual net::URLRequestContextGetter* GetURLRequestContext() override { 140 net::URLRequestContextGetter* GetURLRequestContext() override { return NULL; }
141 net::URLRequestContextGetter* GetMediaURLRequestContext() override {
141 return NULL; 142 return NULL;
142 } 143 }
143 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() override { 144 storage::QuotaManager* GetQuotaManager() override { return NULL; }
144 return NULL; 145 content::AppCacheService* GetAppCacheService() override { return NULL; }
145 } 146 storage::FileSystemContext* GetFileSystemContext() override { return NULL; }
146 virtual storage::QuotaManager* GetQuotaManager() override { return NULL; } 147 storage::DatabaseTracker* GetDatabaseTracker() override { return NULL; }
147 virtual content::AppCacheService* GetAppCacheService() override { 148 content::DOMStorageContext* GetDOMStorageContext() override { return NULL; }
148 return NULL; 149 content::IndexedDBContext* GetIndexedDBContext() override { return NULL; }
149 } 150 content::ServiceWorkerContext* GetServiceWorkerContext() override {
150 virtual storage::FileSystemContext* GetFileSystemContext() override {
151 return NULL;
152 }
153 virtual storage::DatabaseTracker* GetDatabaseTracker() override {
154 return NULL;
155 }
156 virtual content::DOMStorageContext* GetDOMStorageContext() override {
157 return NULL;
158 }
159 virtual content::IndexedDBContext* GetIndexedDBContext() override {
160 return NULL;
161 }
162 virtual content::ServiceWorkerContext* GetServiceWorkerContext() override {
163 return NULL; 151 return NULL;
164 } 152 }
165 153
166 virtual void ClearDataForOrigin(uint32 remove_mask, 154 void ClearDataForOrigin(uint32 remove_mask,
167 uint32 quota_storage_remove_mask, 155 uint32 quota_storage_remove_mask,
168 const GURL& storage_origin, 156 const GURL& storage_origin,
169 net::URLRequestContextGetter* rq_context, 157 net::URLRequestContextGetter* rq_context,
170 const base::Closure& callback) override { 158 const base::Closure& callback) override {
171 BrowserThread::PostTask(BrowserThread::UI, 159 BrowserThread::PostTask(BrowserThread::UI,
172 FROM_HERE, 160 FROM_HERE,
173 base::Bind(&TestStoragePartition::AsyncRunCallback, 161 base::Bind(&TestStoragePartition::AsyncRunCallback,
174 base::Unretained(this), 162 base::Unretained(this),
175 callback)); 163 callback));
176 } 164 }
177 165
178 virtual void ClearData(uint32 remove_mask, 166 void ClearData(uint32 remove_mask,
179 uint32 quota_storage_remove_mask, 167 uint32 quota_storage_remove_mask,
180 const GURL& storage_origin, 168 const GURL& storage_origin,
181 const OriginMatcherFunction& origin_matcher, 169 const OriginMatcherFunction& origin_matcher,
182 const base::Time begin, 170 const base::Time begin,
183 const base::Time end, 171 const base::Time end,
184 const base::Closure& callback) override { 172 const base::Closure& callback) override {
185 // Store stuff to verify parameters' correctness later. 173 // Store stuff to verify parameters' correctness later.
186 storage_partition_removal_data_.remove_mask = remove_mask; 174 storage_partition_removal_data_.remove_mask = remove_mask;
187 storage_partition_removal_data_.quota_storage_remove_mask = 175 storage_partition_removal_data_.quota_storage_remove_mask =
188 quota_storage_remove_mask; 176 quota_storage_remove_mask;
189 storage_partition_removal_data_.remove_origin = storage_origin; 177 storage_partition_removal_data_.remove_origin = storage_origin;
190 storage_partition_removal_data_.remove_begin = begin; 178 storage_partition_removal_data_.remove_begin = begin;
191 storage_partition_removal_data_.remove_end = end; 179 storage_partition_removal_data_.remove_end = end;
192 storage_partition_removal_data_.origin_matcher = origin_matcher; 180 storage_partition_removal_data_.origin_matcher = origin_matcher;
193 181
194 BrowserThread::PostTask( 182 BrowserThread::PostTask(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 class RemoveChannelIDTester : public net::SSLConfigService::Observer { 298 class RemoveChannelIDTester : public net::SSLConfigService::Observer {
311 public: 299 public:
312 explicit RemoveChannelIDTester(TestingProfile* profile) 300 explicit RemoveChannelIDTester(TestingProfile* profile)
313 : ssl_config_changed_count_(0) { 301 : ssl_config_changed_count_(0) {
314 channel_id_service_ = profile->GetRequestContext()-> 302 channel_id_service_ = profile->GetRequestContext()->
315 GetURLRequestContext()->channel_id_service(); 303 GetURLRequestContext()->channel_id_service();
316 ssl_config_service_ = profile->GetSSLConfigService(); 304 ssl_config_service_ = profile->GetSSLConfigService();
317 ssl_config_service_->AddObserver(this); 305 ssl_config_service_->AddObserver(this);
318 } 306 }
319 307
320 virtual ~RemoveChannelIDTester() { 308 ~RemoveChannelIDTester() override {
321 ssl_config_service_->RemoveObserver(this); 309 ssl_config_service_->RemoveObserver(this);
322 } 310 }
323 311
324 int ChannelIDCount() { 312 int ChannelIDCount() {
325 return channel_id_service_->cert_count(); 313 return channel_id_service_->cert_count();
326 } 314 }
327 315
328 // Add a server bound cert for |server| with specific creation and expiry 316 // Add a server bound cert for |server| with specific creation and expiry
329 // times. The cert and key data will be filled with dummy values. 317 // times. The cert and key data will be filled with dummy values.
330 void AddChannelIDWithTimes(const std::string& server_identifier, 318 void AddChannelIDWithTimes(const std::string& server_identifier,
(...skipping 23 matching lines...) Expand all
354 342
355 net::ChannelIDStore* GetChannelIDStore() { 343 net::ChannelIDStore* GetChannelIDStore() {
356 return channel_id_service_->GetChannelIDStore(); 344 return channel_id_service_->GetChannelIDStore();
357 } 345 }
358 346
359 int ssl_config_changed_count() const { 347 int ssl_config_changed_count() const {
360 return ssl_config_changed_count_; 348 return ssl_config_changed_count_;
361 } 349 }
362 350
363 // net::SSLConfigService::Observer implementation: 351 // net::SSLConfigService::Observer implementation:
364 virtual void OnSSLConfigChanged() override { 352 void OnSSLConfigChanged() override { ssl_config_changed_count_++; }
365 ssl_config_changed_count_++;
366 }
367 353
368 private: 354 private:
369 static void GetAllChannelIDsCallback( 355 static void GetAllChannelIDsCallback(
370 net::ChannelIDStore::ChannelIDList* dest, 356 net::ChannelIDStore::ChannelIDList* dest,
371 const net::ChannelIDStore::ChannelIDList& result) { 357 const net::ChannelIDStore::ChannelIDList& result) {
372 *dest = result; 358 *dest = result;
373 } 359 }
374 360
375 net::ChannelIDService* channel_id_service_; 361 net::ChannelIDService* channel_id_service_;
376 scoped_refptr<net::SSLConfigService> ssl_config_service_; 362 scoped_refptr<net::SSLConfigService> ssl_config_service_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 420
435 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver { 421 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver {
436 public: 422 public:
437 explicit RemoveAutofillTester(TestingProfile* profile) 423 explicit RemoveAutofillTester(TestingProfile* profile)
438 : personal_data_manager_( 424 : personal_data_manager_(
439 autofill::PersonalDataManagerFactory::GetForProfile(profile)) { 425 autofill::PersonalDataManagerFactory::GetForProfile(profile)) {
440 autofill::test::DisableSystemServices(profile->GetPrefs()); 426 autofill::test::DisableSystemServices(profile->GetPrefs());
441 personal_data_manager_->AddObserver(this); 427 personal_data_manager_->AddObserver(this);
442 } 428 }
443 429
444 virtual ~RemoveAutofillTester() { 430 ~RemoveAutofillTester() override {
445 personal_data_manager_->RemoveObserver(this); 431 personal_data_manager_->RemoveObserver(this);
446 } 432 }
447 433
448 // Returns true if there are autofill profiles. 434 // Returns true if there are autofill profiles.
449 bool HasProfile() { 435 bool HasProfile() {
450 return !personal_data_manager_->GetProfiles().empty() && 436 return !personal_data_manager_->GetProfiles().empty() &&
451 !personal_data_manager_->GetCreditCards().empty(); 437 !personal_data_manager_->GetCreditCards().empty();
452 } 438 }
453 439
454 bool HasOrigin(const std::string& origin) { 440 bool HasOrigin(const std::string& origin) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 491
506 card.set_guid(base::GenerateGUID()); 492 card.set_guid(base::GenerateGUID());
507 card.set_origin(kChromeOrigin); 493 card.set_origin(kChromeOrigin);
508 cards.push_back(card); 494 cards.push_back(card);
509 495
510 personal_data_manager_->SetCreditCards(&cards); 496 personal_data_manager_->SetCreditCards(&cards);
511 base::MessageLoop::current()->Run(); 497 base::MessageLoop::current()->Run();
512 } 498 }
513 499
514 private: 500 private:
515 virtual void OnPersonalDataChanged() override { 501 void OnPersonalDataChanged() override {
516 base::MessageLoop::current()->Quit(); 502 base::MessageLoop::current()->Quit();
517 } 503 }
518 504
519 autofill::PersonalDataManager* personal_data_manager_; 505 autofill::PersonalDataManager* personal_data_manager_;
520 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); 506 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester);
521 }; 507 };
522 508
523 class RemoveLocalStorageTester { 509 class RemoveLocalStorageTester {
524 public: 510 public:
525 explicit RemoveLocalStorageTester(TestingProfile* profile) 511 explicit RemoveLocalStorageTester(TestingProfile* profile)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 std::vector<content::LocalStorageUsageInfo> infos_; 576 std::vector<content::LocalStorageUsageInfo> infos_;
591 base::Closure quit_closure_; 577 base::Closure quit_closure_;
592 578
593 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); 579 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester);
594 }; 580 };
595 581
596 class MockDomainReliabilityService : public DomainReliabilityService { 582 class MockDomainReliabilityService : public DomainReliabilityService {
597 public: 583 public:
598 MockDomainReliabilityService() : clear_count_(0) {} 584 MockDomainReliabilityService() : clear_count_(0) {}
599 585
600 virtual ~MockDomainReliabilityService() {} 586 ~MockDomainReliabilityService() override {}
601 587
602 virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor( 588 scoped_ptr<DomainReliabilityMonitor> CreateMonitor(
603 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) 589 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
604 override { 590 override {
605 NOTREACHED(); 591 NOTREACHED();
606 return scoped_ptr<DomainReliabilityMonitor>(); 592 return scoped_ptr<DomainReliabilityMonitor>();
607 } 593 }
608 594
609 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, 595 void ClearBrowsingData(DomainReliabilityClearMode clear_mode,
610 const base::Closure& callback) override { 596 const base::Closure& callback) override {
611 clear_count_++; 597 clear_count_++;
612 last_clear_mode_ = clear_mode; 598 last_clear_mode_ = clear_mode;
613 callback.Run(); 599 callback.Run();
614 } 600 }
615 601
616 virtual void GetWebUIData( 602 void GetWebUIData(const base::Callback<void(scoped_ptr<base::Value>)>&
617 const base::Callback<void(scoped_ptr<base::Value>)>& callback) 603 callback) const override {
618 const override {
619 NOTREACHED(); 604 NOTREACHED();
620 } 605 }
621 606
622 int clear_count() const { return clear_count_; } 607 int clear_count() const { return clear_count_; }
623 608
624 DomainReliabilityClearMode last_clear_mode() const { 609 DomainReliabilityClearMode last_clear_mode() const {
625 return last_clear_mode_; 610 return last_clear_mode_;
626 } 611 }
627 612
628 private: 613 private:
629 unsigned clear_count_; 614 unsigned clear_count_;
630 DomainReliabilityClearMode last_clear_mode_; 615 DomainReliabilityClearMode last_clear_mode_;
631 }; 616 };
632 617
633 struct TestingDomainReliabilityServiceFactoryUserData 618 struct TestingDomainReliabilityServiceFactoryUserData
634 : public base::SupportsUserData::Data { 619 : public base::SupportsUserData::Data {
635 TestingDomainReliabilityServiceFactoryUserData( 620 TestingDomainReliabilityServiceFactoryUserData(
636 content::BrowserContext* context, 621 content::BrowserContext* context,
637 MockDomainReliabilityService* service) 622 MockDomainReliabilityService* service)
638 : context(context), 623 : context(context),
639 service(service), 624 service(service),
640 attached(false) {} 625 attached(false) {}
641 virtual ~TestingDomainReliabilityServiceFactoryUserData() {} 626 ~TestingDomainReliabilityServiceFactoryUserData() override {}
642 627
643 content::BrowserContext* const context; 628 content::BrowserContext* const context;
644 MockDomainReliabilityService* const service; 629 MockDomainReliabilityService* const service;
645 bool attached; 630 bool attached;
646 631
647 static const void* kKey; 632 static const void* kKey;
648 }; 633 };
649 634
650 // static 635 // static
651 const void* TestingDomainReliabilityServiceFactoryUserData::kKey = 636 const void* TestingDomainReliabilityServiceFactoryUserData::kKey =
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 779
795 int GetOriginSetMask() { 780 int GetOriginSetMask() {
796 return called_with_details_->origin_set_mask; 781 return called_with_details_->origin_set_mask;
797 } 782 }
798 783
799 StoragePartitionRemovalData GetStoragePartitionRemovalData() { 784 StoragePartitionRemovalData GetStoragePartitionRemovalData() {
800 return storage_partition_removal_data_; 785 return storage_partition_removal_data_;
801 } 786 }
802 787
803 // content::NotificationObserver implementation. 788 // content::NotificationObserver implementation.
804 virtual void Observe(int type, 789 void Observe(int type,
805 const content::NotificationSource& source, 790 const content::NotificationSource& source,
806 const content::NotificationDetails& details) override { 791 const content::NotificationDetails& details) override {
807 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED); 792 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED);
808 793
809 // We're not taking ownership of the details object, but storing a copy of 794 // We're not taking ownership of the details object, but storing a copy of
810 // it locally. 795 // it locally.
811 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails( 796 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails(
812 *content::Details<BrowsingDataRemover::NotificationDetails>( 797 *content::Details<BrowsingDataRemover::NotificationDetails>(
813 details).ptr())); 798 details).ptr()));
814 799
815 registrar_.RemoveAll(); 800 registrar_.RemoveAll();
816 } 801 }
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 EXPECT_EQ(1u, tester.clear_count()); 1814 EXPECT_EQ(1u, tester.clear_count());
1830 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); 1815 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode());
1831 } 1816 }
1832 1817
1833 TEST_F(BrowsingDataRemoverTest, DomainReliability_NoMonitor) { 1818 TEST_F(BrowsingDataRemoverTest, DomainReliability_NoMonitor) {
1834 BlockUntilBrowsingDataRemoved( 1819 BlockUntilBrowsingDataRemoved(
1835 BrowsingDataRemover::EVERYTHING, 1820 BrowsingDataRemover::EVERYTHING,
1836 BrowsingDataRemover::REMOVE_HISTORY | 1821 BrowsingDataRemover::REMOVE_HISTORY |
1837 BrowsingDataRemover::REMOVE_COOKIES, false); 1822 BrowsingDataRemover::REMOVE_COOKIES, false);
1838 } 1823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698