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

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

Issue 2734193002: memory-infra: Finish moving to Mojo (2nd 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:
25 static CoordinatorImpl* GetInstance(); 24 static CoordinatorImpl* GetInstance();
26 25
27 // Coordinator 26 // Coordinator
28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override; 27 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
29 28
29 bool initialize_memory_dump_manager() const {
30 return initialize_memory_dump_manager_;
31 }
32
30 private: 33 private:
31 friend class CoordinatorImplTest; // For testing 34 friend std::default_delete<CoordinatorImpl>; // For testing
32 friend struct base::LazyInstanceTraitsBase<CoordinatorImpl>; 35 friend class CoordinatorImplTest; // For testing
33 36
34 struct QueuedMemoryDumpRequest { 37 struct QueuedMemoryDumpRequest {
35 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args, 38 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args,
36 const RequestGlobalMemoryDumpCallback callback); 39 const RequestGlobalMemoryDumpCallback callback);
37 ~QueuedMemoryDumpRequest(); 40 ~QueuedMemoryDumpRequest();
38 const base::trace_event::MemoryDumpRequestArgs args; 41 const base::trace_event::MemoryDumpRequestArgs args;
39 const RequestGlobalMemoryDumpCallback callback; 42 const RequestGlobalMemoryDumpCallback callback;
40 }; 43 };
41 44
42 CoordinatorImpl(); 45 CoordinatorImpl(bool initialize_memory_dump_manager);
43 ~CoordinatorImpl() override; 46 ~CoordinatorImpl() override;
44 47
45 // mojom::Coordinator 48 // mojom::Coordinator
46 void RegisterProcessLocalDumpManager( 49 void RegisterProcessLocalDumpManager(
47 mojom::ProcessLocalDumpManagerPtr process_manager) override; 50 mojom::ProcessLocalDumpManagerPtr process_manager) override;
48 51
49 // Broadcasts a dump request to all the process-local managers registered and 52 // 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 53 // notifies when all of them have completed, or the global dump attempt
51 // failed. This is in the mojom::Coordinator interface. 54 // failed. This is in the mojom::Coordinator interface.
52 void RequestGlobalMemoryDump( 55 void RequestGlobalMemoryDump(
(...skipping 18 matching lines...) Expand all
71 // Registered ProcessLocalDumpManagers. 74 // Registered ProcessLocalDumpManagers.
72 std::unordered_map<mojom::ProcessLocalDumpManager*, 75 std::unordered_map<mojom::ProcessLocalDumpManager*,
73 mojom::ProcessLocalDumpManagerPtr> 76 mojom::ProcessLocalDumpManagerPtr>
74 process_managers_; 77 process_managers_;
75 78
76 // Pending process managers for RequestGlobalMemoryDump. 79 // Pending process managers for RequestGlobalMemoryDump.
77 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_; 80 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_;
78 int failed_memory_dump_count_; 81 int failed_memory_dump_count_;
79 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_; 82 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
80 83
84 const bool initialize_memory_dump_manager_;
85
81 base::ThreadChecker thread_checker_; 86 base::ThreadChecker thread_checker_;
82 87
83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl); 88 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
84 }; 89 };
85 90
86 } // namespace memory_instrumentation 91 } // namespace memory_instrumentation
87 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 92 #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