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

Side by Side Diff: services/resource_coordinator/tracing/coordinator_impl.h

Issue 2833873003: WIP: The tracing service prototype
Patch Set: sync Created 3 years, 7 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_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
6 #define SERVICES_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/sequenced_task_runner.h"
10 #include "mojo/public/cpp/system/data_pipe.h"
11 #include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom. h"
12 #include "services/resource_coordinator/tracing/agent_set_impl.h"
13 #include "services/resource_coordinator/tracing/recorder_impl.h"
14
15 namespace resource_coordinator {
16 namespace tracing {
17
18 class CoordinatorImpl : public mojom::Coordinator {
19 public:
20 // The getter of the unique instance.
21 static CoordinatorImpl* GetInstance();
22
23 CoordinatorImpl();
24
25 void BindCoordinatorRequest(mojom::CoordinatorRequest request);
26 AgentSetImpl* agent_set() { return agent_set_.get(); }
27
28 private:
29 friend std::default_delete<CoordinatorImpl>;
30 friend class Service;
31
32 ~CoordinatorImpl() override;
33
34 // mojom::Coordinator
35 void IsTracing(const IsTracingCallback& callback) override;
36 void GetCategories(const GetCategoriesCallback& callback) override;
37 void RequestBufferUsage(const RequestBufferUsageCallback& callback) override;
38 void StartTracing(mojo::ScopedDataPipeProducerHandle stream,
39 const std::string& config) override;
40 void StopAndFlush() override;
41
42 bool IsTracing();
43
44 void SendStartTracingToAgent(AgentSetImpl::Entry* entry);
45 void OnRecorderUpdated(const std::string& label);
46 bool ReadFromRecorders();
47 void OnFlushDone();
48 void OnRequestBufferStatusResponse(AgentSetImpl::Entry* entry,
49 uint32_t capacity,
50 uint32_t count);
51
52 // Type of closures that may be run when an agent connection is closed.
53 static const char kRequestBufferUsageType[];
54
55 mojo::Binding<mojom::Coordinator> binding_;
56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
57 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
58 std::unique_ptr<AgentSetImpl> agent_set_;
59 std::string config_;
60 mojo::ScopedDataPipeProducerHandle stream_;
61 std::unordered_map<std::string, std::set<std::unique_ptr<RecorderImpl>>>
62 recorders_;
63 std::string recording_label_;
64 bool first_recorder_update_;
65 bool write_label_;
66
67 // For computing trace buffer usage.
68 float maximum_trace_buffer_usage_;
69 uint32_t approximate_event_count_;
70 size_t pending_request_buffer_status_count_;
71 RequestBufferUsageCallback request_buffer_usage_callback_;
72
73 GetCategoriesCallback get_categories_callback_;
74
75 DISALLOW_COPY_AND_ASSIGN(CoordinatorImpl);
76 };
77
78 } // namespace tracing
79 } // namespace resource_coordinator
80 #endif // SERVICES_RESOURCE_COORDINATOR_TRACING_COORDINATOR_IMPL_H_
OLDNEW
« no previous file with comments | « services/resource_coordinator/tracing/agent_set_impl.cc ('k') | services/resource_coordinator/tracing/coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698