Commit 1982f4ee authored by Karel Král's avatar Karel Král Committed by Commit Bot

Move TracedValue::ValueToString outside the class

Refactor function ValueToString from the class
base::trace_event::TracedValue into namespace base::trace_event.

This is a follow-up of http://crrev.com/c/2299722

Bug: 1103623
Change-Id: Ied92ce36da432d84fef4b186f902c8ac581b416b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302029Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Commit-Queue: Karel Král <karelkral@google.com>
Cr-Commit-Position: refs/heads/master@{#789379}
parent 6b997b28
...@@ -131,14 +131,6 @@ class BASE_EXPORT TracedValue : public ConvertableToTraceFormat { ...@@ -131,14 +131,6 @@ class BASE_EXPORT TracedValue : public ConvertableToTraceFormat {
KeptValueType kept_value_type_; KeptValueType kept_value_type_;
}; };
// Return std::string representation given by |value|'s ostream operator<<.
template <class T>
static std::string ValueToString(const T& value) {
std::stringstream ss;
ss << value;
return ss.str();
}
// A custom serialization class can be supplied by implementing the // A custom serialization class can be supplied by implementing the
// Writer interface and supplying a factory class to SetWriterFactoryCallback. // Writer interface and supplying a factory class to SetWriterFactoryCallback.
// Primarily used by Perfetto to write TracedValues directly into its proto // Primarily used by Perfetto to write TracedValues directly into its proto
...@@ -239,6 +231,14 @@ class BASE_EXPORT TracedValueJSON : public TracedValue { ...@@ -239,6 +231,14 @@ class BASE_EXPORT TracedValueJSON : public TracedValue {
std::string ToFormattedJSON() const; std::string ToFormattedJSON() const;
}; };
// Return std::string representation given by |value|'s ostream operator<<.
template <typename T>
std::string ValueToString(const T& value) {
std::stringstream ss;
ss << value;
return ss.str();
}
} // namespace trace_event } // namespace trace_event
} // namespace base } // namespace base
......
...@@ -16,7 +16,7 @@ namespace base { ...@@ -16,7 +16,7 @@ namespace base {
namespace trace_event { namespace trace_event {
TEST(TraceEventArgumentTest, ValueToString) { TEST(TraceEventArgumentTest, ValueToString) {
std::string zero = TracedValue::ValueToString(0); std::string zero = ValueToString(0);
EXPECT_EQ("0", zero); EXPECT_EQ("0", zero);
} }
......
...@@ -692,8 +692,8 @@ class Generator(generator.Generator): ...@@ -692,8 +692,8 @@ class Generator(generator.Generator):
if self._IsTypemappedKind(kind) or IsNativeOnlyKind(kind): if self._IsTypemappedKind(kind) or IsNativeOnlyKind(kind):
yield '%s->SetInteger("%s", static_cast<int>(%s));' % value_name_cppname yield '%s->SetInteger("%s", static_cast<int>(%s));' % value_name_cppname
else: else:
yield '%s->SetString("%s", base::trace_event::'\ yield '%s->SetString("%s", base::trace_event::ValueToString(%s));'\
'TracedValue::ValueToString(%s));' % value_name_cppname % value_name_cppname
return return
if mojom.IsStringKind(kind): if mojom.IsStringKind(kind):
if self.for_blink: if self.for_blink:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment