call_stack_profile_collector.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2016 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. #include "components/metrics/call_stack_profile_collector.h"
  5. #include <memory>
  6. #include <utility>
  7. #include "components/metrics/call_stack_profile_encoding.h"
  8. #include "components/metrics/call_stack_profile_metrics_provider.h"
  9. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  10. namespace metrics {
  11. CallStackProfileCollector::CallStackProfileCollector() = default;
  12. CallStackProfileCollector::~CallStackProfileCollector() = default;
  13. // static
  14. void CallStackProfileCollector::Create(
  15. mojo::PendingReceiver<mojom::CallStackProfileCollector> receiver) {
  16. mojo::MakeSelfOwnedReceiver(std::make_unique<CallStackProfileCollector>(),
  17. std::move(receiver));
  18. }
  19. void CallStackProfileCollector::Collect(base::TimeTicks start_timestamp,
  20. mojom::ProfileType profile_type,
  21. mojom::SampledProfilePtr profile) {
  22. CallStackProfileMetricsProvider::ReceiveSerializedProfile(
  23. start_timestamp, profile_type == mojom::ProfileType::kHeap,
  24. std::move(profile->contents));
  25. }
  26. } // namespace metrics