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

Side by Side Diff: services/memory_instrumentation/coordinator_impl.h

Issue 2693063002: Renamed /services/memory_infrastructure to /services/resource_coordinator (Closed)
Patch Set: Review fix Created 3 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_MEMORY_INSTRUMENTATION_COORDINATOR_IMPL_H_
6 #define SERVICES_MEMORY_INSTRUMENTATION_COORDINATOR_IMPL_H_
7
8 #include <list>
9 #include <set>
10 #include <unordered_map>
11
12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h"
15 #include "base/trace_event/memory_dump_request_args.h"
16 #include "mojo/public/cpp/bindings/binding.h"
17 #include "mojo/public/cpp/bindings/binding_set.h"
18 #include "services/memory_instrumentation/public/cpp/coordinator.h"
19 #include "services/memory_instrumentation/public/interfaces/memory_instrumentati on.mojom.h"
20
21 namespace memory_instrumentation {
22
23 class CoordinatorImpl : public Coordinator, public mojom::Coordinator {
24 public:
25 static CoordinatorImpl* GetInstance();
26
27 // Coordinator
28 void BindCoordinatorRequest(mojom::CoordinatorRequest) override;
29
30 private:
31 friend class CoordinatorImplTest; // For testing
32 friend struct base::DefaultLazyInstanceTraits<CoordinatorImpl>;
33
34 struct QueuedMemoryDumpRequest {
35 QueuedMemoryDumpRequest(
36 const base::trace_event::MemoryDumpRequestArgs args,
37 const RequestGlobalMemoryDumpCallback callback);
38 ~QueuedMemoryDumpRequest();
39 const base::trace_event::MemoryDumpRequestArgs args;
40 const RequestGlobalMemoryDumpCallback callback;
41 };
42
43 CoordinatorImpl();
44 ~CoordinatorImpl() override;
45
46 // mojom::Coordinator
47 void RegisterProcessLocalDumpManager(
48 mojom::ProcessLocalDumpManagerPtr process_manager) override;
49
50 // Broadcasts a dump request to all the process-local managers registered and
51 // notifies when all of them have completed, or the global dump attempt
52 // failed. This is in the mojom::Coordinator interface.
53 void RequestGlobalMemoryDump(
54 const base::trace_event::MemoryDumpRequestArgs& args,
55 const RequestGlobalMemoryDumpCallback& callback) override;
56
57 // Called when a process-local manager gets disconnected.
58 void UnregisterProcessLocalDumpManager(
59 mojom::ProcessLocalDumpManager* process_manager);
60
61 // Callback of RequestProcessMemoryDump.
62 void OnProcessMemoryDumpResponse(
63 mojom::ProcessLocalDumpManager* process_manager,
64 uint64_t dump_guid,
65 bool success);
66
67 void PerformNextQueuedGlobalMemoryDump();
68 void FinalizeGlobalMemoryDumpIfAllManagersReplied();
69
70 mojo::BindingSet<mojom::Coordinator> bindings_;
71
72 // Registered ProcessLocalDumpManagers.
73 std::unordered_map<mojom::ProcessLocalDumpManager*,
74 mojom::ProcessLocalDumpManagerPtr> process_managers_;
75
76 // Pending process managers for RequestGlobalMemoryDump.
77 std::set<mojom::ProcessLocalDumpManager*> pending_process_managers_;
78 int failed_memory_dump_count_;
79 std::list<QueuedMemoryDumpRequest> queued_memory_dump_requests_;
80
81 base::ThreadChecker thread_checker_;
82
83 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
84 };
85
86 } // namespace memory_instrumentation
87 #endif // SERVICES_MEMORY_INFSTRUMENTATION_COORDINATOR_IMPL_H_
OLDNEW
« no previous file with comments | « services/memory_instrumentation/OWNERS ('k') | services/memory_instrumentation/coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698