Commit e5df6cff authored by Paul Meyer's avatar Paul Meyer Committed by Commit Bot

Route |id| and |anticipatedRemoval| fields in deprecation reports to

Reporting API.

A previous patch
(https://chromium-review.googlesource.com/c/chromium/src/+/772999) added
these new fields. This patch routes them to the Reporting API, and
updates the associated test.

Bug: 731810
Change-Id: I3a9a3ac71d894f784f18d5fb51898184541e6216
Reviewed-on: https://chromium-review.googlesource.com/775154
Commit-Queue: Paul Meyer <paulmeyer@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarRick Byers <rbyers@chromium.org>
Reviewed-by: default avatarJulia Tuttle <juliatuttle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521546}
parent bfc2241d
...@@ -47,11 +47,16 @@ class ReportingServiceProxyImpl : public blink::mojom::ReportingServiceProxy { ...@@ -47,11 +47,16 @@ class ReportingServiceProxyImpl : public blink::mojom::ReportingServiceProxy {
} }
void QueueDeprecationReport(const GURL& url, void QueueDeprecationReport(const GURL& url,
const std::string& id,
base::Time anticipatedRemoval,
const std::string& message, const std::string& message,
const std::string& source_file, const std::string& source_file,
int line_number, int line_number,
int column_number) override { int column_number) override {
auto body = std::make_unique<base::DictionaryValue>(); auto body = std::make_unique<base::DictionaryValue>();
body->SetString("id", id);
if (anticipatedRemoval.is_null())
body->SetDouble("anticipatedRemoval", anticipatedRemoval.ToDoubleT());
body->SetString("message", message); body->SetString("message", message);
body->SetString("sourceFile", source_file); body->SetString("sourceFile", source_file);
body->SetInteger("lineNumber", line_number); body->SetInteger("lineNumber", line_number);
......
...@@ -29,8 +29,8 @@ class MockReportingServiceProxy { ...@@ -29,8 +29,8 @@ class MockReportingServiceProxy {
} }
// Interface implementation. // Interface implementation.
async queueDeprecationReport(url, message, sourceFile, lineNumber, columnNumber) { async queueDeprecationReport(url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber) {
this.resolve([url, message, sourceFile, lineNumber, columnNumber]); this.resolve([url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber]);
this.resetPromise(); this.resetPromise();
} }
...@@ -54,8 +54,10 @@ promise_test(async () => { ...@@ -54,8 +54,10 @@ promise_test(async () => {
// Ensure the deprecation report is generated and routed to the reporting mojo // Ensure the deprecation report is generated and routed to the reporting mojo
// interface. // interface.
let [url, message, sourceFile, lineNumber, columnNumber] = await promise; let [url, id, anticipatedRemoval, message, sourceFile, lineNumber, columnNumber] = await promise;
assert_true(url.url.endsWith("reporting-observer/reporting-api.html")); assert_true(url.url.endsWith("reporting-observer/reporting-api.html"));
assert_equals(typeof id, "string");
assert_equals(typeof anticipatedRemoval, "object");
assert_equals(typeof message, "string"); assert_equals(typeof message, "string");
assert_true(sourceFile.endsWith("reporting-observer/reporting-api.html")); assert_true(sourceFile.endsWith("reporting-observer/reporting-api.html"));
assert_equals(typeof lineNumber, "number"); assert_equals(typeof lineNumber, "number");
......
...@@ -783,9 +783,9 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) { ...@@ -783,9 +783,9 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) {
Document* document = frame->GetDocument(); Document* document = frame->GetDocument();
// Construct the deprecation report. // Construct the deprecation report.
DeprecationReport* body = double removalDate = milestoneDate(info.anticipatedRemoval);
new DeprecationReport(info.id, milestoneDate(info.anticipatedRemoval), DeprecationReport* body = new DeprecationReport(
info.message, SourceLocation::Capture()); info.id, removalDate, info.message, SourceLocation::Capture());
Report* report = new Report("deprecation", document->Url().GetString(), body); Report* report = new Report("deprecation", document->Url().GetString(), body);
// Send the deprecation report to any ReportingObservers. // Send the deprecation report to any ReportingObservers.
...@@ -796,9 +796,10 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) { ...@@ -796,9 +796,10 @@ void Deprecation::GenerateReport(const LocalFrame* frame, WebFeature feature) {
// Send the deprecation report to the Reporting API. // Send the deprecation report to the Reporting API.
mojom::blink::ReportingServiceProxyPtr service; mojom::blink::ReportingServiceProxyPtr service;
frame->Client()->GetInterfaceProvider()->GetInterface(&service); frame->Client()->GetInterfaceProvider()->GetInterface(&service);
service->QueueDeprecationReport(document->Url(), info.message, service->QueueDeprecationReport(document->Url(), info.id,
body->sourceFile(), body->lineNumber(), WTF::Time::FromDoubleT(removalDate),
body->columnNumber()); info.message, body->sourceFile(),
body->lineNumber(), body->columnNumber());
} }
// static // static
......
...@@ -21,26 +21,28 @@ class ReportingServiceProxyPtrHolder { ...@@ -21,26 +21,28 @@ class ReportingServiceProxyPtrHolder {
~ReportingServiceProxyPtrHolder() {} ~ReportingServiceProxyPtrHolder() {}
void QueueInterventionReport(const KURL& url, void QueueInterventionReport(const KURL& url,
const String& body, const String& message,
const String& source_file, const String& source_file,
int line_number, int line_number,
int column_number) { int column_number) {
if (reporting_service_proxy) { if (reporting_service_proxy) {
reporting_service_proxy->QueueInterventionReport( reporting_service_proxy->QueueInterventionReport(
url, body ? body : "", source_file ? source_file : "", line_number, url, message ? message : "", source_file ? source_file : "",
column_number); line_number, column_number);
} }
} }
void QueueDeprecationReport(const KURL& url, void QueueDeprecationReport(const KURL& url,
const String& body, const String& id,
WTF::Time anticipatedRemoval,
const String& message,
const String& source_file, const String& source_file,
int line_number, int line_number,
int column_number) { int column_number) {
if (reporting_service_proxy) { if (reporting_service_proxy) {
reporting_service_proxy->QueueDeprecationReport( reporting_service_proxy->QueueDeprecationReport(
url, body ? body : "", source_file ? source_file : "", line_number, url, id, anticipatedRemoval, message ? message : "",
column_number); source_file ? source_file : "", line_number, column_number);
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
module blink.mojom; module blink.mojom;
import "mojo/common/time.mojom";
import "url/mojo/url.mojom"; import "url/mojo/url.mojom";
interface ReportingServiceProxy { interface ReportingServiceProxy {
...@@ -20,12 +21,14 @@ interface ReportingServiceProxy { ...@@ -20,12 +21,14 @@ interface ReportingServiceProxy {
// //
// (See //third_party/WebKit/Source/core/frame/DeprecationReport.h.) // (See //third_party/WebKit/Source/core/frame/DeprecationReport.h.)
QueueDeprecationReport(url.mojom.Url url, QueueDeprecationReport(url.mojom.Url url,
string id,
mojo.common.mojom.Time anticipatedRemoval,
string message, string message,
string source_file, string source_file,
int32 line_number, int32 line_number,
int32 column_number); int32 column_number);
// Attempts to queue a Deprecation report using the Reporting API. // Attempts to queue a CSP Violation report using the Reporting API.
// //
// (See //third_party/WebKit/Source/core/events/SecurityPolicyViolationEvent.h.) // (See //third_party/WebKit/Source/core/events/SecurityPolicyViolationEvent.h.)
QueueCspViolationReport(url.mojom.Url url, QueueCspViolationReport(url.mojom.Url url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment