OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h" | 6 #include "chrome/browser/safe_browsing/mock_permission_report_sender.h" |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
8 | 8 |
9 namespace safe_browsing { | 9 namespace safe_browsing { |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 content_type.CopyToString(&latest_content_type_); | 28 content_type.CopyToString(&latest_content_type_); |
29 number_of_reports_++; | 29 number_of_reports_++; |
30 | 30 |
31 // BrowserThreads aren't initialized in the unittest, so don't post tasks | 31 // BrowserThreads aren't initialized in the unittest, so don't post tasks |
32 // to them. | 32 // to them. |
33 if (!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI)) | 33 if (!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI)) |
34 return; | 34 return; |
35 | 35 |
36 content::BrowserThread::PostTask( | 36 content::BrowserThread::PostTask( |
37 content::BrowserThread::UI, FROM_HERE, | 37 content::BrowserThread::UI, FROM_HERE, |
38 base::Bind( | 38 base::BindOnce(&MockPermissionReportSender::NotifyReportSentOnUIThread, |
39 &MockPermissionReportSender::NotifyReportSentOnUIThread, | 39 base::Unretained(this))); |
40 base::Unretained(this))); | |
41 } | 40 } |
42 | 41 |
43 void MockPermissionReportSender::WaitForReportSent() { | 42 void MockPermissionReportSender::WaitForReportSent() { |
44 base::RunLoop run_loop; | 43 base::RunLoop run_loop; |
45 quit_closure_ = run_loop.QuitClosure(); | 44 quit_closure_ = run_loop.QuitClosure(); |
46 run_loop.Run(); | 45 run_loop.Run(); |
47 } | 46 } |
48 | 47 |
49 void MockPermissionReportSender::NotifyReportSentOnUIThread() { | 48 void MockPermissionReportSender::NotifyReportSentOnUIThread() { |
50 if (!quit_closure_.is_null()) { | 49 if (!quit_closure_.is_null()) { |
(...skipping 14 matching lines...) Expand all Loading... |
65 return latest_content_type_; | 64 return latest_content_type_; |
66 } | 65 } |
67 | 66 |
68 int MockPermissionReportSender::GetAndResetNumberOfReportsSent() { | 67 int MockPermissionReportSender::GetAndResetNumberOfReportsSent() { |
69 int new_reports = number_of_reports_; | 68 int new_reports = number_of_reports_; |
70 number_of_reports_ = 0; | 69 number_of_reports_ = 0; |
71 return new_reports; | 70 return new_reports; |
72 } | 71 } |
73 | 72 |
74 } // namespace safe_browsing | 73 } // namespace safe_browsing |
OLD | NEW |