Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h

Issue 2694083005: memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: style: auto must not deduce to raw pointer Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0986e22b1ab209a345875a41f018144468c3913f 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,30 +21,56 @@ 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(
const base::trace_event::MemoryDumpRequestArgs& args,
const base::trace_event::MemoryDumpCallback& callback) override;
+ void SetAsNonCoordinatorForTesting();
+
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;
- bool is_coordinator_;
+ // A proxy callback for updating |pending_memory_dump_guid_|.
+ void MemoryDumpCallbackProxy(
+ const base::trace_event::MemoryDumpCallback& callback,
+ uint64_t dump_guid,
+ bool success);
+
+ bool initialized_;
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);
};

Powered by Google App Engine
This is Rietveld 408576698