Proxy: solve event tracing with compile time strings.

This change creates trace events with a single parameter
composed of ClassName::Method.

The change additionally causes the duration of the proxy call to be
traced, not only the occurrence.

Fixed: webrtc:12787
Change-Id: I1689862318d4c6fc1dcef343c3ccf3ae9f7e17df
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219788
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34149}
This commit is contained in:
Markus Handell
2021-05-27 21:42:57 +02:00
committed by WebRTC LUCI CQ
parent d325f322c7
commit 3d46d0b200
15 changed files with 193 additions and 98 deletions

View File

@ -88,6 +88,43 @@ std::string string_trim(const std::string& s);
// TODO(jonasolsson): replace with absl::Hex when that becomes available.
std::string ToHex(const int i);
// CompileTimeString comprises of a string-like object which can be used as a
// regular const char* in compile time and supports concatenation. Useful for
// concatenating constexpr strings in for example macro declarations.
namespace rtc_base_string_utils_internal {
template <int NPlus1>
struct CompileTimeString {
char string[NPlus1] = {0};
constexpr CompileTimeString() = default;
template <int MPlus1>
explicit constexpr CompileTimeString(const char (&chars)[MPlus1]) {
char* chars_pointer = string;
for (auto c : chars)
*chars_pointer++ = c;
}
template <int MPlus1>
constexpr auto Concat(CompileTimeString<MPlus1> b) {
CompileTimeString<NPlus1 + MPlus1 - 1> result;
char* chars_pointer = result.string;
for (auto c : string)
*chars_pointer++ = c;
chars_pointer = result.string + NPlus1 - 1;
for (auto c : b.string)
*chars_pointer++ = c;
result.string[NPlus1 + MPlus1 - 2] = 0;
return result;
}
constexpr operator const char*() { return string; }
};
} // namespace rtc_base_string_utils_internal
// Makes a constexpr CompileTimeString<X> without having to specify X
// explicitly.
template <int N>
constexpr auto MakeCompileTimeString(const char (&a)[N]) {
return rtc_base_string_utils_internal::CompileTimeString<N>(a);
}
} // namespace rtc
#endif // RTC_BASE_STRING_UTILS_H_