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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/test/mock_entropy_provider.h" | 20 #include "base/test/mock_entropy_provider.h" |
21 #include "base/test/scoped_feature_list.h" | 21 #include "base/test/scoped_feature_list.h" |
22 #include "base/test/scoped_mock_time_message_loop_task_runner.h" | 22 #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
23 #include "base/threading/thread_local.h" | 23 #include "base/threading/thread_local.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "base/values.h" |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "chrome/browser/prefs/browser_prefs.h" | 27 #include "chrome/browser/prefs/browser_prefs.h" |
27 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" | 28 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" |
28 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | 29 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" |
29 #include "chrome/browser/safe_browsing/incident_reporting/incident_report_upload
er.h" | 30 #include "chrome/browser/safe_browsing/incident_reporting/incident_report_upload
er.h" |
30 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" | 31 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" |
31 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc
ident.h" | 32 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc
ident.h" |
32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
33 #include "chrome/test/base/testing_browser_process.h" | 34 #include "chrome/test/base/testing_browser_process.h" |
34 #include "chrome/test/base/testing_profile.h" | 35 #include "chrome/test/base/testing_profile.h" |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 TEST_F(IncidentReportingServiceTest, CleanLegacyPruneState) { | 1307 TEST_F(IncidentReportingServiceTest, CleanLegacyPruneState) { |
1307 CreateIncidentReportingService(); | 1308 CreateIncidentReportingService(); |
1308 const std::string omnibox_type(base::IntToString( | 1309 const std::string omnibox_type(base::IntToString( |
1309 static_cast<int32_t>(safe_browsing::IncidentType::OMNIBOX_INTERACTION))); | 1310 static_cast<int32_t>(safe_browsing::IncidentType::OMNIBOX_INTERACTION))); |
1310 const std::string preference_type(base::IntToString( | 1311 const std::string preference_type(base::IntToString( |
1311 static_cast<int32_t>(safe_browsing::IncidentType::TRACKED_PREFERENCE))); | 1312 static_cast<int32_t>(safe_browsing::IncidentType::TRACKED_PREFERENCE))); |
1312 | 1313 |
1313 // Set up a prune state dict with data to be cleared (and not). | 1314 // Set up a prune state dict with data to be cleared (and not). |
1314 std::unique_ptr<base::DictionaryValue> incidents_sent( | 1315 std::unique_ptr<base::DictionaryValue> incidents_sent( |
1315 new base::DictionaryValue()); | 1316 new base::DictionaryValue()); |
1316 base::DictionaryValue* type_dict = new base::DictionaryValue(); | 1317 auto type_dict = base::MakeUnique<base::DictionaryValue>(); |
1317 type_dict->SetStringWithoutPathExpansion("foo", "47"); | 1318 type_dict->SetStringWithoutPathExpansion("foo", "47"); |
1318 incidents_sent->SetWithoutPathExpansion(omnibox_type, type_dict); | 1319 incidents_sent->SetWithoutPathExpansion(omnibox_type, std::move(type_dict)); |
1319 type_dict = new base::DictionaryValue(); | 1320 type_dict = base::MakeUnique<base::DictionaryValue>(); |
1320 type_dict->SetStringWithoutPathExpansion("bar", "43"); | 1321 type_dict->SetStringWithoutPathExpansion("bar", "43"); |
1321 incidents_sent->SetWithoutPathExpansion(preference_type, type_dict); | 1322 incidents_sent->SetWithoutPathExpansion(preference_type, |
| 1323 std::move(type_dict)); |
1322 | 1324 |
1323 // Add a profile. | 1325 // Add a profile. |
1324 Profile* profile = | 1326 Profile* profile = |
1325 CreateProfile("profile1", SAFE_BROWSING_AND_EXTENDED_REPORTING, | 1327 CreateProfile("profile1", SAFE_BROWSING_AND_EXTENDED_REPORTING, |
1326 ON_PROFILE_ADDITION_NO_ACTION, std::move(incidents_sent)); | 1328 ON_PROFILE_ADDITION_NO_ACTION, std::move(incidents_sent)); |
1327 | 1329 |
1328 // Let all tasks run. | 1330 // Let all tasks run. |
1329 mock_time_task_runner_->FastForwardUntilNoTasksRemain(); | 1331 mock_time_task_runner_->FastForwardUntilNoTasksRemain(); |
1330 | 1332 |
1331 const base::DictionaryValue* new_state = | 1333 const base::DictionaryValue* new_state = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 | 1404 |
1403 // Ensure that no report processing remains. | 1405 // Ensure that no report processing remains. |
1404 ASSERT_FALSE(instance_->IsProcessingReport()); | 1406 ASSERT_FALSE(instance_->IsProcessingReport()); |
1405 } | 1407 } |
1406 | 1408 |
1407 // Parallel uploads | 1409 // Parallel uploads |
1408 // Shutdown during processing | 1410 // Shutdown during processing |
1409 // environment colection taking longer than incident delay timer | 1411 // environment colection taking longer than incident delay timer |
1410 // environment colection taking longer than incident delay timer, and then | 1412 // environment colection taking longer than incident delay timer, and then |
1411 // another incident arriving | 1413 // another incident arriving |
OLD | NEW |