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

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

Issue 2724793002: Revert of memory-infra: Finish moving memory_infra from TracingController (Closed)
Patch Set: 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/single_thread_task_runner.h" 14 #include "base/threading/thread_checker.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);
27 26
28 // Coordinator 27 // Coordinator
29 void BindCoordinatorRequest(mojom::CoordinatorRequest) override; 28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
30 29
31 private: 30 private:
32 friend std::default_delete<CoordinatorImpl>; // For testing 31 friend class CoordinatorImplTest; // For testing
33 friend class CoordinatorImplTest; // For testing
34 friend struct base::DefaultLazyInstanceTraits<CoordinatorImpl>; 32 friend struct base::DefaultLazyInstanceTraits<CoordinatorImpl>;
35 33
36 struct QueuedMemoryDumpRequest { 34 struct QueuedMemoryDumpRequest {
37 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args, 35 QueuedMemoryDumpRequest(const base::trace_event::MemoryDumpRequestArgs args,
38 const RequestGlobalMemoryDumpCallback callback); 36 const RequestGlobalMemoryDumpCallback callback);
39 ~QueuedMemoryDumpRequest(); 37 ~QueuedMemoryDumpRequest();
40 const base::trace_event::MemoryDumpRequestArgs args; 38 const base::trace_event::MemoryDumpRequestArgs args;
41 const RequestGlobalMemoryDumpCallback callback; 39 const RequestGlobalMemoryDumpCallback callback;
42 }; 40 };
43 41
44 CoordinatorImpl(); 42 CoordinatorImpl();
45 ~CoordinatorImpl() override; 43 ~CoordinatorImpl() override;
46 44
47 void Initialize(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
48 void InitializeForTest(
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
50
51 // mojom::Coordinator 45 // mojom::Coordinator
52 void RegisterProcessLocalDumpManager( 46 void RegisterProcessLocalDumpManager(
53 mojom::ProcessLocalDumpManagerPtr process_manager) override; 47 mojom::ProcessLocalDumpManagerPtr process_manager) override;
54 48
55 // Broadcasts a dump request to all the process-local managers registered and 49 // Broadcasts a dump request to all the process-local managers registered and
56 // notifies when all of them have completed, or the global dump attempt 50 // notifies when all of them have completed, or the global dump attempt
57 // failed. This is in the mojom::Coordinator interface. 51 // failed. This is in the mojom::Coordinator interface.
58 void RequestGlobalMemoryDump( 52 void RequestGlobalMemoryDump(
59 const base::trace_event::MemoryDumpRequestArgs& args, 53 const base::trace_event::MemoryDumpRequestArgs& args,
60 const RequestGlobalMemoryDumpCallback& callback) override; 54 const RequestGlobalMemoryDumpCallback& callback) override;
(...skipping 16 matching lines...) Expand all
77 // Registered ProcessLocalDumpManagers. 71 // Registered ProcessLocalDumpManagers.
78 std::unordered_map<mojom::ProcessLocalDumpManager*, 72 std::unordered_map<mojom::ProcessLocalDumpManager*,
79 mojom::ProcessLocalDumpManagerPtr> 73 mojom::ProcessLocalDumpManagerPtr>
80 process_managers_; 74 process_managers_;
81 75
82 // Pending process managers for RequestGlobalMemoryDump. 76 // Pending process managers for RequestGlobalMemoryDump.
83 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_; 77 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_;
84 int failed_memory_dump_count_; 78 int failed_memory_dump_count_;
85 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_; 79 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
86 80
87 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 81 base::ThreadChecker thread_checker_;
88 82
89 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl); 83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
90 }; 84 };
91 85
92 } // namespace memory_instrumentation 86 } // namespace memory_instrumentation
93 #endif // SERVICES_RESOURCE_COORDINATOR_MEMORY_COORDINATOR_COORDINATOR_IMPL_H_ 87 #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