Commit 8b307053 authored by Tal Pressman's avatar Tal Pressman Committed by Commit Bot

Migrate blink::ReportingContext to use blink::HeapMojoRemote instead of mojo::Remote.

Bug: 1049056
Change-Id: Iee30a69b0cba2b2fd5bf6ff8a67e0c5bbbfddf4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071436Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Tal Pressman <talp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744191}
parent 1ebca694
......@@ -6,6 +6,7 @@
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/csp/csp_violation_report_body.h"
......@@ -25,7 +26,9 @@ namespace blink {
const char ReportingContext::kSupplementName[] = "ReportingContext";
ReportingContext::ReportingContext(ExecutionContext& context)
: Supplement<ExecutionContext>(context), execution_context_(context) {}
: Supplement<ExecutionContext>(context),
execution_context_(context),
reporting_service_(&context) {}
// static
ReportingContext* ReportingContext::From(ExecutionContext* context) {
......@@ -84,6 +87,7 @@ void ReportingContext::Trace(Visitor* visitor) {
visitor->Trace(observers_);
visitor->Trace(report_buffer_);
visitor->Trace(execution_context_);
visitor->Trace(reporting_service_);
Supplement<ExecutionContext>::Trace(visitor);
}
......@@ -104,11 +108,12 @@ void ReportingContext::CountReport(Report* report) {
UseCounter::Count(execution_context_, feature);
}
const mojo::Remote<mojom::blink::ReportingServiceProxy>&
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
ReportingContext::GetReportingService() const {
if (!reporting_service_) {
if (!reporting_service_.is_bound()) {
Platform::Current()->GetBrowserInterfaceBroker()->GetInterface(
reporting_service_.BindNewPipeAndPassReceiver());
reporting_service_.BindNewPipeAndPassReceiver(
execution_context_->GetTaskRunner(TaskType::kMiscPlatformAPI)));
}
return reporting_service_;
}
......@@ -138,19 +143,13 @@ void ReportingContext::SendToReportingAPI(Report* report,
const CSPViolationReportBody* body =
static_cast<CSPViolationReportBody*>(report->body());
GetReportingService()->QueueCspViolationReport(
url,
endpoint,
body->documentURL() ? body->documentURL() : "",
body->referrer(),
body->blockedURL(),
url, endpoint, body->documentURL() ? body->documentURL() : "",
body->referrer(), body->blockedURL(),
body->effectiveDirective() ? body->effectiveDirective() : "",
body->originalPolicy() ? body->originalPolicy() : "",
body->sourceFile(),
body->sample(),
body->disposition() ? body->disposition() : "",
body->statusCode(),
line_number,
column_number);
body->sourceFile(), body->sample(),
body->disposition() ? body->disposition() : "", body->statusCode(),
line_number, column_number);
} else if (type == ReportType::kDeprecation) {
// Send the deprecation report.
const DeprecationReportBody* body =
......
......@@ -5,10 +5,10 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/reporting/reporting.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
......@@ -49,8 +49,8 @@ class CORE_EXPORT ReportingContext final
// Counts the use of a report type via UseCounter.
void CountReport(Report*);
const mojo::Remote<mojom::blink::ReportingServiceProxy>& GetReportingService()
const;
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
GetReportingService() const;
// Send |report| via the Reporting API to |endpoint|.
void SendToReportingAPI(Report* report, const String& endpoint) const;
......@@ -61,7 +61,8 @@ class CORE_EXPORT ReportingContext final
// This is declared mutable so that the service endpoint can be cached by
// const methods.
mutable mojo::Remote<mojom::blink::ReportingServiceProxy> reporting_service_;
mutable HeapMojoRemote<mojom::blink::ReportingServiceProxy>
reporting_service_;
};
} // namespace blink
......
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