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 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_PARAMS_H_ 6 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_PARAMS_H_ 7 8 #include "base/time/time.h" 9 10 namespace metrics { 11 12 // Parameters to pass back to the metrics provider. 13 struct CallStackProfileParams { 14 // The process in which the collection occurred. 15 enum class Process { 16 kUnknown, 17 kBrowser, 18 kRenderer, 19 kGpu, 20 kUtility, 21 kZygote, 22 kSandboxHelper, 23 kPpapiPlugin, 24 kNetworkService, 25 26 kMax = kNetworkService, 27 }; 28 29 // The thread from which the collection occurred. 30 enum class Thread { 31 kUnknown, 32 33 // Each process has a 'main thread'. In the Browser process, the 'main 34 // thread' is also often called the 'UI thread'. 35 kMain, 36 kIo, 37 38 // Compositor thread (can be in both renderer and gpu processes). 39 kCompositor, 40 41 // Service worker thread. 42 kServiceWorker, 43 44 kMax = kServiceWorker, 45 }; 46 47 // The event that triggered the profile collection. 48 enum class Trigger { 49 kUnknown, 50 kProcessStartup, 51 kJankyTask, 52 kThreadHung, 53 kPeriodicCollection, 54 kPeriodicHeapCollection, 55 kLast = kPeriodicHeapCollection 56 }; 57 58 // The default constructor is required for mojo and should not be used 59 // otherwise. A valid trigger should always be specified. 60 constexpr CallStackProfileParams() = default; 61 62 constexpr CallStackProfileParams( 63 Process process, 64 Thread thread, 65 Trigger trigger, 66 base::TimeDelta time_offset = base::TimeDelta()) processCallStackProfileParams67 : process(process), 68 thread(thread), 69 trigger(trigger), 70 time_offset(time_offset) {} 71 72 // The collection process. 73 Process process = Process::kUnknown; 74 75 // The collection thread. 76 Thread thread = Thread::kUnknown; 77 78 // The triggering event. 79 Trigger trigger = Trigger::kUnknown; 80 81 // The time of the profile, since roughly the start of the process being 82 // profiled. 0 indicates that the time is not reported. 83 base::TimeDelta time_offset; 84 }; 85 86 } // namespace metrics 87 88 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_PARAMS_H_ 89