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

Side by Side Diff: components/visitedlink/test/visitedlink_unittest.cc

Issue 623133002: replace OVERRIDE and FINAL with override and final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <cstdio> 5 #include <cstdio>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Returns a test URL for index |i| 48 // Returns a test URL for index |i|
49 GURL TestURL(int i) { 49 GURL TestURL(int i) {
50 return GURL(base::StringPrintf("%s%d", g_test_prefix, i)); 50 return GURL(base::StringPrintf("%s%d", g_test_prefix, i));
51 } 51 }
52 52
53 std::vector<VisitedLinkSlave*> g_slaves; 53 std::vector<VisitedLinkSlave*> g_slaves;
54 54
55 class TestVisitedLinkDelegate : public VisitedLinkDelegate { 55 class TestVisitedLinkDelegate : public VisitedLinkDelegate {
56 public: 56 public:
57 virtual void RebuildTable( 57 virtual void RebuildTable(
58 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; 58 const scoped_refptr<URLEnumerator>& enumerator) override;
59 59
60 void AddURLForRebuild(const GURL& url); 60 void AddURLForRebuild(const GURL& url);
61 61
62 private: 62 private:
63 URLs rebuild_urls_; 63 URLs rebuild_urls_;
64 }; 64 };
65 65
66 void TestVisitedLinkDelegate::RebuildTable( 66 void TestVisitedLinkDelegate::RebuildTable(
67 const scoped_refptr<URLEnumerator>& enumerator) { 67 const scoped_refptr<URLEnumerator>& enumerator) {
68 for (URLs::const_iterator itr = rebuild_urls_.begin(); 68 for (URLs::const_iterator itr = rebuild_urls_.begin();
69 itr != rebuild_urls_.end(); 69 itr != rebuild_urls_.end();
70 ++itr) 70 ++itr)
71 enumerator->OnURL(*itr); 71 enumerator->OnURL(*itr);
72 enumerator->OnComplete(true); 72 enumerator->OnComplete(true);
73 } 73 }
74 74
75 void TestVisitedLinkDelegate::AddURLForRebuild(const GURL& url) { 75 void TestVisitedLinkDelegate::AddURLForRebuild(const GURL& url) {
76 rebuild_urls_.push_back(url); 76 rebuild_urls_.push_back(url);
77 } 77 }
78 78
79 class TestURLIterator : public VisitedLinkMaster::URLIterator { 79 class TestURLIterator : public VisitedLinkMaster::URLIterator {
80 public: 80 public:
81 explicit TestURLIterator(const URLs& urls); 81 explicit TestURLIterator(const URLs& urls);
82 82
83 virtual const GURL& NextURL() OVERRIDE; 83 virtual const GURL& NextURL() override;
84 virtual bool HasNextURL() const OVERRIDE; 84 virtual bool HasNextURL() const override;
85 85
86 private: 86 private:
87 URLs::const_iterator iterator_; 87 URLs::const_iterator iterator_;
88 URLs::const_iterator end_; 88 URLs::const_iterator end_;
89 }; 89 };
90 90
91 TestURLIterator::TestURLIterator(const URLs& urls) 91 TestURLIterator::TestURLIterator(const URLs& urls)
92 : iterator_(urls.begin()), 92 : iterator_(urls.begin()),
93 end_(urls.end()) { 93 end_(urls.end()) {
94 } 94 }
95 95
96 const GURL& TestURLIterator::NextURL() { 96 const GURL& TestURLIterator::NextURL() {
97 return *(iterator_++); 97 return *(iterator_++);
98 } 98 }
99 99
100 bool TestURLIterator::HasNextURL() const { 100 bool TestURLIterator::HasNextURL() const {
101 return iterator_ != end_; 101 return iterator_ != end_;
102 } 102 }
103 103
104 } // namespace 104 } // namespace
105 105
106 class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener { 106 class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener {
107 public: 107 public:
108 TrackingVisitedLinkEventListener() 108 TrackingVisitedLinkEventListener()
109 : reset_count_(0), 109 : reset_count_(0),
110 add_count_(0) {} 110 add_count_(0) {}
111 111
112 virtual void NewTable(base::SharedMemory* table) OVERRIDE { 112 virtual void NewTable(base::SharedMemory* table) override {
113 if (table) { 113 if (table) {
114 for (std::vector<VisitedLinkSlave>::size_type i = 0; 114 for (std::vector<VisitedLinkSlave>::size_type i = 0;
115 i < g_slaves.size(); i++) { 115 i < g_slaves.size(); i++) {
116 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle(); 116 base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
117 table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle); 117 table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
118 g_slaves[i]->OnUpdateVisitedLinks(new_handle); 118 g_slaves[i]->OnUpdateVisitedLinks(new_handle);
119 } 119 }
120 } 120 }
121 } 121 }
122 virtual void Add(VisitedLinkCommon::Fingerprint) OVERRIDE { add_count_++; } 122 virtual void Add(VisitedLinkCommon::Fingerprint) override { add_count_++; }
123 virtual void Reset() OVERRIDE { reset_count_++; } 123 virtual void Reset() override { reset_count_++; }
124 124
125 void SetUp() { 125 void SetUp() {
126 reset_count_ = 0; 126 reset_count_ = 0;
127 add_count_ = 0; 127 add_count_ = 0;
128 } 128 }
129 129
130 int reset_count() const { return reset_count_; } 130 int reset_count() const { return reset_count_; }
131 int add_count() const { return add_count_; } 131 int add_count() const { return add_count_; }
132 132
133 private: 133 private:
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 content::Source<RenderProcessHost>(this), 536 content::Source<RenderProcessHost>(this),
537 content::NotificationService::NoDetails()); 537 content::NotificationService::NoDetails());
538 } 538 }
539 virtual ~VisitRelayingRenderProcessHost() { 539 virtual ~VisitRelayingRenderProcessHost() {
540 content::NotificationService::current()->Notify( 540 content::NotificationService::current()->Notify(
541 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 541 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
542 content::Source<content::RenderProcessHost>(this), 542 content::Source<content::RenderProcessHost>(this),
543 content::NotificationService::NoDetails()); 543 content::NotificationService::NoDetails());
544 } 544 }
545 545
546 virtual void WidgetRestored() OVERRIDE { widgets_++; } 546 virtual void WidgetRestored() override { widgets_++; }
547 virtual void WidgetHidden() OVERRIDE { widgets_--; } 547 virtual void WidgetHidden() override { widgets_--; }
548 virtual int VisibleWidgetCount() const OVERRIDE { return widgets_; } 548 virtual int VisibleWidgetCount() const override { return widgets_; }
549 549
550 virtual bool Send(IPC::Message* msg) OVERRIDE { 550 virtual bool Send(IPC::Message* msg) override {
551 VisitCountingContext* counting_context = 551 VisitCountingContext* counting_context =
552 static_cast<VisitCountingContext*>( 552 static_cast<VisitCountingContext*>(
553 GetBrowserContext()); 553 GetBrowserContext());
554 554
555 if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) { 555 if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) {
556 PickleIterator iter(*msg); 556 PickleIterator iter(*msg);
557 std::vector<uint64> fingerprints; 557 std::vector<uint64> fingerprints;
558 CHECK(IPC::ReadParam(msg, &iter, &fingerprints)); 558 CHECK(IPC::ReadParam(msg, &iter, &fingerprints));
559 counting_context->CountAddEvent(fingerprints.size()); 559 counting_context->CountAddEvent(fingerprints.size());
560 } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) { 560 } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) {
(...skipping 12 matching lines...) Expand all
573 DISALLOW_COPY_AND_ASSIGN(VisitRelayingRenderProcessHost); 573 DISALLOW_COPY_AND_ASSIGN(VisitRelayingRenderProcessHost);
574 }; 574 };
575 575
576 class VisitedLinkRenderProcessHostFactory 576 class VisitedLinkRenderProcessHostFactory
577 : public content::RenderProcessHostFactory { 577 : public content::RenderProcessHostFactory {
578 public: 578 public:
579 VisitedLinkRenderProcessHostFactory() 579 VisitedLinkRenderProcessHostFactory()
580 : content::RenderProcessHostFactory() {} 580 : content::RenderProcessHostFactory() {}
581 virtual content::RenderProcessHost* CreateRenderProcessHost( 581 virtual content::RenderProcessHost* CreateRenderProcessHost(
582 content::BrowserContext* browser_context, 582 content::BrowserContext* browser_context,
583 content::SiteInstance* site_instance) const OVERRIDE { 583 content::SiteInstance* site_instance) const override {
584 return new VisitRelayingRenderProcessHost(browser_context); 584 return new VisitRelayingRenderProcessHost(browser_context);
585 } 585 }
586 586
587 private: 587 private:
588 DISALLOW_COPY_AND_ASSIGN(VisitedLinkRenderProcessHostFactory); 588 DISALLOW_COPY_AND_ASSIGN(VisitedLinkRenderProcessHostFactory);
589 }; 589 };
590 590
591 class VisitedLinkEventsTest : public content::RenderViewHostTestHarness { 591 class VisitedLinkEventsTest : public content::RenderViewHostTestHarness {
592 public: 592 public:
593 virtual void SetUp() { 593 virtual void SetUp() {
594 SetRenderProcessHostFactory(&vc_rph_factory_); 594 SetRenderProcessHostFactory(&vc_rph_factory_);
595 content::RenderViewHostTestHarness::SetUp(); 595 content::RenderViewHostTestHarness::SetUp();
596 } 596 }
597 597
598 virtual content::BrowserContext* CreateBrowserContext() OVERRIDE { 598 virtual content::BrowserContext* CreateBrowserContext() override {
599 VisitCountingContext* context = new VisitCountingContext(); 599 VisitCountingContext* context = new VisitCountingContext();
600 master_.reset(new VisitedLinkMaster(context, &delegate_, true)); 600 master_.reset(new VisitedLinkMaster(context, &delegate_, true));
601 master_->Init(); 601 master_->Init();
602 return context; 602 return context;
603 } 603 }
604 604
605 VisitCountingContext* context() { 605 VisitCountingContext* context() {
606 return static_cast<VisitCountingContext*>(browser_context()); 606 return static_cast<VisitCountingContext*>(browser_context());
607 } 607 }
608 608
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 content::NotificationService::current()->Notify( 761 content::NotificationService::current()->Notify(
762 content::NOTIFICATION_RENDERER_PROCESS_CREATED, 762 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
763 content::Source<content::RenderProcessHost>(&different_process_host), 763 content::Source<content::RenderProcessHost>(&different_process_host),
764 content::NotificationService::NoDetails()); 764 content::NotificationService::NoDetails());
765 WaitForCoalescense(); 765 WaitForCoalescense();
766 766
767 EXPECT_EQ(0, different_context.new_table_count()); 767 EXPECT_EQ(0, different_context.new_table_count());
768 } 768 }
769 769
770 } // namespace visitedlink 770 } // namespace visitedlink
OLDNEW
« no previous file with comments | « components/visitedlink/test/visitedlink_perftest.cc ('k') | components/web_cache/browser/web_cache_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698