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

Unified Diff: ui/events/latency_info.cc

Issue 25022003: Report LatencyInfo through trace buffer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 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: ui/events/latency_info.cc
diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc
index 796f442ae6d953de923edf7a131048c4ad046e4c..6b04cd4a937f619a8d4bf325ce647ad5c14b841d 100644
--- a/ui/events/latency_info.cc
+++ b/ui/events/latency_info.cc
@@ -2,18 +2,87 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/json/json_writer.h"
+#include "base/strings/stringprintf.h"
#include "ui/events/latency_info.h"
#include <algorithm>
+namespace {
+const char* GetComponentName(ui::LatencyComponentType type) {
+#define CASE_TYPE(t) case ui::t: return #t
+ switch (type) {
+ CASE_TYPE(INPUT_EVENT_LATENCY_RWH_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_ACKED_MOUSE_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_ACKED_GESTURE_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT);
+ default:
+ DLOG(WARNING) << "Unhandled LatencyComponentType.\n";
+ break;
+ }
+#undef CASE_TYPE
+ return "unknown";
+}
+
+} // namespace
+
namespace ui {
+scoped_ptr<base::debug::ConvertableToTraceFormat>
+LatencyInfoTracedValue::FromValue(base::Value* value) {
+ LatencyInfoTracedValue* ptr = new LatencyInfoTracedValue(value);
+ scoped_ptr<LatencyInfoTracedValue> result(ptr);
+ return result.PassAs<base::debug::ConvertableToTraceFormat>();
+}
+
+LatencyInfoTracedValue::~LatencyInfoTracedValue() {
+}
+
+void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const {
+ std::string tmp;
+ base::JSONWriter::Write(value_.get(), &tmp);
+ *out += tmp;
+}
+
+LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value)
+ : value_(value) {
+}
+
LatencyInfo::LatencyInfo() {
}
LatencyInfo::~LatencyInfo() {
}
+void LatencyInfo::Report(LatencyComponentType terminal_component) {
nduca 2013/10/01 21:43:44 lets try putting the logic here inside the AddLate
Rick Byers 2013/10/03 13:12:41 It should be illegal to call Report more than once
Yufeng Shen (Slow to review) 2013/10/04 00:29:51 Done.
Yufeng Shen (Slow to review) 2013/10/04 00:29:51 Yes, added DCHECK to enforce that at most only one
+ AddLatencyNumber(terminal_component, 0, 0);
+ TRACE_EVENT_INSTANT1("benchmark",
nduca 2013/10/01 21:43:44 can you try to issue async_begin and async_end tra
Yufeng Shen (Slow to review) 2013/10/04 00:29:51 Yes, we can see the grey latency rect in tracing U
+ "LatencyInfo::IssueTraceEvent",
+ TRACE_EVENT_SCOPE_THREAD,
+ "data", AsTraceableData());
+}
+
+scoped_ptr<base::debug::ConvertableToTraceFormat>
+LatencyInfo::AsTraceableData() const {
+ scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
+ for (LatencyMap::const_iterator it = latency_components.begin();
+ it != latency_components.end();
+ ++it) {
+ record_data->SetString(
+ GetComponentName(it->first.first),
+ base::StringPrintf("%ld %ld %d",
nduca 2013/10/01 21:43:44 this should probably be another dict inside instad
Yufeng Shen (Slow to review) 2013/10/04 00:29:51 Done.
+ it->first.second,
+ it->second.event_time.ToInternalValue(),
+ it->second.event_count));
+ }
+ return LatencyInfoTracedValue::FromValue(record_data.release());
+}
+
void LatencyInfo::MergeWith(const LatencyInfo& other) {
for (LatencyMap::const_iterator it = other.latency_components.begin();
it != other.latency_components.end();

Powered by Google App Engine
This is Rietveld 408576698