xref: /aosp_15_r20/external/cronet/components/metrics/call_stacks/call_stack_profile_collector.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "components/metrics/call_stacks/call_stack_profile_collector.h"
6 
7 #include <memory>
8 #include <utility>
9 
10 #include "components/metrics/call_stacks/call_stack_profile_encoding.h"
11 #include "components/metrics/call_stacks/call_stack_profile_metrics_provider.h"
12 #include "mojo/public/cpp/bindings/self_owned_receiver.h"
13 
14 namespace metrics {
15 
16 CallStackProfileCollector::CallStackProfileCollector() = default;
17 
18 CallStackProfileCollector::~CallStackProfileCollector() = default;
19 
20 // static
Create(mojo::PendingReceiver<mojom::CallStackProfileCollector> receiver)21 void CallStackProfileCollector::Create(
22     mojo::PendingReceiver<mojom::CallStackProfileCollector> receiver) {
23   mojo::MakeSelfOwnedReceiver(std::make_unique<CallStackProfileCollector>(),
24                               std::move(receiver));
25 }
26 
Collect(base::TimeTicks start_timestamp,mojom::ProfileType profile_type,mojom::SampledProfilePtr profile)27 void CallStackProfileCollector::Collect(base::TimeTicks start_timestamp,
28                                         mojom::ProfileType profile_type,
29                                         mojom::SampledProfilePtr profile) {
30   CallStackProfileMetricsProvider::ReceiveSerializedProfile(
31       start_timestamp, profile_type == mojom::ProfileType::kHeap,
32       std::move(profile->contents));
33 }
34 
35 }  // namespace metrics
36