Chromium Code Reviews| 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 117661997368983b166c9a275728e054f488a42b..fee52d1068f0be66e8732614ac65920430dcfacb 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,6 +5,9 @@ |
| #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/lazy_instance.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" |
| @@ -18,15 +21,18 @@ class MemoryDumpManagerDelegateImpl |
| : public base::trace_event::MemoryDumpManagerDelegate, |
| public mojom::ProcessLocalDumpManager { |
| public: |
| + static MemoryDumpManagerDelegateImpl* GetInstance(); |
| + |
| // Use to bind to a remote coordinator. |
| - MemoryDumpManagerDelegateImpl( |
| + void InitializeWithInterfaceProvider( |
| service_manager::InterfaceProvider* interface_provider); |
| // Use to bind to a coordinator in the same process. |
| - MemoryDumpManagerDelegateImpl(Coordinator* coordinator); |
| - ~MemoryDumpManagerDelegateImpl() override; |
| + void InitializeWithCoordinator( |
| + Coordinator* coordinator, |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| - bool IsCoordinator() const; |
| + bool IsCoordinator() const override; |
| // The base::trace_event::MemoryDumpManager calls this. |
| void RequestGlobalMemoryDump( |
| @@ -34,14 +40,35 @@ class MemoryDumpManagerDelegateImpl |
| const base::trace_event::MemoryDumpCallback& callback) override; |
| private: |
| + friend std::default_delete<MemoryDumpManagerDelegateImpl>; // For testing |
| + friend class MemoryDumpManagerDelegateImplTest; // For testing |
| + friend struct base::DefaultLazyInstanceTraits<MemoryDumpManagerDelegateImpl>; |
| + |
| + MemoryDumpManagerDelegateImpl(); |
| + ~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 OnMemoryDump(const base::trace_event::MemoryDumpCallback& callback, |
|
ssid
2017/02/23 20:21:50
Not sure if this was already discussed. Could you
chiniforooshan
2017/02/24 15:51:03
Done.
|
| + uint64_t dump_guid, |
| + bool success); |
| + |
| + bool initialized_; |
| bool is_coordinator_; |
| mojom::CoordinatorPtr coordinator_; |
| mojo::Binding<mojom::ProcessLocalDumpManager> binding_; |
| + 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); |
| }; |