diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index ae3e4110bf3f86..eee02fb990f882 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -133,7 +133,6 @@ #include "chrome/common/pepper_permission_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/prerender_url_loader_throttle.h" -#include "chrome/common/profiling/constants.mojom.h" #include "chrome/common/render_messages.h" #include "chrome/common/renderer_configuration.mojom.h" #include "chrome/common/secure_origin_whitelist.h" @@ -182,6 +181,7 @@ #include "components/safe_browsing/db/database_manager.h" #include "components/safe_browsing/features.h" #include "components/safe_browsing/password_protection/password_protection_navigation_throttle.h" +#include "components/services/heap_profiling/public/mojom/constants.mojom.h" #include "components/services/patch/public/interfaces/constants.mojom.h" #include "components/services/unzip/public/interfaces/constants.mojom.h" #include "components/signin/core/browser/profile_management_switches.h" diff --git a/chrome/browser/profiling_host/profiling_process_host.cc b/chrome/browser/profiling_host/profiling_process_host.cc index 7fa51cbec0b15d..e8fe997585820d 100644 --- a/chrome/browser/profiling_host/profiling_process_host.cc +++ b/chrome/browser/profiling_host/profiling_process_host.cc @@ -33,9 +33,9 @@ #include "chrome/browser/tracing/crash_service_uploader.h" #include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/profiling/constants.mojom.h" #include "chrome/common/profiling/memlog_sender_pipe.h" #include "chrome/common/profiling/profiling_constants.h" +#include "components/services/heap_profiling/public/mojom/constants.mojom.h" #include "components/version_info/version_info.h" #include "content/public/browser/browser_child_process_host.h" #include "content/public/browser/browser_child_process_host_iterator.h" diff --git a/chrome/browser/profiling_host/profiling_process_host.h b/chrome/browser/profiling_host/profiling_process_host.h index fcaea7e494986d..1c4f9da63e0c09 100644 --- a/chrome/browser/profiling_host/profiling_process_host.h +++ b/chrome/browser/profiling_host/profiling_process_host.h @@ -17,8 +17,8 @@ #include "chrome/browser/profiling_host/background_profiling_triggers.h" #include "chrome/common/chrome_features.h" #include "chrome/common/profiling/profiling_client.h" -#include "chrome/common/profiling/profiling_client.mojom.h" -#include "chrome/common/profiling/profiling_service.mojom.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_service.mojom.h" #include "content/public/browser/browser_child_process_observer.h" #include "content/public/browser/child_process_data.h" #include "content/public/browser/notification_observer.h" diff --git a/chrome/common/profiling/BUILD.gn b/chrome/common/profiling/BUILD.gn index 773b6d780a164d..2a6f62dd6fa6da 100644 --- a/chrome/common/profiling/BUILD.gn +++ b/chrome/common/profiling/BUILD.gn @@ -20,7 +20,7 @@ static_library("profiling") { ] public_deps = [ - ":interfaces", + "//components/services/heap_profiling/public:interfaces", ] deps = [ "//base", @@ -32,18 +32,6 @@ static_library("profiling") { ] } -mojom("interfaces") { - sources = [ - "constants.mojom", - "profiling_client.mojom", - "profiling_service.mojom", - ] - deps = [ - "//mojo/common:common_custom_types", - "//mojo/public/mojom/base", - ] -} - source_set("unit_tests") { testonly = true sources = [ diff --git a/chrome/common/profiling/DEPS b/chrome/common/profiling/DEPS index b236bb77146da7..ffd2b74e390a92 100644 --- a/chrome/common/profiling/DEPS +++ b/chrome/common/profiling/DEPS @@ -1,4 +1,5 @@ include_rules = [ "+mojo/edk/embedder", "+services/service_manager/public/cpp", + "+components/services/heap_profiling/public", ] diff --git a/chrome/common/profiling/memlog_allocator_shim.h b/chrome/common/profiling/memlog_allocator_shim.h index 467846d046f747..08fcd8c8802d94 100644 --- a/chrome/common/profiling/memlog_allocator_shim.h +++ b/chrome/common/profiling/memlog_allocator_shim.h @@ -7,7 +7,7 @@ #include "chrome/common/profiling/memlog_sender_pipe.h" #include "chrome/common/profiling/memlog_stream.h" -#include "chrome/common/profiling/profiling_client.mojom.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h" namespace profiling { diff --git a/chrome/common/profiling/profiling_client.h b/chrome/common/profiling/profiling_client.h index 6faed8748a6093..5649566f351db6 100644 --- a/chrome/common/profiling/profiling_client.h +++ b/chrome/common/profiling/profiling_client.h @@ -5,7 +5,7 @@ #ifndef CHROME_COMMON_PROFILING_PROFILING_CLIENT_H_ #define CHROME_COMMON_PROFILING_PROFILING_CLIENT_H_ -#include "chrome/common/profiling/profiling_client.mojom.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/system/handle.h" diff --git a/chrome/profiling/DEPS b/chrome/profiling/DEPS index 9ec6dd206024dc..b45205cc608758 100644 --- a/chrome/profiling/DEPS +++ b/chrome/profiling/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/services/heap_profiling/public", "+content/public/child", "+mojo/edk/embedder", "+services/resource_coordinator/public", diff --git a/chrome/profiling/json_exporter.h b/chrome/profiling/json_exporter.h index 6968a63d796443..b4deb9c33ee93f 100644 --- a/chrome/profiling/json_exporter.h +++ b/chrome/profiling/json_exporter.h @@ -10,8 +10,8 @@ #include "base/values.h" #include "chrome/common/profiling/memlog_stream.h" -#include "chrome/common/profiling/profiling_service.mojom.h" #include "chrome/profiling/allocation_event.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_service.mojom.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" namespace profiling { diff --git a/chrome/profiling/memlog_connection_manager.h b/chrome/profiling/memlog_connection_manager.h index 8da3e474879684..40931b05aeb577 100644 --- a/chrome/profiling/memlog_connection_manager.h +++ b/chrome/profiling/memlog_connection_manager.h @@ -17,10 +17,10 @@ #include "base/threading/thread.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/common/profiling/profiling_service.mojom.h" #include "chrome/profiling/allocation_event.h" #include "chrome/profiling/allocation_tracker.h" #include "chrome/profiling/backtrace_storage.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_service.mojom.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" diff --git a/chrome/profiling/profiling_service.h b/chrome/profiling/profiling_service.h index ff77ff81a427be..952c6bb3b4d07e 100644 --- a/chrome/profiling/profiling_service.h +++ b/chrome/profiling/profiling_service.h @@ -6,8 +6,8 @@ #define CHROME_PROFILING_PROFILING_SERVICE_H_ #include "base/memory/weak_ptr.h" -#include "chrome/common/profiling/profiling_service.mojom.h" #include "chrome/profiling/memlog_connection_manager.h" +#include "components/services/heap_profiling/public/mojom/heap_profiling_service.mojom.h" #include "mojo/public/cpp/bindings/binding.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" #include "services/service_manager/public/cpp/binder_registry.h" diff --git a/chrome/utility/DEPS b/chrome/utility/DEPS index e12af00d0dbc19..7305d09a914685 100644 --- a/chrome/utility/DEPS +++ b/chrome/utility/DEPS @@ -18,6 +18,7 @@ include_rules = [ "+chrome/services/wifi_util_win/wifi_util_win_service.h", "+chrome/services/wifi_util_win/public/mojom", "+components/crash/core/common/crash_keys.h", + "+components/services/heap_profiling/public", "+components/services/font/font_service_app.h", "+components/services/patch", "+components/payments/content/utility", diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index 1d9b65c4051197..6d30f87f6d3f0b 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc @@ -15,8 +15,8 @@ #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "chrome/common/buildflags.h" -#include "chrome/common/profiling/constants.mojom.h" #include "chrome/profiling/profiling_service.h" +#include "components/services/heap_profiling/public/mojom/constants.mojom.h" #include "components/services/patch/patch_service.h" #include "components/services/patch/public/interfaces/constants.mojom.h" #include "components/services/unzip/public/interfaces/constants.mojom.h" diff --git a/components/services/heap_profiling/OWNERS b/components/services/heap_profiling/OWNERS new file mode 100644 index 00000000000000..987c0c88a4ac69 --- /dev/null +++ b/components/services/heap_profiling/OWNERS @@ -0,0 +1 @@ +erikchen@chromium.org diff --git a/components/services/heap_profiling/README.md b/components/services/heap_profiling/README.md new file mode 100644 index 00000000000000..27028b262080e1 --- /dev/null +++ b/components/services/heap_profiling/README.md @@ -0,0 +1,18 @@ +The heap profiling service provides: + * Storage for recording metadata about heap allocations and deallocations, + for any number of clients. + * A lightweight, synchronous API for clients to send metadata about heap + allocations and deallocations. + +There are two main entities: + * Heap Profiling Clients send heap allocation data to the Heap Profiling + Service. Clients require no special privileges. There should be at most 1 + Client per process, since heap hooks are instantiated on a per-process + basis. + * The Heap Profiling Service runs in an unprivileged, sandboxed process. It's + sole purpose is to record allocations and serve them in heap dumps. + +Heap dumps are emitted in traces with the "memory-infra" category enabled. This +is coordinated by the (memory_instrumentation +service)[https://cs.chromium.org/chromium/src/services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom]. +See the HeapProfiler and HeapProfilerHelper interfaces. diff --git a/components/services/heap_profiling/public/BUILD.gn b/components/services/heap_profiling/public/BUILD.gn new file mode 100644 index 00000000000000..9c3328cb072a23 --- /dev/null +++ b/components/services/heap_profiling/public/BUILD.gn @@ -0,0 +1,17 @@ +# 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. + +import("//mojo/public/tools/bindings/mojom.gni") + +mojom("interfaces") { + sources = [ + "mojom/constants.mojom", + "mojom/heap_profiling_client.mojom", + "mojom/heap_profiling_service.mojom", + ] + deps = [ + "//mojo/common:common_custom_types", + "//mojo/public/mojom/base", + ] +} diff --git a/components/services/heap_profiling/public/mojom/OWNERS b/components/services/heap_profiling/public/mojom/OWNERS new file mode 100644 index 00000000000000..08850f421205f8 --- /dev/null +++ b/components/services/heap_profiling/public/mojom/OWNERS @@ -0,0 +1,2 @@ +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS diff --git a/chrome/common/profiling/constants.mojom b/components/services/heap_profiling/public/mojom/constants.mojom similarity index 100% rename from chrome/common/profiling/constants.mojom rename to components/services/heap_profiling/public/mojom/constants.mojom diff --git a/chrome/common/profiling/profiling_client.mojom b/components/services/heap_profiling/public/mojom/heap_profiling_client.mojom similarity index 100% rename from chrome/common/profiling/profiling_client.mojom rename to components/services/heap_profiling/public/mojom/heap_profiling_client.mojom diff --git a/chrome/common/profiling/profiling_service.mojom b/components/services/heap_profiling/public/mojom/heap_profiling_service.mojom similarity index 84% rename from chrome/common/profiling/profiling_service.mojom rename to components/services/heap_profiling/public/mojom/heap_profiling_service.mojom index 202e8ff82907a0..882edccec7382c 100644 --- a/chrome/common/profiling/profiling_service.mojom +++ b/components/services/heap_profiling/public/mojom/heap_profiling_service.mojom @@ -4,7 +4,7 @@ module profiling.mojom; -import "chrome/common/profiling/profiling_client.mojom"; +import "components/services/heap_profiling/public/mojom/heap_profiling_client.mojom"; import "mojo/public/mojom/base/process_id.mojom"; import "mojo/common/values.mojom"; @@ -31,10 +31,8 @@ interface ProfilingService { // // |stack_mode| refers to the type of stacks that the client should record for // allocations. - AddProfilingClient(mojo_base.mojom.ProcessId pid, - ProfilingClient client, - handle memlog_pipe_receiver, - ProcessType process_type, + AddProfilingClient(mojo_base.mojom.ProcessId pid, ProfilingClient client, + handle memlog_pipe_receiver, ProcessType process_type, ProfilingParams params); // |keep_small_allocations| controls whether small allocations are emitted in diff --git a/services/README.md b/services/README.md index 035bcb9fd5b69f..fb2c309c4d60b6 100644 --- a/services/README.md +++ b/services/README.md @@ -31,7 +31,7 @@ Individual services are structured like so: //services/foo/ <-- Implementation code, may have subdirs. /public/ /cpp/ <-- C++ client libraries (optional) - /interfaces/ <-- Mojom interfaces + /mojom/ <-- Mojom interfaces ``` ## Dependencies