| OLD | NEW | 
|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "net/reporting/reporting_delivery_agent.h" | 5 #include "net/reporting/reporting_delivery_agent.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" | 
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 171 | 171 | 
| 172   // Remove the report while the upload is running. | 172   // Remove the report while the upload is running. | 
| 173   std::vector<const ReportingReport*> reports; | 173   std::vector<const ReportingReport*> reports; | 
| 174   cache()->GetReports(&reports); | 174   cache()->GetReports(&reports); | 
| 175   EXPECT_EQ(1u, reports.size()); | 175   EXPECT_EQ(1u, reports.size()); | 
| 176 | 176 | 
| 177   const ReportingReport* report = reports[0]; | 177   const ReportingReport* report = reports[0]; | 
| 178   EXPECT_FALSE(cache()->IsReportDoomedForTesting(report)); | 178   EXPECT_FALSE(cache()->IsReportDoomedForTesting(report)); | 
| 179 | 179 | 
| 180   // Report should appear removed, even though the cache has doomed it. | 180   // Report should appear removed, even though the cache has doomed it. | 
| 181   cache()->RemoveReports(reports); | 181   cache()->RemoveReports(reports, ReportingReport::Outcome::UNKNOWN); | 
| 182   cache()->GetReports(&reports); | 182   cache()->GetReports(&reports); | 
| 183   EXPECT_TRUE(reports.empty()); | 183   EXPECT_TRUE(reports.empty()); | 
| 184   EXPECT_TRUE(cache()->IsReportDoomedForTesting(report)); | 184   EXPECT_TRUE(cache()->IsReportDoomedForTesting(report)); | 
| 185 | 185 | 
| 186   // Completing upload shouldn't crash, and report should still be gone. | 186   // Completing upload shouldn't crash, and report should still be gone. | 
| 187   pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS); | 187   pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS); | 
| 188   cache()->GetReports(&reports); | 188   cache()->GetReports(&reports); | 
| 189   EXPECT_TRUE(reports.empty()); | 189   EXPECT_TRUE(reports.empty()); | 
| 190   // This is slightly sketchy since |report| has been freed, but it nonetheless | 190   // This is slightly sketchy since |report| has been freed, but it nonetheless | 
| 191   // should not be in the set of doomed reports. | 191   // should not be in the set of doomed reports. | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 319   delivery_timer()->Fire(); | 319   delivery_timer()->Fire(); | 
| 320   ASSERT_EQ(2u, pending_uploads().size()); | 320   ASSERT_EQ(2u, pending_uploads().size()); | 
| 321 | 321 | 
| 322   pending_uploads()[1]->Complete(ReportingUploader::Outcome::SUCCESS); | 322   pending_uploads()[1]->Complete(ReportingUploader::Outcome::SUCCESS); | 
| 323   pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS); | 323   pending_uploads()[0]->Complete(ReportingUploader::Outcome::SUCCESS); | 
| 324   EXPECT_EQ(0u, pending_uploads().size()); | 324   EXPECT_EQ(0u, pending_uploads().size()); | 
| 325 } | 325 } | 
| 326 | 326 | 
| 327 }  // namespace | 327 }  // namespace | 
| 328 }  // namespace net | 328 }  // namespace net | 
| OLD | NEW | 
|---|