| Index: services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h
|
| diff --git a/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h b/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h
|
| index 60ff3765e5312fd5abe690c3bf251ac146a90009..117661997368983b166c9a275728e054f488a42b 100644
|
| --- a/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h
|
| +++ b/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h
|
| @@ -5,8 +5,6 @@
|
| #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELEGATE_IMPL_H_
|
| #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELEGATE_IMPL_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"
|
| @@ -16,80 +14,34 @@
|
|
|
| namespace memory_instrumentation {
|
|
|
| -// This is the bridge between MemoryDumpManager and the Coordinator service.
|
| -// This indirection is needed to avoid a dependency from //base, where
|
| -// MemoryDumpManager lives, to //services, where the Coordinator service lives.
|
| -//
|
| -// This cannot just be implemented by the Coordinator service, because there is
|
| -// no Coordinator service in child processes. So, in a child process, the
|
| -// delegate remotely connects to the Coordinator service. In the browser
|
| -// process, the delegate locally connects to the Coordinator service.
|
| class MemoryDumpManagerDelegateImpl
|
| : public base::trace_event::MemoryDumpManagerDelegate,
|
| public mojom::ProcessLocalDumpManager {
|
| public:
|
| - class Config {
|
| - public:
|
| - Config(service_manager::InterfaceProvider* interface_provider)
|
| - : interface_provider_(interface_provider), coordinator_(nullptr) {}
|
| - Config(Coordinator* coordinator)
|
| - : interface_provider_(nullptr), coordinator_(coordinator) {}
|
| - ~Config();
|
| + // Use to bind to a remote coordinator.
|
| + MemoryDumpManagerDelegateImpl(
|
| + service_manager::InterfaceProvider* interface_provider);
|
|
|
| - service_manager::InterfaceProvider* interface_provider() const {
|
| - return interface_provider_;
|
| - }
|
| + // Use to bind to a coordinator in the same process.
|
| + MemoryDumpManagerDelegateImpl(Coordinator* coordinator);
|
| + ~MemoryDumpManagerDelegateImpl() override;
|
|
|
| - Coordinator* coordinator() const { return coordinator_; }
|
| -
|
| - private:
|
| - service_manager::InterfaceProvider* interface_provider_;
|
| - Coordinator* coordinator_;
|
| - bool is_test_config_;
|
| - };
|
| -
|
| - //
|
| - static MemoryDumpManagerDelegateImpl* Create(const Config& config);
|
| -
|
| - bool IsCoordinator() const override;
|
| + bool IsCoordinator() const;
|
|
|
| // The base::trace_event::MemoryDumpManager calls this.
|
| void RequestGlobalMemoryDump(
|
| const base::trace_event::MemoryDumpRequestArgs& args,
|
| const base::trace_event::MemoryDumpCallback& callback) override;
|
|
|
| - Config config() { return config_; }
|
| - void SetAsNonCoordinatorForTesting();
|
| -
|
| private:
|
| - friend std::default_delete<MemoryDumpManagerDelegateImpl>; // For testing
|
| - friend class MemoryDumpManagerDelegateImplTest; // For testing
|
| -
|
| - MemoryDumpManagerDelegateImpl(const Config& config);
|
| - ~MemoryDumpManagerDelegateImpl() override;
|
| -
|
| // The ProcessLocalDumpManager interface. The coordinator calls this.
|
| void RequestProcessMemoryDump(
|
| const base::trace_event::MemoryDumpRequestArgs& args,
|
| const RequestProcessMemoryDumpCallback& callback) override;
|
|
|
| - // A proxy callback for updating |pending_memory_dump_guid_|.
|
| - void MemoryDumpCallbackProxy(
|
| - const base::trace_event::MemoryDumpCallback& callback,
|
| - uint64_t dump_guid,
|
| - bool success);
|
| -
|
| + bool is_coordinator_;
|
| mojom::CoordinatorPtr coordinator_;
|
| mojo::Binding<mojom::ProcessLocalDumpManager> binding_;
|
| - const Config config_;
|
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| - uint64_t pending_memory_dump_guid_;
|
| -
|
| - // Prevents racy access to |pending_memory_dump_guid_|.
|
| - base::Lock pending_memory_dump_guid_lock_;
|
| -
|
| - // Prevents racy access to |initialized_|.
|
| - base::Lock initialized_lock_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegateImpl);
|
| };
|
|
|