Skip to content

Commit

Permalink
[code-health] Remove DeprecatedDictionaryValue in ReportingApiReport
Browse files Browse the repository at this point in the history
Bug: 1187061
Change-Id: Ieea4ab2bf7e9de6c7a048d86a19440852d1baf37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3896775
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Commit-Queue: Fabrice de Gans <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048085}
  • Loading branch information
Steelskin authored and Chromium LUCI CQ committed Sep 16, 2022
1 parent cd23b8b commit 9c6d779
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 28 deletions.
3 changes: 1 addition & 2 deletions content/browser/devtools/protocol/network_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,7 @@ NetworkHandler::BuildProtocolReport(const net::ReportingReport& report) {
(report.queued - base::TimeTicks::UnixEpoch()).InSecondsF())
.SetDepth(report.depth)
.SetCompletedAttempts(report.attempts)
.SetBody(
std::make_unique<base::Value::Dict>(report.body->GetDict().Clone()))
.SetBody(std::make_unique<base::Value::Dict>(report.body.Clone()))
.SetStatus(BuildReportStatus(report.status))
.Build();
}
Expand Down
7 changes: 2 additions & 5 deletions net/reporting/reporting_cache_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ void ReportingCacheImpl::AddReport(

auto report = std::make_unique<ReportingReport>(
reporting_source, network_isolation_key, url, user_agent, group_name,
type, std::make_unique<base::Value>(std::move(body)), depth, queued,
attempts);
type, std::move(body), depth, queued, attempts);

auto inserted = reports_.insert(std::move(report));
DCHECK(inserted.second);
Expand Down Expand Up @@ -111,9 +110,7 @@ base::Value ReportingCacheImpl::GetReportsAsValue() const {
report_dict.Set("depth", report->depth);
report_dict.Set("queued", NetLog::TickCountToString(report->queued));
report_dict.Set("attempts", report->attempts);
if (report->body) {
report_dict.Set("body", report->body->Clone());
}
report_dict.Set("body", report->body.Clone());
switch (report->status) {
case ReportingReport::Status::DOOMED:
report_dict.Set("status", "doomed");
Expand Down
4 changes: 2 additions & 2 deletions net/reporting/reporting_cache_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ReportingCacheTest : public ReportingTestBase,
int depth,
base::TimeTicks queued,
int attempts) {
const base::Value body_clone(body.Clone());
const base::Value::Dict body_clone(body.Clone());

// The public API will only give us the (unordered) full list of reports in
// the cache. So we need to grab the list before we add, and the list after
Expand All @@ -135,7 +135,7 @@ class ReportingCacheTest : public ReportingTestBase,
EXPECT_EQ(user_agent, report->user_agent);
EXPECT_EQ(group, report->group);
EXPECT_EQ(type, report->type);
EXPECT_EQ(body_clone, *report->body);
EXPECT_EQ(body_clone, report->body);
EXPECT_EQ(depth, report->depth);
EXPECT_EQ(queued, report->queued);
EXPECT_EQ(attempts, report->attempts);
Expand Down
2 changes: 1 addition & 1 deletion net/reporting/reporting_delivery_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ std::string SerializeReports(const ReportList& reports, base::TimeTicks now) {
report_value.Set("type", report->type);
report_value.Set("url", report->url.spec());
report_value.Set("user_agent", report->user_agent);
report_value.Set("body", report->body->Clone());
report_value.Set("body", report->body.Clone());

reports_value.Append(std::move(report_value));
}
Expand Down
2 changes: 1 addition & 1 deletion net/reporting/reporting_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ReportingReport::ReportingReport(
const std::string& user_agent,
const std::string& group,
const std::string& type,
std::unique_ptr<const base::Value> body,
base::Value::Dict body,
int depth,
base::TimeTicks queued,
int attempts)
Expand Down
9 changes: 3 additions & 6 deletions net/reporting/reporting_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@

#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "base/values.h"
#include "net/base/net_export.h"
#include "net/base/network_isolation_key.h"
#include "net/reporting/reporting_endpoint.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"

namespace base {
class Value;
} // namespace base

namespace net {

// An undelivered report.
Expand Down Expand Up @@ -50,7 +47,7 @@ struct NET_EXPORT ReportingReport {
const std::string& user_agent,
const std::string& group,
const std::string& type,
std::unique_ptr<const base::Value> body,
base::Value::Dict body,
int depth,
base::TimeTicks queued,
int attempts);
Expand Down Expand Up @@ -110,7 +107,7 @@ struct NET_EXPORT ReportingReport {
std::string type;

// The body of the report. (Included in the delivered report.)
std::unique_ptr<const base::Value> body;
base::Value::Dict body;

// How many uploads deep the related request was: 0 if the related request was
// not an upload (or there was no related request), or n+1 if it was an upload
Expand Down
10 changes: 2 additions & 8 deletions services/network/public/cpp/reporting_api_report_mojom_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ bool StructTraits<
if (!data.ReadStatus(&out->status))
return false;

base::Value body;
if (!data.ReadBody(&body)) {
return false;
}
out->body = base::Value::ToUniquePtrValue(std::move(body));

return true;
return data.ReadBody(&out->body);
}

} // namespace mojo
} // namespace mojo
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct StructTraits<network::mojom::ReportingApiReportDataView,
return report.attempts;
}

static const base::Value& body(const net::ReportingReport& report) {
return *report.body;
static const base::Value::Dict& body(const net::ReportingReport& report) {
return report.body;
}

static net::ReportingReport::Status status(
Expand Down
2 changes: 1 addition & 1 deletion services/network/public/mojom/reporting_service.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ReportingApiReport {
// attempt.
int32 attempts;
// The body of the report.
mojo_base.mojom.DeprecatedDictionaryValue body;
mojo_base.mojom.DictionaryValue body;
// The status of the report.
ReportingApiReportStatus status;
};
Expand Down

0 comments on commit 9c6d779

Please sign in to comment.