juliatuttle | 58684333 | 2017-03-27 16:22:37 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/reporting/reporting_test_util.h" |
| 6 | |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 7 | #include <memory> |
| 8 | #include <string> |
juliatuttle | 58684333 | 2017-03-27 16:22:37 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 11 | #include "base/bind.h" |
Hans Wennborg | 0924470b | 2020-04-27 21:08:05 | [diff] [blame] | 12 | #include "base/check_op.h" |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 13 | #include "base/json/json_reader.h" |
| 14 | #include "base/memory/ptr_util.h" |
Hans Wennborg | 0924470b | 2020-04-27 21:08:05 | [diff] [blame] | 15 | #include "base/notreached.h" |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 16 | #include "base/strings/stringprintf.h" |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 17 | #include "base/test/simple_test_clock.h" |
| 18 | #include "base/test/simple_test_tick_clock.h" |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 19 | #include "base/timer/mock_timer.h" |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 20 | #include "net/base/network_isolation_key.h" |
juliatuttle | 58684333 | 2017-03-27 16:22:37 | [diff] [blame] | 21 | #include "net/reporting/reporting_cache.h" |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 22 | #include "net/reporting/reporting_context.h" |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 23 | #include "net/reporting/reporting_delegate.h" |
juliatuttle | 830962a | 2017-04-19 17:50:04 | [diff] [blame] | 24 | #include "net/reporting/reporting_delivery_agent.h" |
Lily Chen | fc92ff4 | 2019-05-06 22:59:10 | [diff] [blame] | 25 | #include "net/reporting/reporting_endpoint.h" |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 26 | #include "net/reporting/reporting_garbage_collector.h" |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 27 | #include "net/reporting/reporting_policy.h" |
| 28 | #include "net/reporting/reporting_uploader.h" |
| 29 | #include "testing/gtest/include/gtest/gtest.h" |
juliatuttle | 58684333 | 2017-03-27 16:22:37 | [diff] [blame] | 30 | #include "url/gurl.h" |
| 31 | #include "url/origin.h" |
| 32 | |
| 33 | namespace net { |
| 34 | |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 35 | namespace { |
| 36 | |
| 37 | class PendingUploadImpl : public TestReportingUploader::PendingUpload { |
| 38 | public: |
Douglas Creager | 3428d81 | 2018-07-13 03:59:56 | [diff] [blame] | 39 | PendingUploadImpl(const url::Origin& report_origin, |
| 40 | const GURL& url, |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 41 | const NetworkIsolationKey& network_isolation_key, |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 42 | const std::string& json, |
| 43 | ReportingUploader::UploadCallback callback, |
| 44 | base::OnceCallback<void(PendingUpload*)> complete_callback) |
Douglas Creager | 3428d81 | 2018-07-13 03:59:56 | [diff] [blame] | 45 | : report_origin_(report_origin), |
| 46 | url_(url), |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 47 | network_isolation_key_(network_isolation_key), |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 48 | json_(json), |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 49 | callback_(std::move(callback)), |
| 50 | complete_callback_(std::move(complete_callback)) {} |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 51 | |
Chris Watkins | 806691b | 2017-12-01 06:01:22 | [diff] [blame] | 52 | ~PendingUploadImpl() override = default; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 53 | |
Julia Tuttle | 107e3067 | 2018-03-29 18:48:42 | [diff] [blame] | 54 | // PendingUpload implementation: |
Douglas Creager | 3428d81 | 2018-07-13 03:59:56 | [diff] [blame] | 55 | const url::Origin& report_origin() const override { return report_origin_; } |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 56 | const GURL& url() const override { return url_; } |
| 57 | const std::string& json() const override { return json_; } |
| 58 | std::unique_ptr<base::Value> GetValue() const override { |
Lei Zhang | a8b4c5fb | 2019-02-16 03:02:03 | [diff] [blame] | 59 | return base::JSONReader::ReadDeprecated(json_); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void Complete(ReportingUploader::Outcome outcome) override { |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 63 | std::move(callback_).Run(outcome); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 64 | // Deletes |this|. |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 65 | std::move(complete_callback_).Run(this); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | private: |
Douglas Creager | 3428d81 | 2018-07-13 03:59:56 | [diff] [blame] | 69 | url::Origin report_origin_; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 70 | GURL url_; |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 71 | NetworkIsolationKey network_isolation_key_; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 72 | std::string json_; |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 73 | ReportingUploader::UploadCallback callback_; |
| 74 | base::OnceCallback<void(PendingUpload*)> complete_callback_; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | void ErasePendingUpload( |
| 78 | std::vector<std::unique_ptr<TestReportingUploader::PendingUpload>>* uploads, |
| 79 | TestReportingUploader::PendingUpload* upload) { |
| 80 | for (auto it = uploads->begin(); it != uploads->end(); ++it) { |
| 81 | if (it->get() == upload) { |
| 82 | uploads->erase(it); |
| 83 | return; |
| 84 | } |
| 85 | } |
| 86 | NOTREACHED(); |
| 87 | } |
| 88 | |
| 89 | } // namespace |
| 90 | |
Matt Menke | 515136d | 2019-10-05 00:27:09 | [diff] [blame] | 91 | RandIntCallback TestReportingRandIntCallback() { |
| 92 | return base::BindRepeating( |
| 93 | [](int* rand_counter, int min, int max) { |
| 94 | DCHECK_LE(min, max); |
| 95 | return min + ((*rand_counter)++ % (max - min + 1)); |
| 96 | }, |
| 97 | base::Owned(std::make_unique<int>(0))); |
| 98 | } |
| 99 | |
Chris Watkins | 806691b | 2017-12-01 06:01:22 | [diff] [blame] | 100 | TestReportingUploader::PendingUpload::~PendingUpload() = default; |
| 101 | TestReportingUploader::PendingUpload::PendingUpload() = default; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 102 | |
Chris Watkins | 806691b | 2017-12-01 06:01:22 | [diff] [blame] | 103 | TestReportingUploader::TestReportingUploader() = default; |
| 104 | TestReportingUploader::~TestReportingUploader() = default; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 105 | |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 106 | void TestReportingUploader::StartUpload( |
| 107 | const url::Origin& report_origin, |
| 108 | const GURL& url, |
| 109 | const NetworkIsolationKey& network_isolation_key, |
| 110 | const std::string& json, |
| 111 | int max_depth, |
| 112 | UploadCallback callback) { |
Jeremy Roman | 0579ed6 | 2017-08-29 15:56:19 | [diff] [blame] | 113 | pending_uploads_.push_back(std::make_unique<PendingUploadImpl>( |
Matt Menke | 5577421a | 2019-10-10 00:04:49 | [diff] [blame] | 114 | report_origin, url, network_isolation_key, json, std::move(callback), |
Julia Tuttle | ed8d84b | 2017-12-05 18:54:53 | [diff] [blame] | 115 | base::BindOnce(&ErasePendingUpload, &pending_uploads_))); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 116 | } |
| 117 | |
Lily Chen | 91b51e6 | 2019-03-01 16:46:07 | [diff] [blame] | 118 | void TestReportingUploader::OnShutdown() { |
| 119 | pending_uploads_.clear(); |
| 120 | } |
| 121 | |
| 122 | int TestReportingUploader::GetPendingUploadCountForTesting() const { |
| 123 | return pending_uploads_.size(); |
| 124 | } |
| 125 | |
Matt Menke | 515136d | 2019-10-05 00:27:09 | [diff] [blame] | 126 | TestReportingDelegate::TestReportingDelegate() = default; |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 127 | |
Chris Watkins | 806691b | 2017-12-01 06:01:22 | [diff] [blame] | 128 | TestReportingDelegate::~TestReportingDelegate() = default; |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 129 | |
| 130 | bool TestReportingDelegate::CanQueueReport(const url::Origin& origin) const { |
| 131 | return true; |
| 132 | } |
| 133 | |
Douglas Creager | 7b07ea4 | 2018-02-27 21:08:08 | [diff] [blame] | 134 | void TestReportingDelegate::CanSendReports( |
| 135 | std::set<url::Origin> origins, |
| 136 | base::OnceCallback<void(std::set<url::Origin>)> result_callback) const { |
Douglas Creager | 66494e1 | 2018-03-05 22:21:00 | [diff] [blame] | 137 | if (pause_permissions_check_) { |
| 138 | saved_origins_ = std::move(origins); |
| 139 | permissions_check_callback_ = std::move(result_callback); |
| 140 | return; |
| 141 | } |
| 142 | |
Douglas Creager | 7b07ea4 | 2018-02-27 21:08:08 | [diff] [blame] | 143 | if (disallow_report_uploads_) |
| 144 | origins.clear(); |
| 145 | std::move(result_callback).Run(std::move(origins)); |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 146 | } |
| 147 | |
Douglas Creager | 66494e1 | 2018-03-05 22:21:00 | [diff] [blame] | 148 | bool TestReportingDelegate::PermissionsCheckPaused() const { |
| 149 | return !permissions_check_callback_.is_null(); |
| 150 | } |
| 151 | |
| 152 | void TestReportingDelegate::ResumePermissionsCheck() { |
| 153 | if (disallow_report_uploads_) |
| 154 | saved_origins_.clear(); |
| 155 | std::move(permissions_check_callback_).Run(std::move(saved_origins_)); |
| 156 | } |
| 157 | |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 158 | bool TestReportingDelegate::CanSetClient(const url::Origin& origin, |
| 159 | const GURL& endpoint) const { |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | bool TestReportingDelegate::CanUseClient(const url::Origin& origin, |
| 164 | const GURL& endpoint) const { |
| 165 | return true; |
| 166 | } |
| 167 | |
Lily Chen | 731a95c | 2019-05-06 22:27:22 | [diff] [blame] | 168 | TestReportingContext::TestReportingContext( |
| 169 | base::Clock* clock, |
| 170 | const base::TickClock* tick_clock, |
| 171 | const ReportingPolicy& policy, |
| 172 | ReportingCache::PersistentReportingStore* store) |
Matt Menke | 515136d | 2019-10-05 00:27:09 | [diff] [blame] | 173 | : ReportingContext(policy, |
| 174 | clock, |
| 175 | tick_clock, |
| 176 | TestReportingRandIntCallback(), |
| 177 | std::make_unique<TestReportingUploader>(), |
| 178 | std::make_unique<TestReportingDelegate>(), |
| 179 | store), |
tzik | 35945aa | 2018-06-22 00:33:26 | [diff] [blame] | 180 | delivery_timer_(new base::MockOneShotTimer()), |
| 181 | garbage_collection_timer_(new base::MockOneShotTimer()) { |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 182 | garbage_collector()->SetTimerForTesting( |
| 183 | base::WrapUnique(garbage_collection_timer_)); |
juliatuttle | 830962a | 2017-04-19 17:50:04 | [diff] [blame] | 184 | delivery_agent()->SetTimerForTesting(base::WrapUnique(delivery_timer_)); |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 185 | } |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 186 | |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 187 | TestReportingContext::~TestReportingContext() { |
juliatuttle | 830962a | 2017-04-19 17:50:04 | [diff] [blame] | 188 | delivery_timer_ = nullptr; |
juliatuttle | 9f970c0 | 2017-04-10 19:26:37 | [diff] [blame] | 189 | garbage_collection_timer_ = nullptr; |
| 190 | } |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 191 | |
Lily Chen | 731a95c | 2019-05-06 22:27:22 | [diff] [blame] | 192 | ReportingTestBase::ReportingTestBase() : store_(nullptr) { |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 193 | // For tests, disable jitter. |
| 194 | ReportingPolicy policy; |
| 195 | policy.endpoint_backoff_policy.jitter_factor = 0.0; |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 196 | |
juliatuttle | 42c5731 | 2017-04-28 03:01:30 | [diff] [blame] | 197 | CreateContext(policy, base::Time::Now(), base::TimeTicks::Now()); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 198 | } |
| 199 | |
Chris Watkins | 806691b | 2017-12-01 06:01:22 | [diff] [blame] | 200 | ReportingTestBase::~ReportingTestBase() = default; |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 201 | |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 202 | void ReportingTestBase::UsePolicy(const ReportingPolicy& new_policy) { |
juliatuttle | 42c5731 | 2017-04-28 03:01:30 | [diff] [blame] | 203 | CreateContext(new_policy, clock()->Now(), tick_clock()->NowTicks()); |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 204 | } |
| 205 | |
Lily Chen | 731a95c | 2019-05-06 22:27:22 | [diff] [blame] | 206 | void ReportingTestBase::UseStore( |
| 207 | ReportingCache::PersistentReportingStore* store) { |
| 208 | store_ = store; |
| 209 | CreateContext(policy(), clock()->Now(), tick_clock()->NowTicks()); |
| 210 | } |
| 211 | |
Lily Chen | fc92ff4 | 2019-05-06 22:59:10 | [diff] [blame] | 212 | const ReportingEndpoint ReportingTestBase::FindEndpointInCache( |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 213 | const ReportingEndpointGroupKey& group_key, |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 214 | const GURL& url) { |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 215 | return cache()->GetEndpointForTesting(group_key, url); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 216 | } |
| 217 | |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 218 | bool ReportingTestBase::SetEndpointInCache( |
| 219 | const ReportingEndpointGroupKey& group_key, |
| 220 | const GURL& url, |
| 221 | base::Time expires, |
| 222 | OriginSubdomains include_subdomains, |
| 223 | int priority, |
| 224 | int weight) { |
| 225 | cache()->SetEndpointForTesting(group_key, url, include_subdomains, expires, |
| 226 | priority, weight); |
| 227 | const ReportingEndpoint endpoint = FindEndpointInCache(group_key, url); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 228 | return endpoint.is_valid(); |
| 229 | } |
| 230 | |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 231 | bool ReportingTestBase::EndpointExistsInCache( |
| 232 | const ReportingEndpointGroupKey& group_key, |
| 233 | const GURL& url) { |
| 234 | ReportingEndpoint endpoint = cache()->GetEndpointForTesting(group_key, url); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 235 | return endpoint.is_valid(); |
| 236 | } |
| 237 | |
Lily Chen | fc92ff4 | 2019-05-06 22:59:10 | [diff] [blame] | 238 | ReportingEndpoint::Statistics ReportingTestBase::GetEndpointStatistics( |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 239 | const ReportingEndpointGroupKey& group_key, |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 240 | const GURL& url) { |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 241 | ReportingEndpoint endpoint = cache()->GetEndpointForTesting(group_key, url); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 242 | if (endpoint) |
| 243 | return endpoint.stats; |
Lily Chen | fc92ff4 | 2019-05-06 22:59:10 | [diff] [blame] | 244 | return ReportingEndpoint::Statistics(); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | bool ReportingTestBase::EndpointGroupExistsInCache( |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 248 | const ReportingEndpointGroupKey& group_key, |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 249 | OriginSubdomains include_subdomains, |
| 250 | base::Time expires) { |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 251 | return cache()->EndpointGroupExistsForTesting(group_key, include_subdomains, |
| 252 | expires); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 253 | } |
| 254 | |
Lily Chen | ad5dd080 | 2020-03-10 21:58:09 | [diff] [blame] | 255 | bool ReportingTestBase::ClientExistsInCacheForOrigin( |
| 256 | const url::Origin& origin) { |
| 257 | std::set<url::Origin> all_origins = cache()->GetAllOrigins(); |
| 258 | return all_origins.find(origin) != all_origins.end(); |
Lily Chen | efb6fcf | 2019-04-19 04:17:54 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | GURL ReportingTestBase::MakeURL(size_t index) { |
| 262 | return GURL(base::StringPrintf("https://example%zd.test", index)); |
| 263 | } |
| 264 | |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 265 | void ReportingTestBase::SimulateRestart(base::TimeDelta delta, |
| 266 | base::TimeDelta delta_ticks) { |
juliatuttle | 42c5731 | 2017-04-28 03:01:30 | [diff] [blame] | 267 | CreateContext(policy(), clock()->Now() + delta, |
| 268 | tick_clock()->NowTicks() + delta_ticks); |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 269 | } |
| 270 | |
juliatuttle | 42c5731 | 2017-04-28 03:01:30 | [diff] [blame] | 271 | void ReportingTestBase::CreateContext(const ReportingPolicy& policy, |
| 272 | base::Time now, |
| 273 | base::TimeTicks now_ticks) { |
Lily Chen | 731a95c | 2019-05-06 22:27:22 | [diff] [blame] | 274 | context_ = std::make_unique<TestReportingContext>(&clock_, &tick_clock_, |
| 275 | policy, store_); |
juliatuttle | 7da1381 | 2017-04-13 19:18:19 | [diff] [blame] | 276 | clock()->SetNow(now); |
| 277 | tick_clock()->SetNowTicks(now_ticks); |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | base::TimeTicks ReportingTestBase::yesterday() { |
| 281 | return tick_clock()->NowTicks() - base::TimeDelta::FromDays(1); |
| 282 | } |
| 283 | |
juliatuttle | 830962a | 2017-04-19 17:50:04 | [diff] [blame] | 284 | base::TimeTicks ReportingTestBase::now() { |
| 285 | return tick_clock()->NowTicks(); |
| 286 | } |
| 287 | |
juliatuttle | ee4b55e | 2017-04-07 17:09:45 | [diff] [blame] | 288 | base::TimeTicks ReportingTestBase::tomorrow() { |
| 289 | return tick_clock()->NowTicks() + base::TimeDelta::FromDays(1); |
| 290 | } |
| 291 | |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 292 | TestReportingService::Report::Report() = default; |
| 293 | |
| 294 | TestReportingService::Report::Report(Report&& other) |
| 295 | : url(other.url), |
| 296 | user_agent(other.user_agent), |
| 297 | group(other.group), |
| 298 | type(other.type), |
| 299 | body(std::move(other.body)), |
| 300 | depth(other.depth) {} |
| 301 | |
Matt Menke | dd2ed7a | 2020-10-22 04:09:20 | [diff] [blame] | 302 | TestReportingService::Report::Report( |
| 303 | const GURL& url, |
| 304 | const NetworkIsolationKey& network_isolation_key, |
| 305 | const std::string& user_agent, |
| 306 | const std::string& group, |
| 307 | const std::string& type, |
| 308 | std::unique_ptr<const base::Value> body, |
| 309 | int depth) |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 310 | : url(url), |
Matt Menke | dd2ed7a | 2020-10-22 04:09:20 | [diff] [blame] | 311 | network_isolation_key(network_isolation_key), |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 312 | user_agent(user_agent), |
| 313 | group(group), |
| 314 | type(type), |
| 315 | body(std::move(body)), |
| 316 | depth(depth) {} |
| 317 | |
| 318 | TestReportingService::Report::~Report() = default; |
| 319 | |
| 320 | TestReportingService::TestReportingService() = default; |
| 321 | |
| 322 | TestReportingService::~TestReportingService() = default; |
| 323 | |
Matt Menke | dd2ed7a | 2020-10-22 04:09:20 | [diff] [blame] | 324 | void TestReportingService::QueueReport( |
| 325 | const GURL& url, |
| 326 | const NetworkIsolationKey& network_isolation_key, |
| 327 | const std::string& user_agent, |
| 328 | const std::string& group, |
| 329 | const std::string& type, |
| 330 | std::unique_ptr<const base::Value> body, |
| 331 | int depth) { |
| 332 | reports_.emplace_back(Report(url, network_isolation_key, user_agent, group, |
| 333 | type, std::move(body), depth)); |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 334 | } |
| 335 | |
Matt Menke | 17b23c4 | 2020-10-22 05:14:57 | [diff] [blame] | 336 | void TestReportingService::ProcessHeader( |
| 337 | const GURL& url, |
| 338 | const NetworkIsolationKey& network_isolation_key, |
| 339 | const std::string& header_value) { |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 340 | NOTREACHED(); |
| 341 | } |
| 342 | |
| 343 | void TestReportingService::RemoveBrowsingData( |
Marcus Pasell | c3305c04 | 2020-06-03 22:14:36 | [diff] [blame] | 344 | uint64_t data_type_mask, |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 345 | const base::RepeatingCallback<bool(const GURL&)>& origin_filter) { |
| 346 | NOTREACHED(); |
| 347 | } |
| 348 | |
Marcus Pasell | c3305c04 | 2020-06-03 22:14:36 | [diff] [blame] | 349 | void TestReportingService::RemoveAllBrowsingData(uint64_t data_type_mask) { |
Lily Chen | 8a9e5372 | 2019-04-26 15:16:02 | [diff] [blame] | 350 | NOTREACHED(); |
| 351 | } |
| 352 | |
| 353 | void TestReportingService::OnShutdown() {} |
| 354 | |
| 355 | const ReportingPolicy& TestReportingService::GetPolicy() const { |
| 356 | NOTREACHED(); |
| 357 | return dummy_policy_; |
| 358 | } |
| 359 | |
| 360 | ReportingContext* TestReportingService::GetContextForTesting() const { |
| 361 | NOTREACHED(); |
| 362 | return nullptr; |
| 363 | } |
| 364 | |
juliatuttle | 58684333 | 2017-03-27 16:22:37 | [diff] [blame] | 365 | } // namespace net |