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

Side by Side Diff: chrome/browser/safe_browsing/notification_image_reporter_unittest.cc

Issue 2821193005: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/safe_browsing (Closed)
Patch Set: Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/safe_browsing/notification_image_reporter.h" 5 #include "chrome/browser/safe_browsing/notification_image_reporter.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/scoped_feature_list.h" 10 #include "base/test/scoped_feature_list.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void SetReportingChance(bool reporting_chance) { 44 void SetReportingChance(bool reporting_chance) {
45 reporting_chance_ = reporting_chance; 45 reporting_chance_ = reporting_chance;
46 } 46 }
47 47
48 protected: 48 protected:
49 double GetReportChance() const override { return reporting_chance_; } 49 double GetReportChance() const override { return reporting_chance_; }
50 void SkippedReporting() override { 50 void SkippedReporting() override {
51 DCHECK_CURRENTLY_ON(BrowserThread::IO); 51 DCHECK_CURRENTLY_ON(BrowserThread::IO);
52 BrowserThread::PostTask( 52 BrowserThread::PostTask(
53 BrowserThread::UI, FROM_HERE, 53 BrowserThread::UI, FROM_HERE,
54 base::Bind(&TestingNotificationImageReporter::SkippedReportingOnUI, 54 base::BindOnce(&TestingNotificationImageReporter::SkippedReportingOnUI,
55 base::Unretained(this))); 55 base::Unretained(this)));
56 } 56 }
57 57
58 private: 58 private:
59 void SkippedReportingOnUI() { 59 void SkippedReportingOnUI() {
60 if (quit_closure_) { 60 if (quit_closure_) {
61 quit_closure_.Run(); 61 quit_closure_.Run();
62 quit_closure_.Reset(); 62 quit_closure_.Reset();
63 } 63 }
64 } 64 }
65 base::Closure quit_closure_; 65 base::Closure quit_closure_;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService( 137 TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(
138 safe_browsing_service_.get()); 138 safe_browsing_service_.get());
139 g_browser_process->safe_browsing_service()->Initialize(); 139 g_browser_process->safe_browsing_service()->Initialize();
140 base::RunLoop().RunUntilIdle(); // TODO(johnme): Might still be tasks on IO. 140 base::RunLoop().RunUntilIdle(); // TODO(johnme): Might still be tasks on IO.
141 141
142 profile_ = base::MakeUnique<TestingProfile>(); 142 profile_ = base::MakeUnique<TestingProfile>();
143 143
144 base::RunLoop run_loop; 144 base::RunLoop run_loop;
145 BrowserThread::PostTaskAndReply( 145 BrowserThread::PostTaskAndReply(
146 BrowserThread::IO, FROM_HERE, 146 BrowserThread::IO, FROM_HERE,
147 base::Bind(&NotificationImageReporterTest::SetUpOnIO, 147 base::BindOnce(&NotificationImageReporterTest::SetUpOnIO,
148 base::Unretained(this)), 148 base::Unretained(this)),
149 run_loop.QuitClosure()); 149 run_loop.QuitClosure());
150 run_loop.Run(); 150 run_loop.Run();
151 } 151 }
152 152
153 void NotificationImageReporterTest::TearDown() { 153 void NotificationImageReporterTest::TearDown() {
154 TestingBrowserProcess::GetGlobal()->safe_browsing_service()->ShutDown(); 154 TestingBrowserProcess::GetGlobal()->safe_browsing_service()->ShutDown();
155 base::RunLoop().RunUntilIdle(); // TODO(johnme): Might still be tasks on IO. 155 base::RunLoop().RunUntilIdle(); // TODO(johnme): Might still be tasks on IO.
156 TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(nullptr); 156 TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(nullptr);
157 } 157 }
158 158
(...skipping 14 matching lines...) Expand all
173 feature_list_->InitWithFeatures({safe_browsing::kOnlyShowScoutOptIn}, {}); 173 feature_list_->InitWithFeatures({safe_browsing::kOnlyShowScoutOptIn}, {});
174 174
175 InitializeSafeBrowsingPrefs(profile_->GetPrefs()); 175 InitializeSafeBrowsingPrefs(profile_->GetPrefs());
176 SetExtendedReportingPref(profile_->GetPrefs(), level != SBER_LEVEL_OFF); 176 SetExtendedReportingPref(profile_->GetPrefs(), level != SBER_LEVEL_OFF);
177 } 177 }
178 178
179 void NotificationImageReporterTest::ReportNotificationImage() { 179 void NotificationImageReporterTest::ReportNotificationImage() {
180 DCHECK_CURRENTLY_ON(BrowserThread::UI); 180 DCHECK_CURRENTLY_ON(BrowserThread::UI);
181 BrowserThread::PostTask( 181 BrowserThread::PostTask(
182 BrowserThread::IO, FROM_HERE, 182 BrowserThread::IO, FROM_HERE,
183 base::Bind(&NotificationImageReporterTest::ReportNotificationImageOnIO, 183 base::BindOnce(
184 base::Unretained(this))); 184 &NotificationImageReporterTest::ReportNotificationImageOnIO,
185 base::Unretained(this)));
185 } 186 }
186 187
187 void NotificationImageReporterTest::ReportNotificationImageOnIO() { 188 void NotificationImageReporterTest::ReportNotificationImageOnIO() {
188 DCHECK_CURRENTLY_ON(BrowserThread::IO); 189 DCHECK_CURRENTLY_ON(BrowserThread::IO);
189 if (!safe_browsing_service_->enabled()) 190 if (!safe_browsing_service_->enabled())
190 return; 191 return;
191 safe_browsing_service_->ping_manager()->ReportNotificationImage( 192 safe_browsing_service_->ping_manager()->ReportNotificationImage(
192 profile_.get(), safe_browsing_service_->database_manager(), origin_, 193 profile_.get(), safe_browsing_service_->database_manager(), origin_,
193 image_); 194 image_);
194 } 195 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 mock_report_sender_->WaitForReportSent(); 277 mock_report_sender_->WaitForReportSent();
277 } 278 }
278 ReportNotificationImage(); 279 ReportNotificationImage();
279 notification_image_reporter_->WaitForReportSkipped(); 280 notification_image_reporter_->WaitForReportSkipped();
280 281
281 EXPECT_EQ(kMaxReportsPerDay, 282 EXPECT_EQ(kMaxReportsPerDay,
282 mock_report_sender_->GetAndResetNumberOfReportsSent()); 283 mock_report_sender_->GetAndResetNumberOfReportsSent());
283 } 284 }
284 285
285 } // namespace safe_browsing 286 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698