| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELE
GATE_IMPL_H_ | 5 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELE
GATE_IMPL_H_ |
| 6 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELE
GATE_IMPL_H_ | 6 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_DELE
GATE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/trace_event/memory_dump_manager.h" | 10 #include "base/trace_event/memory_dump_manager.h" |
| 11 #include "base/trace_event/memory_dump_request_args.h" | 11 #include "base/trace_event/memory_dump_request_args.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" | 13 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" |
| 14 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" | 14 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" |
| 15 #include "services/service_manager/public/cpp/interface_provider.h" | 15 #include "services/service_manager/public/cpp/connector.h" |
| 16 | 16 |
| 17 namespace memory_instrumentation { | 17 namespace memory_instrumentation { |
| 18 | 18 |
| 19 // This is the bridge between MemoryDumpManager and the Coordinator service. | 19 // This is the bridge between MemoryDumpManager and the Coordinator service. |
| 20 // This indirection is needed to avoid a dependency from //base, where | 20 // This indirection is needed to avoid a dependency from //base, where |
| 21 // MemoryDumpManager lives, to //services, where the Coordinator service lives. | 21 // MemoryDumpManager lives, to //services, where the Coordinator service lives. |
| 22 // | 22 // |
| 23 // This cannot just be implemented by the Coordinator service, because there is | 23 // This cannot just be implemented by the Coordinator service, because there is |
| 24 // no Coordinator service in child processes. So, in a child process, the | 24 // no Coordinator service in child processes. So, in a child process, the |
| 25 // delegate remotely connects to the Coordinator service. In the browser | 25 // delegate remotely connects to the Coordinator service. In the browser |
| 26 // process, the delegate locally connects to the Coordinator service. | 26 // process, the delegate locally connects to the Coordinator service. |
| 27 class MemoryDumpManagerDelegateImpl | 27 class MemoryDumpManagerDelegateImpl |
| 28 : public base::trace_event::MemoryDumpManagerDelegate, | 28 : public base::trace_event::MemoryDumpManagerDelegate, |
| 29 public mojom::ProcessLocalDumpManager { | 29 public mojom::ProcessLocalDumpManager { |
| 30 public: | 30 public: |
| 31 class Config { | 31 class Config { |
| 32 public: | 32 public: |
| 33 Config(service_manager::InterfaceProvider* interface_provider) | 33 Config(service_manager::Connector* connector, |
| 34 : interface_provider_(interface_provider), coordinator_(nullptr) {} | 34 const std::string& service_name) |
| 35 : connector_(connector), |
| 36 service_name_(service_name), |
| 37 coordinator_(nullptr) {} |
| 35 Config(Coordinator* coordinator) | 38 Config(Coordinator* coordinator) |
| 36 : interface_provider_(nullptr), coordinator_(coordinator) {} | 39 : connector_(nullptr), coordinator_(coordinator) {} |
| 37 ~Config(); | 40 ~Config(); |
| 38 | 41 |
| 39 service_manager::InterfaceProvider* interface_provider() const { | 42 service_manager::Connector* connector() const { return connector_; } |
| 40 return interface_provider_; | 43 |
| 41 } | 44 const std::string& service_name() const { return service_name_; } |
| 42 | 45 |
| 43 Coordinator* coordinator() const { return coordinator_; } | 46 Coordinator* coordinator() const { return coordinator_; } |
| 44 | 47 |
| 45 private: | 48 private: |
| 46 service_manager::InterfaceProvider* interface_provider_; | 49 service_manager::Connector* connector_; |
| 50 const std::string service_name_; |
| 47 Coordinator* coordinator_; | 51 Coordinator* coordinator_; |
| 48 bool is_test_config_; | 52 bool is_test_config_; |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 explicit MemoryDumpManagerDelegateImpl(const Config& config); | 55 explicit MemoryDumpManagerDelegateImpl(const Config& config); |
| 52 ~MemoryDumpManagerDelegateImpl() override; | 56 ~MemoryDumpManagerDelegateImpl() override; |
| 53 | 57 |
| 54 bool IsCoordinator() const override; | 58 bool IsCoordinator() const override; |
| 55 | 59 |
| 56 // The base::trace_event::MemoryDumpManager calls this. | 60 // The base::trace_event::MemoryDumpManager calls this. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 87 | 91 |
| 88 // Prevents racy access to |initialized_|. | 92 // Prevents racy access to |initialized_|. |
| 89 base::Lock initialized_lock_; | 93 base::Lock initialized_lock_; |
| 90 | 94 |
| 91 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegateImpl); | 95 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegateImpl); |
| 92 }; | 96 }; |
| 93 | 97 |
| 94 } // namespace memory_instrumentation | 98 } // namespace memory_instrumentation |
| 95 | 99 |
| 96 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_D
ELEGATE_IMPL_H_ | 100 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_D
ELEGATE_IMPL_H_ |
| OLD | NEW |