1 // Copyright 2024 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 BASE_TRACE_EVENT_NAMED_TRIGGER_H_ 6 #define BASE_TRACE_EVENT_NAMED_TRIGGER_H_ 7 8 #include <optional> 9 #include <string> 10 11 #include "base/base_export.h" 12 13 namespace base::trace_event { 14 15 // Notifies that a manual trigger event has occurred. Returns true if the 16 // trigger caused a scenario to either begin recording or finalize the trace 17 // depending on the config, or false if the trigger had no effect. If the 18 // trigger specified isn't active in the config, this will do nothing. 19 BASE_EXPORT bool EmitNamedTrigger(const std::string& trigger_name, 20 std::optional<int32_t> value = std::nullopt); 21 22 class NamedTriggerManager { 23 public: 24 virtual bool DoEmitNamedTrigger(const std::string& trigger_name, 25 std::optional<int32_t> value) = 0; 26 27 protected: 28 // Sets the instance returns by GetInstance() globally to |manager|. 29 BASE_EXPORT static void SetInstance(NamedTriggerManager* manager); 30 }; 31 32 } // namespace base::trace_event 33 34 #endif // BASE_TRACE_EVENT_NAMED_TRIGGER_H_ 35