|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +#pragma once |
| 9 | + |
| 10 | +#include <optional> |
| 11 | +#include <string> |
| 12 | + |
| 13 | +namespace facebook::react::jsinspector_modern::tracing { |
| 14 | + |
| 15 | +enum class Category { |
| 16 | + HiddenTimeline, /* disabled-by-default-devtools.timeline */ |
| 17 | + JavaScriptSampling, /* disabled-by-default-v8.cpu_profiler */ |
| 18 | + RuntimeExecution, /* v8.execute */ |
| 19 | + Timeline, /* devtools.timeline */ |
| 20 | + UserTiming, /* blink.user_timing */ |
| 21 | +}; |
| 22 | + |
| 23 | +inline std::string tracingCategoryToString(const Category &category) |
| 24 | +{ |
| 25 | + switch (category) { |
| 26 | + case Category::Timeline: |
| 27 | + return "devtools.timeline"; |
| 28 | + case Category::HiddenTimeline: |
| 29 | + return "disabled-by-default-devtools.timeline"; |
| 30 | + case Category::UserTiming: |
| 31 | + return "blink.user_timing"; |
| 32 | + case Category::JavaScriptSampling: |
| 33 | + return "disabled-by-default-v8.cpu_profiler"; |
| 34 | + case Category::RuntimeExecution: |
| 35 | + return "v8.execute"; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +inline std::optional<Category> getTracingCategoryFromString(const std::string &str) |
| 40 | +{ |
| 41 | + if (str == "blink.user_timing") { |
| 42 | + return Category::UserTiming; |
| 43 | + } else if (str == "devtools.timeline") { |
| 44 | + return Category::Timeline; |
| 45 | + } else if (str == "disabled-by-default-devtools.timeline") { |
| 46 | + return Category::HiddenTimeline; |
| 47 | + } else if (str == "disabled-by-default-v8.cpu_profiler") { |
| 48 | + return Category::JavaScriptSampling; |
| 49 | + } else if (str == "v8.execute") { |
| 50 | + return Category::RuntimeExecution; |
| 51 | + } else { |
| 52 | + return std::nullopt; |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +} // namespace facebook::react::jsinspector_modern::tracing |
0 commit comments