| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ | 5 #ifndef COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ |
| 6 #define COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ | 6 #define COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 void SetParentProfileCollector( | 61 void SetParentProfileCollector( |
| 62 metrics::mojom::CallStackProfileCollectorPtr parent_collector); | 62 metrics::mojom::CallStackProfileCollectorPtr parent_collector); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 friend class ChildCallStackProfileCollectorTest; | 65 friend class ChildCallStackProfileCollectorTest; |
| 66 | 66 |
| 67 // Bundles together a set of collected profiles and the collection state for | 67 // Bundles together a set of collected profiles and the collection state for |
| 68 // storage, pending availability of the parent mojo interface. | 68 // storage, pending availability of the parent mojo interface. |
| 69 struct ProfilesState { | 69 struct ProfilesState { |
| 70 ProfilesState(); | 70 ProfilesState(); |
| 71 ProfilesState(const ProfilesState&); | 71 ProfilesState(ProfilesState&&); |
| 72 ProfilesState( | 72 ProfilesState( |
| 73 const CallStackProfileParams& params, | 73 const CallStackProfileParams& params, |
| 74 base::TimeTicks start_timestamp, | 74 base::TimeTicks start_timestamp, |
| 75 const base::StackSamplingProfiler::CallStackProfiles& profiles); | 75 base::StackSamplingProfiler::CallStackProfiles profiles); |
| 76 ~ProfilesState(); | 76 ~ProfilesState(); |
| 77 | 77 |
| 78 ProfilesState& operator=(ProfilesState&&); |
| 79 |
| 78 CallStackProfileParams params; | 80 CallStackProfileParams params; |
| 79 base::TimeTicks start_timestamp; | 81 base::TimeTicks start_timestamp; |
| 80 | 82 |
| 81 // The sampled profiles. | 83 // The sampled profiles. |
| 82 base::StackSamplingProfiler::CallStackProfiles profiles; | 84 base::StackSamplingProfiler::CallStackProfiles profiles; |
| 85 |
| 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(ProfilesState); |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 using CallStackProfile = base::StackSamplingProfiler::CallStackProfile; | 90 using CallStackProfile = base::StackSamplingProfiler::CallStackProfile; |
| 86 | 91 |
| 87 void Collect(const CallStackProfileParams& params, | 92 void Collect(const CallStackProfileParams& params, |
| 88 base::TimeTicks start_timestamp, | 93 base::TimeTicks start_timestamp, |
| 89 const std::vector<CallStackProfile>& profiles); | 94 std::vector<CallStackProfile> profiles); |
| 90 | 95 |
| 91 // This object may be accessed on any thread, including the profiler | 96 // This object may be accessed on any thread, including the profiler |
| 92 // thread. The expected use case for the object is to be created and have | 97 // thread. The expected use case for the object is to be created and have |
| 93 // GetProfilerCallback before the message loop starts, which prevents the use | 98 // GetProfilerCallback before the message loop starts, which prevents the use |
| 94 // of PostTask and the like for inter-thread communication. | 99 // of PostTask and the like for inter-thread communication. |
| 95 base::Lock lock_; | 100 base::Lock lock_; |
| 96 | 101 |
| 97 // Whether to retain profiles when the interface is not set. Remains true | 102 // Whether to retain profiles when the interface is not set. Remains true |
| 98 // until the invocation of SetParentProfileCollector(), at which point it is | 103 // until the invocation of SetParentProfileCollector(), at which point it is |
| 99 // false for the rest of the object lifetime. | 104 // false for the rest of the object lifetime. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 111 // Profiles being cached by this object, pending a parent interface to be | 116 // Profiles being cached by this object, pending a parent interface to be |
| 112 // supplied. | 117 // supplied. |
| 113 std::vector<ProfilesState> profiles_; | 118 std::vector<ProfilesState> profiles_; |
| 114 | 119 |
| 115 DISALLOW_COPY_AND_ASSIGN(ChildCallStackProfileCollector); | 120 DISALLOW_COPY_AND_ASSIGN(ChildCallStackProfileCollector); |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 } // namespace metrics | 123 } // namespace metrics |
| 119 | 124 |
| 120 #endif // COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ | 125 #endif // COMPONENTS_METRICS_CHILD_CALL_STACK_PROFILE_COLLECTOR_H_ |
| OLD | NEW |