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

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: review 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 and setter of the unique instance.
25 static CoordinatorImpl* GetInstance(); 25 static CoordinatorImpl* GetInstance();
26 static void SetInstance(CoordinatorImpl* coordinator_impl);
jam 2017/03/16 15:42:43 this seems redundant; just set the global in the c
chiniforooshan 2017/03/16 17:13:17 Done.
27
28 explicit CoordinatorImpl(bool initialize_memory_dump_manager);
26 29
27 // Coordinator 30 // Coordinator
28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override; 31 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
29 32
33 bool initialize_memory_dump_manager() const {
34 return initialize_memory_dump_manager_;
35 }
36
30 private: 37 private:
31 friend class CoordinatorImplTest; // For testing 38 friend std::default_delete<CoordinatorImpl>; // For testing
32 friend struct base::LazyInstanceTraitsBase<CoordinatorImpl>; 39 friend class CoordinatorImplTest; // For testing
33 40
34 struct QueuedMemoryDumpRequest { 41 struct QueuedMemoryDumpRequest {
35 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args, 42 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args,
36 const RequestGlobalMemoryDumpCallback callback); 43 const RequestGlobalMemoryDumpCallback callback);
37 ~QueuedMemoryDumpRequest(); 44 ~QueuedMemoryDumpRequest();
38 const base::trace_event::MemoryDumpRequestArgs args; 45 const base::trace_event::MemoryDumpRequestArgs args;
39 const RequestGlobalMemoryDumpCallback callback; 46 const RequestGlobalMemoryDumpCallback callback;
40 }; 47 };
41 48
42 CoordinatorImpl();
43 ~CoordinatorImpl() override; 49 ~CoordinatorImpl() override;
44 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(
(...skipping 18 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
87 const bool initialize_memory_dump_manager_;
88
81 base::ThreadChecker thread_checker_; 89 base::ThreadChecker thread_checker_;
82 90
83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl); 91 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
84 }; 92 };
85 93
86 } // namespace memory_instrumentation 94 } // namespace memory_instrumentation
87 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 95 #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