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

Side by Side Diff: services/resource_coordinator/memory/coordinator/coordinator_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, 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_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 5 #ifndef SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_
6 #define SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 6 #define SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/trace_event/memory_dump_request_args.h" 15 #include "base/trace_event/memory_dump_request_args.h"
16 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
17 #include "mojo/public/cpp/bindings/binding_set.h" 17 #include "mojo/public/cpp/bindings/binding_set.h"
18 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" 18 #include "services/resource_coordinator/public/cpp/memory/coordinator.h"
19 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" 19 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h"
20 20
21 namespace memory_instrumentation { 21 namespace memory_instrumentation {
22 22
23 class CoordinatorImpl : public Coordinator, public mojom::Coordinator { 23 class CoordinatorImpl : public Coordinator, public mojom::Coordinator {
24 public: 24 public:
25 static CoordinatorImpl* GetInstance(); 25 static CoordinatorImpl* GetInstance(
26 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
26 27
27 // Coordinator 28 // Coordinator
28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override; 29 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
29 30
30 private: 31 private:
31 friend class CoordinatorImplTest; // For testing 32 friend std::default_delete<CoordinatorImpl>; // For testing
33 friend class CoordinatorImplTest; // For testing
32 friend struct base::DefaultLazyInstanceTraits<CoordinatorImpl>; 34 friend struct base::DefaultLazyInstanceTraits<CoordinatorImpl>;
33 35
34 struct QueuedMemoryDumpRequest { 36 struct QueuedMemoryDumpRequest {
35 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args, 37 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args,
36 const RequestGlobalMemoryDumpCallback callback); 38 const RequestGlobalMemoryDumpCallback callback);
37 ~QueuedMemoryDumpRequest(); 39 ~QueuedMemoryDumpRequest();
38 const base::trace_event::MemoryDumpRequestArgs args; 40 const base::trace_event::MemoryDumpRequestArgs args;
39 const RequestGlobalMemoryDumpCallback callback; 41 const RequestGlobalMemoryDumpCallback callback;
40 }; 42 };
41 43
42 CoordinatorImpl(); 44 CoordinatorImpl();
43 ~CoordinatorImpl() override; 45 ~CoordinatorImpl() override;
44 46
47 void Initialize(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
48 void InitializeForTest(
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
50
45 // mojom::Coordinator 51 // mojom::Coordinator
46 void RegisterProcessLocalDumpManager( 52 void RegisterProcessLocalDumpManager(
47 mojom::ProcessLocalDumpManagerPtr process_manager) override; 53 mojom::ProcessLocalDumpManagerPtr process_manager) override;
48 54
49 // Broadcasts a dump request to all the process-local managers registered and 55 // Broadcasts a dump request to all the process-local managers registered and
50 // notifies when all of them have completed, or the global dump attempt 56 // notifies when all of them have completed, or the global dump attempt
51 // failed. This is in the mojom::Coordinator interface. 57 // failed. This is in the mojom::Coordinator interface.
52 void RequestGlobalMemoryDump( 58 void RequestGlobalMemoryDump(
53 const base::trace_event::MemoryDumpRequestArgs& args, 59 const base::trace_event::MemoryDumpRequestArgs& args,
54 const RequestGlobalMemoryDumpCallback& callback) override; 60 const RequestGlobalMemoryDumpCallback& callback) override;
(...skipping 16 matching lines...) Expand all
71 // Registered ProcessLocalDumpManagers. 77 // Registered ProcessLocalDumpManagers.
72 std::unordered_map<mojom::ProcessLocalDumpManager*, 78 std::unordered_map<mojom::ProcessLocalDumpManager*,
73 mojom::ProcessLocalDumpManagerPtr> 79 mojom::ProcessLocalDumpManagerPtr>
74 process_managers_; 80 process_managers_;
75 81
76 // Pending process managers for RequestGlobalMemoryDump. 82 // Pending process managers for RequestGlobalMemoryDump.
77 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_; 83 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_;
78 int failed_memory_dump_count_; 84 int failed_memory_dump_count_;
79 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_; 85 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
80 86
81 base::ThreadChecker thread_checker_; 87 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
82 88
83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl); 89 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
84 }; 90 };
85 91
86 } // namespace memory_instrumentation 92 } // namespace memory_instrumentation
87 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 93 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_
OLDNEW
« no previous file with comments | « services/resource_coordinator/BUILD.gn ('k') | services/resource_coordinator/memory/coordinator/coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698