Commit 6e161040 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

RC: Remove unnecessary dependencies on resource_coordinator_cpp.

Apart from the code in resource_coordinator_features.cc/.h and
the code in the memory_instrumentation/ sub-directory, the code
in services/resource_coordinator/public/cpp is never used from
child processes.

This CL splits the resource_coordinator_cpp component into
3 separate components (resource_coordinator_cpp,
resource_coordinator_features and memory_instrumentation) so that
code that runs in child processes doesn't have to depend on all of
services/resource_coordinator/public/cpp/ (this is important to
avoid security concerns as we add functionality to
services/resource_coordinator/public/cpp/).

TBR=clamy@chromium.org

Change-Id: Ic2045164621d99b11d218d1a01c5ce160a4dc855
Reviewed-on: https://chromium-review.googlesource.com/c/1250006
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597121}
parent cb4b9ea7
......@@ -110,7 +110,7 @@ target(link_target_type, "child") {
"//services/device/public/cpp:device_features",
"//services/device/public/cpp/power_monitor",
"//services/device/public/mojom:constants",
"//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
"//services/resource_coordinator/public/cpp/memory_instrumentation",
"//services/service_manager/public/cpp",
"//services/service_manager/public/mojom",
"//services/service_manager/runner/common",
......
......@@ -328,7 +328,7 @@ source_set("common") {
"//sandbox:sandbox_buildflags",
"//services/network/public/cpp",
"//services/network/public/mojom",
"//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
"//services/resource_coordinator/public/cpp/memory_instrumentation",
"//services/service_manager",
"//services/service_manager/embedder",
"//services/service_manager/public/cpp",
......
......@@ -9,7 +9,7 @@ component("resource_coordinator_cpp_base") {
"coordination_unit_types.h",
]
defines = [ "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION" ]
defines = [ "IS_SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPL" ]
deps = [
"//base",
......@@ -17,56 +17,40 @@ component("resource_coordinator_cpp_base") {
]
}
component("resource_coordinator_cpp_features") {
sources = [
"resource_coordinator_features.cc",
"resource_coordinator_features.h",
]
defines = [ "IS_SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES_IMPL" ]
deps = [
"//base",
]
}
component("resource_coordinator_cpp") {
sources = [
"frame_resource_coordinator.cc",
"frame_resource_coordinator.h",
"memory_instrumentation/client_process_impl.cc",
"memory_instrumentation/client_process_impl.h",
"memory_instrumentation/coordinator.h",
"memory_instrumentation/global_memory_dump.cc",
"memory_instrumentation/global_memory_dump.h",
"memory_instrumentation/memory_instrumentation.cc",
"memory_instrumentation/memory_instrumentation.h",
"memory_instrumentation/os_metrics.cc",
"memory_instrumentation/os_metrics.h",
"memory_instrumentation/os_metrics_linux.cc",
"memory_instrumentation/os_metrics_mac.cc",
"memory_instrumentation/os_metrics_win.cc",
"memory_instrumentation/tracing_observer.cc",
"memory_instrumentation/tracing_observer.h",
"page_resource_coordinator.cc",
"page_resource_coordinator.h",
"process_resource_coordinator.cc",
"process_resource_coordinator.h",
"resource_coordinator_features.cc",
"resource_coordinator_features.h",
"resource_coordinator_interface.h",
"system_resource_coordinator.cc",
"system_resource_coordinator.h",
]
if (is_android) {
set_sources_assignment_filter([])
sources += [ "memory_instrumentation/os_metrics_linux.cc" ]
set_sources_assignment_filter(sources_assignment_filter)
}
if (is_fuchsia) {
sources += [ "memory_instrumentation/os_metrics_fuchsia.cc" ]
}
defines = [ "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION" ]
deps = []
if (is_win) {
deps += [ "//base/win:pe_image" ]
}
defines = [ "IS_SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPL" ]
public_deps = [
":resource_coordinator_cpp_base",
":resource_coordinator_cpp_features",
"//base",
"//mojo/public/cpp/bindings",
"//services/resource_coordinator/public/cpp/memory_instrumentation",
"//services/resource_coordinator/public/mojom",
"//services/service_manager/public/cpp",
]
......
......@@ -7,8 +7,8 @@
#include <string>
#include <tuple>
#include "base/component_export.h"
#include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_base_export.h"
namespace resource_coordinator {
......@@ -17,7 +17,8 @@ namespace resource_coordinator {
// would like to move it to base/ as easily as possible at that point.
// TODO(oysteine): Rename to CoordinationUnitGUID to better differentiate the
// class from the internal id
struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT CoordinationUnitID {
struct COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE)
CoordinationUnitID {
typedef uint64_t CoordinationUnitTypeId;
enum RandomID { RANDOM_ID };
......
......@@ -12,7 +12,8 @@
namespace resource_coordinator {
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT FrameResourceCoordinator
class COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP)
FrameResourceCoordinator
: public ResourceCoordinatorInterface<mojom::FrameCoordinationUnitPtr,
mojom::FrameCoordinationUnitRequest> {
public:
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
component("memory_instrumentation") {
sources = [
"client_process_impl.cc",
"client_process_impl.h",
"coordinator.h",
"global_memory_dump.cc",
"global_memory_dump.h",
"memory_instrumentation.cc",
"memory_instrumentation.h",
"os_metrics.cc",
"os_metrics.h",
"os_metrics_linux.cc",
"os_metrics_mac.cc",
"os_metrics_win.cc",
"tracing_observer.cc",
"tracing_observer.h",
]
if (is_android) {
# Disable the rule that excludes _linux.cc files from Android builds.
set_sources_assignment_filter([])
sources += [ "os_metrics_linux.cc" ]
set_sources_assignment_filter(sources_assignment_filter)
}
if (is_fuchsia) {
sources += [ "os_metrics_fuchsia.cc" ]
}
defines = [ "IS_RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION_IMPL" ]
deps = []
if (is_win) {
deps += [ "//base/win:pe_image" ]
}
public_deps = [
"//base",
"//mojo/public/cpp/bindings",
"//services/resource_coordinator/public/mojom",
"//services/service_manager/public/cpp",
]
}
......@@ -6,13 +6,13 @@
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_CLIENT_PROCESS_IMPL_H_
#include "base/compiler_specific.h"
#include "base/component_export.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/coordinator.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -28,10 +28,11 @@ class TracingObserver;
// no Coordinator service in child processes. So, in a child process, the
// local dump manager remotely connects to the Coordinator service. In the
// browser process, it locally connects to the Coordinator service.
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT ClientProcessImpl
: public mojom::ClientProcess {
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
ClientProcessImpl : public mojom::ClientProcess {
public:
struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT Config {
struct COMPONENT_EXPORT(
RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION) Config {
public:
Config(service_manager::Connector* connector,
const std::string& service_name,
......
......@@ -5,17 +5,19 @@
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_GLOBAL_MEMORY_DUMP_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_GLOBAL_MEMORY_DUMP_H_
#include "base/component_export.h"
#include "base/optional.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
namespace memory_instrumentation {
// The returned data structure to consumers of the memory_instrumentation
// service containing dumps for each process.
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT GlobalMemoryDump {
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
GlobalMemoryDump {
public:
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT ProcessDump {
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
ProcessDump {
public:
ProcessDump(mojom::ProcessMemoryDumpPtr process_memory_dump);
~ProcessDump();
......
......@@ -6,12 +6,12 @@
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_MEMORY_INSTRUMENTATION_H_
#include "base/callback_forward.h"
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread_local_storage.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/coordinator.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
......@@ -26,7 +26,8 @@ namespace memory_instrumentation {
// memory_instrumentation service and hides away the complexity associated with
// having to deal with it (e.g., maintaining service connections, bindings,
// handling timeouts).
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT MemoryInstrumentation {
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
MemoryInstrumentation {
public:
using MemoryDumpType = base::trace_event::MemoryDumpType;
using MemoryDumpLevelOfDetail = base::trace_event::MemoryDumpLevelOfDetail;
......
......@@ -4,11 +4,11 @@
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_OS_METRICS_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_OS_METRICS_H_
#include "base/component_export.h"
#include "base/gtest_prod_util.h"
#include "base/process/process_handle.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
namespace heap_profiling {
......@@ -17,7 +17,8 @@ FORWARD_DECLARE_TEST(ProfilingJsonExporterTest, MemoryMaps);
namespace memory_instrumentation {
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT OSMetrics {
class COMPONENT_EXPORT(
RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION) OSMetrics {
public:
static bool FillOSMemoryDump(base::ProcessId pid, mojom::RawOSMemDump* dump);
static bool FillProcessMemoryMaps(base::ProcessId,
......
......@@ -5,10 +5,10 @@
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_TRACING_OBSERVER_H
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_TRACING_OBSERVER_H
#include "base/component_export.h"
#include "base/macros.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
namespace memory_instrumentation {
......@@ -16,8 +16,8 @@ namespace memory_instrumentation {
// Observes TraceLog for Enable/Disable events and when they occur Enables and
// Disables the MemoryDumpManager with the correct state based on reading the
// trace log. Also provides a method for adding a dump to the trace.
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT TracingObserver
: public base::trace_event::TraceLog::EnabledStateObserver {
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
TracingObserver : public base::trace_event::TraceLog::EnabledStateObserver {
public:
TracingObserver(base::trace_event::TraceLog*,
base::trace_event::MemoryDumpManager*);
......
......@@ -14,7 +14,8 @@
namespace resource_coordinator {
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT PageResourceCoordinator
class COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP)
PageResourceCoordinator
: public ResourceCoordinatorInterface<mojom::PageCoordinationUnitPtr,
mojom::PageCoordinationUnitRequest> {
public:
......
......@@ -14,10 +14,10 @@
namespace resource_coordinator {
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT ProcessResourceCoordinator
: public ResourceCoordinatorInterface<
mojom::ProcessCoordinationUnitPtr,
mojom::ProcessCoordinationUnitRequest> {
class COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP)
ProcessResourceCoordinator : public ResourceCoordinatorInterface<
mojom::ProcessCoordinationUnitPtr,
mojom::ProcessCoordinationUnitRequest> {
public:
ProcessResourceCoordinator(service_manager::Connector* connector);
~ProcessResourceCoordinator() override;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
__declspec(dllexport)
#else
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
__declspec(dllimport)
#endif // defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
__attribute__((visibility("default")))
#else
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT
#endif
#endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_EXPORT_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_EXPORT_H_
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT __declspec(dllexport)
#else
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT __declspec(dllimport)
#endif // defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT \
__attribute__((visibility("default")))
#else
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
#endif
#endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_EXPORT_H_
......@@ -8,29 +8,29 @@
#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_FEATURES_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_FEATURES_H_
#include "base/component_export.h"
#include "base/feature_list.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
namespace features {
// The features should be documented alongside the definition of their values
// in the .cc file.
extern const SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT base::Feature
kGlobalResourceCoordinator;
extern const SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT base::Feature
kPageAlmostIdle;
extern const SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT base::Feature
kPerformanceMeasurement;
extern const COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES)
base::Feature kGlobalResourceCoordinator;
extern const COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES)
base::Feature kPageAlmostIdle;
extern const COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES)
base::Feature kPerformanceMeasurement;
} // namespace features
namespace resource_coordinator {
bool SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
IsPageAlmostIdleSignalEnabled();
bool COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES)
IsPageAlmostIdleSignalEnabled();
int SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
GetMainThreadTaskLoadLowThreshold();
int COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_FEATURES)
GetMainThreadTaskLoadLowThreshold();
} // namespace resource_coordinator
......
......@@ -7,9 +7,9 @@
#include <stdint.h>
#include "base/component_export.h"
#include "base/macros.h"
#include "services/resource_coordinator/public/cpp/coordination_unit_id.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
#include "services/resource_coordinator/public/mojom/coordination_unit_provider.mojom.h"
#include "services/resource_coordinator/public/mojom/service_constants.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
......
......@@ -10,10 +10,10 @@
namespace resource_coordinator {
class SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT SystemResourceCoordinator
: public ResourceCoordinatorInterface<
mojom::SystemCoordinationUnitPtr,
mojom::SystemCoordinationUnitRequest> {
class COMPONENT_EXPORT(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP)
SystemResourceCoordinator : public ResourceCoordinatorInterface<
mojom::SystemCoordinationUnitPtr,
mojom::SystemCoordinationUnitRequest> {
public:
SystemResourceCoordinator(service_manager::Connector* connector);
~SystemResourceCoordinator() override;
......
......@@ -179,7 +179,7 @@ group("blink_platform_public_deps") {
"//services/network/public/cpp:cpp",
"//services/network/public/mojom",
"//services/network/public/mojom:mojom_blink",
"//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
"//services/resource_coordinator/public/cpp:resource_coordinator_cpp_features",
"//services/resource_coordinator/public/mojom:mojom_blink",
"//services/service_manager/public/mojom:mojom_blink",
"//skia",
......
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