| 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 |
| 11 MockPermissionReportSender::MockPermissionReportSender() | 11 MockPermissionReportSender::MockPermissionReportSender() |
| 12 : net::ReportSender(nullptr, DO_NOT_SEND_COOKIES), | 12 : net::ReportSender(nullptr, DO_NOT_SEND_COOKIES), |
| 13 number_of_reports_(0) { | 13 number_of_reports_(0) { |
| 14 DCHECK(quit_closure_.is_null()); | 14 DCHECK(quit_closure_.is_null()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 MockPermissionReportSender::~MockPermissionReportSender() { | 17 MockPermissionReportSender::~MockPermissionReportSender() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 void MockPermissionReportSender::Send( | 20 void MockPermissionReportSender::Send( |
| 21 const GURL& report_uri, | 21 const GURL& report_uri, |
| 22 base::StringPiece content_type, | 22 base::StringPiece content_type, |
| 23 base::StringPiece report, | 23 base::StringPiece report, |
| 24 const base::Callback<void()>& success_callback, | 24 const base::Callback<void(int)>& success_callback, |
| 25 const base::Callback<void(const GURL&, int)>& error_callback) { | 25 const base::Callback<void(const GURL&, int)>& error_callback) { |
| 26 latest_report_uri_ = report_uri; | 26 latest_report_uri_ = report_uri; |
| 27 report.CopyToString(&latest_report_); | 27 report.CopyToString(&latest_report_); |
| 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; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 64 return latest_content_type_; | 64 return latest_content_type_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 int MockPermissionReportSender::GetAndResetNumberOfReportsSent() { | 67 int MockPermissionReportSender::GetAndResetNumberOfReportsSent() { |
| 68 int new_reports = number_of_reports_; | 68 int new_reports = number_of_reports_; |
| 69 number_of_reports_ = 0; | 69 number_of_reports_ = 0; |
| 70 return new_reports; | 70 return new_reports; |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace safe_browsing | 73 } // namespace safe_browsing |
| OLD | NEW |