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

Side by Side Diff: services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h

Issue 2724793002: Revert of memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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/lazy_instance.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/synchronization/lock.h"
11 #include "base/trace_event/memory_dump_manager.h" 8 #include "base/trace_event/memory_dump_manager.h"
12 #include "base/trace_event/memory_dump_request_args.h" 9 #include "base/trace_event/memory_dump_request_args.h"
13 #include "mojo/public/cpp/bindings/binding.h" 10 #include "mojo/public/cpp/bindings/binding.h"
14 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" 11 #include "services/resource_coordinator/public/cpp/memory/coordinator.h"
15 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" 12 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h"
16 #include "services/service_manager/public/cpp/interface_provider.h" 13 #include "services/service_manager/public/cpp/interface_provider.h"
17 14
18 namespace memory_instrumentation { 15 namespace memory_instrumentation {
19 16
20 class MemoryDumpManagerDelegateImpl 17 class MemoryDumpManagerDelegateImpl
21 : public base::trace_event::MemoryDumpManagerDelegate, 18 : public base::trace_event::MemoryDumpManagerDelegate,
22 public mojom::ProcessLocalDumpManager { 19 public mojom::ProcessLocalDumpManager {
23 public: 20 public:
24 static MemoryDumpManagerDelegateImpl* GetInstance();
25
26 // Use to bind to a remote coordinator. 21 // Use to bind to a remote coordinator.
27 void InitializeWithInterfaceProvider( 22 MemoryDumpManagerDelegateImpl(
28 service_manager::InterfaceProvider* interface_provider); 23 service_manager::InterfaceProvider* interface_provider);
29 24
30 // Use to bind to a coordinator in the same process. 25 // Use to bind to a coordinator in the same process.
31 void InitializeWithCoordinator( 26 MemoryDumpManagerDelegateImpl(Coordinator* coordinator);
32 Coordinator* coordinator, 27 ~MemoryDumpManagerDelegateImpl() override;
33 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
34 28
35 bool IsCoordinator() const override; 29 bool IsCoordinator() const;
36 30
37 // The base::trace_event::MemoryDumpManager calls this. 31 // The base::trace_event::MemoryDumpManager calls this.
38 void RequestGlobalMemoryDump( 32 void RequestGlobalMemoryDump(
39 const base::trace_event::MemoryDumpRequestArgs& args, 33 const base::trace_event::MemoryDumpRequestArgs& args,
40 const base::trace_event::MemoryDumpCallback& callback) override; 34 const base::trace_event::MemoryDumpCallback& callback) override;
41 35
42 void SetAsNonCoordinatorForTesting();
43
44 private: 36 private:
45 friend std::default_delete<MemoryDumpManagerDelegateImpl>; // For testing
46 friend class MemoryDumpManagerDelegateImplTest; // For testing
47 friend struct base::DefaultLazyInstanceTraits<MemoryDumpManagerDelegateImpl>;
48
49 MemoryDumpManagerDelegateImpl();
50 ~MemoryDumpManagerDelegateImpl() override;
51
52 // The ProcessLocalDumpManager interface. The coordinator calls this. 37 // The ProcessLocalDumpManager interface. The coordinator calls this.
53 void RequestProcessMemoryDump( 38 void RequestProcessMemoryDump(
54 const base::trace_event::MemoryDumpRequestArgs& args, 39 const base::trace_event::MemoryDumpRequestArgs& args,
55 const RequestProcessMemoryDumpCallback& callback) override; 40 const RequestProcessMemoryDumpCallback& callback) override;
56 41
57 // A proxy callback for updating |pending_memory_dump_guid_|. 42 bool is_coordinator_;
58 void MemoryDumpCallbackProxy(
59 const base::trace_event::MemoryDumpCallback& callback,
60 uint64_t dump_guid,
61 bool success);
62
63 bool initialized_;
64 mojom::CoordinatorPtr coordinator_; 43 mojom::CoordinatorPtr coordinator_;
65 mojo::Binding<mojom::ProcessLocalDumpManager> binding_; 44 mojo::Binding<mojom::ProcessLocalDumpManager> binding_;
66 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
67 uint64_t pending_memory_dump_guid_;
68
69 // Prevents racy access to |pending_memory_dump_guid_|.
70 base::Lock pending_memory_dump_guid_lock_;
71
72 // Prevents racy access to |initialized_|.
73 base::Lock initialized_lock_;
74 45
75 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegateImpl); 46 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegateImpl);
76 }; 47 };
77 48
78 } // namespace memory_instrumentation 49 } // namespace memory_instrumentation
79 50
80 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_D ELEGATE_IMPL_H_ 51 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_DUMP_MANAGER_D ELEGATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698