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

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

Powered by Google App Engine
This is Rietveld 408576698