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

Side by Side Diff: services/resource_coordinator/memory/coordinator/coordinator_impl.h

Issue 2741203002: memory-infra: Finish moving to Mojo (3nd attempt) (Closed)
Patch Set: rebase 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"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
15 #include "base/trace_event/memory_dump_request_args.h" 14 #include "base/trace_event/memory_dump_request_args.h"
16 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
17 #include "mojo/public/cpp/bindings/binding_set.h" 16 #include "mojo/public/cpp/bindings/binding_set.h"
18 #include "services/resource_coordinator/public/cpp/memory/coordinator.h" 17 #include "services/resource_coordinator/public/cpp/memory/coordinator.h"
19 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" 18 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h"
20 19
21 namespace memory_instrumentation { 20 namespace memory_instrumentation {
22 21
23 class CoordinatorImpl : public Coordinator, public mojom::Coordinator { 22 class CoordinatorImpl : public Coordinator, public mojom::Coordinator {
24 public: 23 public:
24 // The getter of the unique instance.
25 static CoordinatorImpl* GetInstance(); 25 static CoordinatorImpl* GetInstance();
26 26
27 explicit CoordinatorImpl(bool initialize_memory_dump_manager);
28
27 // Coordinator 29 // Coordinator
28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override; 30 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
29 31
32 bool initialize_memory_dump_manager() const {
33 return initialize_memory_dump_manager_;
34 }
35
30 private: 36 private:
31 friend class CoordinatorImplTest; // For testing 37 friend std::default_delete<CoordinatorImpl>; // For testing
32 friend struct base::LazyInstanceTraitsBase<CoordinatorImpl>; 38 friend class CoordinatorImplTest; // For testing
33 39
34 struct QueuedMemoryDumpRequest { 40 struct QueuedMemoryDumpRequest {
35 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args, 41 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args,
36 const RequestGlobalMemoryDumpCallback callback); 42 const RequestGlobalMemoryDumpCallback callback);
37 ~QueuedMemoryDumpRequest(); 43 ~QueuedMemoryDumpRequest();
38 const base::trace_event::MemoryDumpRequestArgs args; 44 const base::trace_event::MemoryDumpRequestArgs args;
39 const RequestGlobalMemoryDumpCallback callback; 45 const RequestGlobalMemoryDumpCallback callback;
40 }; 46 };
41 47
42 CoordinatorImpl();
43 ~CoordinatorImpl() override; 48 ~CoordinatorImpl() override;
44 49
45 // mojom::Coordinator 50 // mojom::Coordinator
46 void RegisterProcessLocalDumpManager( 51 void RegisterProcessLocalDumpManager(
47 mojom::ProcessLocalDumpManagerPtr process_manager) override; 52 mojom::ProcessLocalDumpManagerPtr process_manager) override;
48 53
49 // Broadcasts a dump request to all the process-local managers registered and 54 // 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 55 // notifies when all of them have completed, or the global dump attempt
51 // failed. This is in the mojom::Coordinator interface. 56 // failed. This is in the mojom::Coordinator interface.
52 void RequestGlobalMemoryDump( 57 void RequestGlobalMemoryDump(
(...skipping 18 matching lines...) Expand all
71 // Registered ProcessLocalDumpManagers. 76 // Registered ProcessLocalDumpManagers.
72 std::unordered_map<mojom::ProcessLocalDumpManager*, 77 std::unordered_map<mojom::ProcessLocalDumpManager*,
73 mojom::ProcessLocalDumpManagerPtr> 78 mojom::ProcessLocalDumpManagerPtr>
74 process_managers_; 79 process_managers_;
75 80
76 // Pending process managers for RequestGlobalMemoryDump. 81 // Pending process managers for RequestGlobalMemoryDump.
77 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_; 82 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_;
78 int failed_memory_dump_count_; 83 int failed_memory_dump_count_;
79 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_; 84 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
80 85
86 const bool initialize_memory_dump_manager_;
87
81 base::ThreadChecker thread_checker_; 88 base::ThreadChecker thread_checker_;
82 89
83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl); 90 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
84 }; 91 };
85 92
86 } // namespace memory_instrumentation 93 } // namespace memory_instrumentation
87 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 94 #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