wittman | e16da278 | 2016-09-21 16:43:04 | [diff] [blame] | 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 | |
| 5 | #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_COLLECTOR_H_ |
| 6 | #define COMPONENTS_METRICS_CALL_STACK_PROFILE_COLLECTOR_H_ |
| 7 | |
| 8 | #include "base/macros.h" |
| 9 | #include "components/metrics/public/interfaces/call_stack_profile_collector.mojom.h" |
| 10 | |
| 11 | namespace metrics { |
| 12 | |
| 13 | class CallStackProfileCollector : public mojom::CallStackProfileCollector { |
| 14 | public: |
| 15 | using CallStackProfile = base::StackSamplingProfiler::CallStackProfile; |
| 16 | |
wittman | 4472aa9 | 2016-09-22 20:13:46 | [diff] [blame^] | 17 | explicit CallStackProfileCollector( |
| 18 | CallStackProfileParams::Process expected_process); |
wittman | e16da278 | 2016-09-21 16:43:04 | [diff] [blame] | 19 | ~CallStackProfileCollector() override; |
| 20 | |
wittman | 4472aa9 | 2016-09-22 20:13:46 | [diff] [blame^] | 21 | // Create a collector to receive profiles from |expected_process|. |
| 22 | static void Create(CallStackProfileParams::Process expected_process, |
| 23 | mojom::CallStackProfileCollectorRequest request); |
wittman | e16da278 | 2016-09-21 16:43:04 | [diff] [blame] | 24 | |
| 25 | // mojom::CallStackProfileCollector: |
| 26 | void Collect(const CallStackProfileParams& params, |
| 27 | base::TimeTicks start_timestamp, |
| 28 | const std::vector<CallStackProfile>& profiles) override; |
| 29 | |
| 30 | private: |
wittman | 4472aa9 | 2016-09-22 20:13:46 | [diff] [blame^] | 31 | // Profile params are validated to come from this process. Profiles with a |
| 32 | // different process declared in the params are considered untrustworthy and |
| 33 | // ignored. |
| 34 | const CallStackProfileParams::Process expected_process_; |
| 35 | |
wittman | e16da278 | 2016-09-21 16:43:04 | [diff] [blame] | 36 | DISALLOW_COPY_AND_ASSIGN(CallStackProfileCollector); |
| 37 | }; |
| 38 | |
| 39 | } // namespace metrics |
| 40 | |
| 41 | #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_COLLECTOR_H_ |