Skip to content

Commit 479f832

Browse files
hoxyqfacebook-github-bot
authored andcommitted
Define TracingCategory enum (facebook#54377)
Summary: # Changelog: [Internal] Defines tracing category as a concept. The end goal is to be able to control these categories from the frontend, so that we only enable what user has requested. Reviewed By: sbuggay Differential Revision: D85912264
1 parent 60471cb commit 479f832

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)