Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Unified Diff: third_party/WebKit/Source/platform/TraceEventCommon.h

Issue 1620673002: Remove Blink's ConvertableToTraceFormat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/TraceEventCommon.h
diff --git a/third_party/WebKit/Source/platform/TraceEventCommon.h b/third_party/WebKit/Source/platform/TraceEventCommon.h
index b2c919843003ea90f0380afe21ae9c3103f3ab97..06ef273f87bd9869da1584706d6c1f20ef4bc686 100644
--- a/third_party/WebKit/Source/platform/TraceEventCommon.h
+++ b/third_party/WebKit/Source/platform/TraceEventCommon.h
@@ -137,32 +137,33 @@
//
//
// Convertable notes:
-// Converting a large data type to a string can be costly. To help with this,
-// the trace framework provides an interface ConvertableToTraceFormat. If you
-// inherit from it and implement the AppendAsTraceFormat method the trace
-// framework will call back to your object to convert a trace output time. This
-// means, if the category for the event is disabled, the conversion will not
-// happen.
+// Unlike base's trace framework, no convertable support in Blink because of
+// the way we estimate tracing memory overhead. All objects passed to the
+// tracing framework should be allocated by malloc to calculate overhead
+// correctly, while many Blink objects use PartitionAlloc/Oilpan. Convertable
+// is an interface to avoid unnecessary conversion but if we allow to use
+// PartitionAlloc/Oilpan backed objects, overhead estimation could be wrong.
+// For structured objects, you can use TracedValue.
//
-// class MyData : public base::trace_event::ConvertableToTraceFormat {
+// class MyData {
// public:
// MyData() {}
-// void AppendAsTraceFormat(std::string* out) const override {
-// out->append("{\"foo\":1}");
+// PassRefPtr<TracedValue> toTracedValue() {
+// RefPtr<TracedValue> tracedValue = TracedValue::create();
+// tracedValue->setInteger("foo", 1);
+// tracedValue->beginArray("bar");
+// tracedValue->pushInteger(2);
+// tracedValue->pushInteger(3);
+// tracedValue->endArray();
+// return tracedValue.release();
// }
// private:
// ~MyData() override {}
-// DISALLOW_COPY_AND_ASSIGN(MyData);
// };
//
-// TRACE_EVENT1("foo", "bar", "data",
-// scoped_refptr<ConvertableToTraceFormat>(new MyData()));
+// TRACE_EVENT1("foo", "bar", "data", myData.toTracedValue());
//
-// The trace framework will take ownership if the passed pointer and it will
-// be free'd when the trace buffer is flushed.
-//
-// Note, we only do the conversion when the buffer is flushed, so the provided
-// data object should not be modified after it's passed to the trace framework.
+// The trace framework will take ownership.
//
//
// Thread Safety:

Powered by Google App Engine
This is Rietveld 408576698