| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/incident_reporting/incident_reporting_ser
vice.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 test_instance_.Get().Set(this); | 68 test_instance_.Get().Set(this); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual ~TestIncidentReportingService() { test_instance_.Get().Set(NULL); } | 71 virtual ~TestIncidentReportingService() { test_instance_.Get().Set(NULL); } |
| 72 | 72 |
| 73 bool IsProcessingReport() const { | 73 bool IsProcessingReport() const { |
| 74 return IncidentReportingService::IsProcessingReport(); | 74 return IncidentReportingService::IsProcessingReport(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 virtual void OnProfileAdded(Profile* profile) OVERRIDE { | 78 virtual void OnProfileAdded(Profile* profile) override { |
| 79 pre_profile_add_callback_.Run(profile); | 79 pre_profile_add_callback_.Run(profile); |
| 80 safe_browsing::IncidentReportingService::OnProfileAdded(profile); | 80 safe_browsing::IncidentReportingService::OnProfileAdded(profile); |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual scoped_ptr<safe_browsing::LastDownloadFinder> CreateDownloadFinder( | 83 virtual scoped_ptr<safe_browsing::LastDownloadFinder> CreateDownloadFinder( |
| 84 const safe_browsing::LastDownloadFinder::LastDownloadCallback& callback) | 84 const safe_browsing::LastDownloadFinder::LastDownloadCallback& callback) |
| 85 OVERRIDE { | 85 override { |
| 86 return create_download_finder_callback_.Run(callback); | 86 return create_download_finder_callback_.Run(callback); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual scoped_ptr<safe_browsing::IncidentReportUploader> StartReportUpload( | 89 virtual scoped_ptr<safe_browsing::IncidentReportUploader> StartReportUpload( |
| 90 const safe_browsing::IncidentReportUploader::OnResultCallback& callback, | 90 const safe_browsing::IncidentReportUploader::OnResultCallback& callback, |
| 91 const scoped_refptr<net::URLRequestContextGetter>& | 91 const scoped_refptr<net::URLRequestContextGetter>& |
| 92 request_context_getter, | 92 request_context_getter, |
| 93 const safe_browsing::ClientIncidentReport& report) OVERRIDE { | 93 const safe_browsing::ClientIncidentReport& report) override { |
| 94 return start_upload_callback_.Run(callback, report); | 94 return start_upload_callback_.Run(callback, report); |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 static TestIncidentReportingService& current() { | 98 static TestIncidentReportingService& current() { |
| 99 return *test_instance_.Get().Get(); | 99 return *test_instance_.Get().Get(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 static void CollectEnvironmentData( | 102 static void CollectEnvironmentData( |
| 103 safe_browsing::ClientIncidentReport_EnvironmentData* data) { | 103 safe_browsing::ClientIncidentReport_EnvironmentData* data) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 on_create_download_finder_action_( | 168 on_create_download_finder_action_( |
| 169 ON_CREATE_DOWNLOAD_FINDER_DOWNLOAD_FOUND), | 169 ON_CREATE_DOWNLOAD_FINDER_DOWNLOAD_FOUND), |
| 170 on_delayed_analysis_action_(ON_DELAYED_ANALYSIS_NO_ACTION), | 170 on_delayed_analysis_action_(ON_DELAYED_ANALYSIS_NO_ACTION), |
| 171 upload_result_(safe_browsing::IncidentReportUploader::UPLOAD_SUCCESS), | 171 upload_result_(safe_browsing::IncidentReportUploader::UPLOAD_SUCCESS), |
| 172 environment_collected_(), | 172 environment_collected_(), |
| 173 download_finder_created_(), | 173 download_finder_created_(), |
| 174 download_finder_destroyed_(), | 174 download_finder_destroyed_(), |
| 175 uploader_destroyed_(), | 175 uploader_destroyed_(), |
| 176 delayed_analysis_ran_() {} | 176 delayed_analysis_ran_() {} |
| 177 | 177 |
| 178 virtual void SetUp() OVERRIDE { | 178 virtual void SetUp() override { |
| 179 testing::Test::SetUp(); | 179 testing::Test::SetUp(); |
| 180 ASSERT_TRUE(profile_manager_.SetUp()); | 180 ASSERT_TRUE(profile_manager_.SetUp()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Sets the action to be taken by the test fixture when the service creates a | 183 // Sets the action to be taken by the test fixture when the service creates a |
| 184 // LastDownloadFinder. | 184 // LastDownloadFinder. |
| 185 void SetCreateDownloadFinderAction(OnCreateDownloadFinderAction action) { | 185 void SetCreateDownloadFinderAction(OnCreateDownloadFinderAction action) { |
| 186 on_create_download_finder_action_ = action; | 186 on_create_download_finder_action_ = action; |
| 187 } | 187 } |
| 188 | 188 |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 | 997 |
| 998 // Ensure that the report is dropped. | 998 // Ensure that the report is dropped. |
| 999 ASSERT_FALSE(instance_->IsProcessingReport()); | 999 ASSERT_FALSE(instance_->IsProcessingReport()); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 // Parallel uploads | 1002 // Parallel uploads |
| 1003 // Shutdown during processing | 1003 // Shutdown during processing |
| 1004 // environment colection taking longer than incident delay timer | 1004 // environment colection taking longer than incident delay timer |
| 1005 // environment colection taking longer than incident delay timer, and then | 1005 // environment colection taking longer than incident delay timer, and then |
| 1006 // another incident arriving | 1006 // another incident arriving |
| OLD | NEW |