Files
cromite/build/patches/Allow-building-without-enable_reporting.patch
T
2021-10-08 01:17:15 +02:00

210 lines
8.5 KiB
Diff

From: Zoraver Kang <Zoraver@users.noreply.github.com>
Date: Fri, 22 May 2020 22:43:27 -0400
Subject: Allow building without enable_reporting
---
content/browser/BUILD.gn | 8 ++++----
third_party/blink/renderer/core/frame/local_frame.cc | 5 +++++
third_party/blink/renderer/core/frame/local_frame.h | 7 +++++--
.../blink/renderer/core/frame/reporting_context.cc | 9 +++++++++
.../blink/renderer/core/frame/reporting_context.h | 7 +++++--
5 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -1227,6 +1227,10 @@ source_set("browser") {
"net/browser_online_state_observer.cc",
"net/browser_online_state_observer.h",
"net/cookie_store_factory.cc",
+ "net/cross_origin_embedder_policy_reporter.cc",
+ "net/cross_origin_embedder_policy_reporter.h",
+ "net/cross_origin_opener_policy_reporter.cc",
+ "net/cross_origin_opener_policy_reporter.h",
"net/network_errors_listing_ui.cc",
"net/network_errors_listing_ui.h",
"net/network_quality_observer_impl.cc",
@@ -2966,10 +2970,6 @@ source_set("browser") {
if (enable_reporting) {
sources += [
- "net/cross_origin_embedder_policy_reporter.cc",
- "net/cross_origin_embedder_policy_reporter.h",
- "net/cross_origin_opener_policy_reporter.cc",
- "net/cross_origin_opener_policy_reporter.h",
"net/reporting_service_proxy.cc",
"net/reporting_service_proxy.h",
]
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc
--- a/third_party/blink/renderer/core/frame/local_frame.cc
+++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -39,6 +39,7 @@
#include "base/values.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"
+#include "net/net_buildflags.h"
#include "services/data_decoder/public/mojom/resource_snapshot_for_web_bundle.mojom-blink.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/content_security_policy.mojom-blink.h"
@@ -423,7 +424,9 @@ void LocalFrame::Trace(Visitor* visitor) const {
visitor->Trace(raw_system_clipboard_);
visitor->Trace(virtual_keyboard_overlay_changed_observers_);
visitor->Trace(pause_handle_receivers_);
+#if BUILDFLAG(ENABLE_REPORTING)
visitor->Trace(reporting_service_);
+#endif
#if defined(OS_MAC)
visitor->Trace(text_input_host_);
#endif
@@ -2308,6 +2311,7 @@ const base::UnguessableToken& LocalFrame::GetAgentClusterId() const {
return base::UnguessableToken::Null();
}
+#if BUILDFLAG(ENABLE_REPORTING)
mojom::blink::ReportingServiceProxy* LocalFrame::GetReportingService() {
if (!reporting_service_.is_bound()) {
GetBrowserInterfaceBroker().GetInterface(
@@ -2316,6 +2320,7 @@ mojom::blink::ReportingServiceProxy* LocalFrame::GetReportingService() {
}
return reporting_service_.get();
}
+#endif
// static
void LocalFrame::NotifyUserActivation(
diff --git a/third_party/blink/renderer/core/frame/local_frame.h b/third_party/blink/renderer/core/frame/local_frame.h
--- a/third_party/blink/renderer/core/frame/local_frame.h
+++ b/third_party/blink/renderer/core/frame/local_frame.h
@@ -36,6 +36,7 @@
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "net/net_buildflags.h"
#include "services/network/public/mojom/fetch_api.mojom-blink-forward.h"
#include "third_party/blink/public/common/frame/frame_ad_evidence.h"
#include "third_party/blink/public/common/frame/payment_request_token.h"
@@ -545,9 +546,9 @@ class CORE_EXPORT LocalFrame final : public Frame,
}
SmoothScrollSequencer& GetSmoothScrollSequencer();
-
+#if BUILDFLAG(ENABLE_REPORTING)
mojom::blink::ReportingServiceProxy* GetReportingService();
-
+#endif
// Returns the frame host ptr. The interface returned is backed by an
// associated interface with the legacy Chrome IPC channel.
mojom::blink::LocalFrameHost& GetLocalFrameHostRemote() const;
@@ -875,8 +876,10 @@ class CORE_EXPORT LocalFrame final : public Frame,
// const methods.
//
// LocalFrame can be reused by multiple ExecutionContext.
+#if BUILDFLAG(ENABLE_REPORTING)
mutable HeapMojoRemote<mojom::blink::ReportingServiceProxy>
reporting_service_{nullptr};
+#endif
#if defined(OS_MAC)
// LocalFrame can be reused by multiple ExecutionContext.
diff --git a/third_party/blink/renderer/core/frame/reporting_context.cc b/third_party/blink/renderer/core/frame/reporting_context.cc
--- a/third_party/blink/renderer/core/frame/reporting_context.cc
+++ b/third_party/blink/renderer/core/frame/reporting_context.cc
@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/frame/reporting_context.h"
+#include "net/net_buildflags.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
@@ -54,7 +55,9 @@ const char ReportingContext::kSupplementName[] = "ReportingContext";
ReportingContext::ReportingContext(ExecutionContext& context)
: Supplement<ExecutionContext>(context),
execution_context_(context),
+#if BUILDFLAG(ENABLE_REPORTING)
reporting_service_(&context),
+#endif
receiver_(this, &context) {}
// static
@@ -118,7 +121,9 @@ void ReportingContext::Trace(Visitor* visitor) const {
visitor->Trace(observers_);
visitor->Trace(report_buffer_);
visitor->Trace(execution_context_);
+#if BUILDFLAG(ENABLE_REPORTING)
visitor->Trace(reporting_service_);
+#endif
visitor->Trace(receiver_);
Supplement<ExecutionContext>::Trace(visitor);
}
@@ -140,6 +145,7 @@ void ReportingContext::CountReport(Report* report) {
UseCounter::Count(execution_context_, feature);
}
+#if BUILDFLAG(ENABLE_REPORTING)
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
ReportingContext::GetReportingService() const {
if (!reporting_service_.is_bound()) {
@@ -149,6 +155,7 @@ ReportingContext::GetReportingService() const {
}
return reporting_service_;
}
+#endif
void ReportingContext::NotifyInternal(Report* report) {
// Buffer the report.
@@ -171,6 +178,7 @@ void ReportingContext::NotifyInternal(Report* report) {
void ReportingContext::SendToReportingAPI(Report* report,
const String& endpoint) const {
+#if BUILDFLAG(ENABLE_REPORTING)
const String& type = report->type();
if (!(type == ReportType::kCSPViolation || type == ReportType::kDeprecation ||
type == ReportType::kPermissionsPolicyViolation ||
@@ -226,6 +234,7 @@ void ReportingContext::SendToReportingAPI(Report* report,
url, endpoint, body->featureId(), body->disposition(), body->message(),
body->sourceFile(), line_number, column_number);
}
+#endif
}
} // namespace blink
diff --git a/third_party/blink/renderer/core/frame/reporting_context.h b/third_party/blink/renderer/core/frame/reporting_context.h
--- a/third_party/blink/renderer/core/frame/reporting_context.h
+++ b/third_party/blink/renderer/core/frame/reporting_context.h
@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REPORTING_CONTEXT_H_
+#include "net/net_buildflags.h"
#include "third_party/blink/public/mojom/frame/reporting_observer.mojom-blink.h"
#include "third_party/blink/public/mojom/reporting/reporting.mojom-blink.h"
#include "third_party/blink/renderer/core/core_export.h"
@@ -53,10 +54,10 @@ class CORE_EXPORT ReportingContext : public GarbageCollected<ReportingContext>,
private:
// Counts the use of a report type via UseCounter.
void CountReport(Report*);
-
+#if BUILDFLAG(ENABLE_REPORTING)
const HeapMojoRemote<mojom::blink::ReportingServiceProxy>&
GetReportingService() const;
-
+#endif
void NotifyInternal(Report* report);
// Send |report| via the Reporting API to |endpoint|.
void SendToReportingAPI(Report* report, const String& endpoint) const;
@@ -67,8 +68,10 @@ class CORE_EXPORT ReportingContext : public GarbageCollected<ReportingContext>,
// This is declared mutable so that the service endpoint can be cached by
// const methods.
+#if BUILDFLAG(ENABLE_REPORTING)
mutable HeapMojoRemote<mojom::blink::ReportingServiceProxy>
reporting_service_;
+#endif
HeapMojoReceiver<mojom::blink::ReportingObserver, ReportingContext> receiver_;
};
--
2.17.1