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

Unified Diff: ui/events/latency_info.cc

Issue 1898033003: Revert https://codereview.chromium.org/1871233002 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « ui/events/latency_info.h ('k') | ui/events/latency_info.dot » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/latency_info.cc
diff --git a/ui/latency_info/latency_info.cc b/ui/events/latency_info.cc
similarity index 81%
rename from ui/latency_info/latency_info.cc
rename to ui/events/latency_info.cc
index 66e374838aa0ab3f44696cc6ff52f7aa13f9c5cd..b5d99547465c4dbc0a3e7fcfd5ad049572e5ea5c 100644
--- a/ui/latency_info/latency_info.cc
+++ b/ui/events/latency_info.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/latency_info/latency_info.h"
+#include "ui/events/latency_info.h"
#include <stddef.h>
@@ -20,9 +20,7 @@ namespace {
const size_t kMaxLatencyInfoNumber = 100;
const char* GetComponentName(ui::LatencyComponentType type) {
-#define CASE_TYPE(t) \
- case ui::t: \
- return #t
+#define CASE_TYPE(t) case ui::t: return #t
switch (type) {
CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT);
CASE_TYPE(LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT);
@@ -106,7 +104,8 @@ LatencyInfoTracedValue::FromValue(std::unique_ptr<base::Value> value) {
new LatencyInfoTracedValue(value.release()));
}
-LatencyInfoTracedValue::~LatencyInfoTracedValue() {}
+LatencyInfoTracedValue::~LatencyInfoTracedValue() {
+}
void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const {
std::string tmp;
@@ -115,28 +114,32 @@ void LatencyInfoTracedValue::AppendAsTraceFormat(std::string* out) const {
}
LatencyInfoTracedValue::LatencyInfoTracedValue(base::Value* value)
- : value_(value) {}
+ : value_(value) {
+}
const char kTraceCategoriesForAsyncEvents[] = "benchmark,latencyInfo";
struct LatencyInfoEnabledInitializer {
- LatencyInfoEnabledInitializer()
- : latency_info_enabled(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
- kTraceCategoriesForAsyncEvents)) {}
+ LatencyInfoEnabledInitializer() :
+ latency_info_enabled(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
+ kTraceCategoriesForAsyncEvents)) {
+ }
const unsigned char* latency_info_enabled;
};
static base::LazyInstance<LatencyInfoEnabledInitializer>::Leaky
- g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER;
+ g_latency_info_enabled = LAZY_INSTANCE_INITIALIZER;
} // namespace
namespace ui {
-LatencyInfo::InputCoordinate::InputCoordinate() : x(0), y(0) {}
+LatencyInfo::InputCoordinate::InputCoordinate() : x(0), y(0) {
+}
-LatencyInfo::InputCoordinate::InputCoordinate(float x, float y) : x(x), y(y) {}
+LatencyInfo::InputCoordinate::InputCoordinate(float x, float y) : x(x), y(y) {
+}
LatencyInfo::LatencyInfo()
: input_coordinates_size_(0),
@@ -159,7 +162,8 @@ bool LatencyInfo::Verify(const std::vector<LatencyInfo>& latency_info,
LOG(ERROR) << referring_msg << ", LatencyInfo vector size "
<< latency_info.size() << " is too big.";
TRACE_EVENT_INSTANT1("input,benchmark", "LatencyInfo::Verify Fails",
- TRACE_EVENT_SCOPE_GLOBAL, "size", latency_info.size());
+ TRACE_EVENT_SCOPE_GLOBAL,
+ "size", latency_info.size());
return false;
}
return true;
@@ -169,9 +173,11 @@ void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other,
LatencyComponentType type) {
for (const auto& lc : other.latency_components()) {
if (lc.first.first == type) {
- AddLatencyNumberWithTimestamp(
- lc.first.first, lc.first.second, lc.second.sequence_number,
- lc.second.event_time, lc.second.event_count);
+ AddLatencyNumberWithTimestamp(lc.first.first,
+ lc.first.second,
+ lc.second.sequence_number,
+ lc.second.event_time,
+ lc.second.event_count);
}
}
}
@@ -179,9 +185,11 @@ void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other,
void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) {
for (const auto& lc : other.latency_components()) {
if (!FindLatency(lc.first.first, lc.first.second, NULL)) {
- AddLatencyNumberWithTimestamp(
- lc.first.first, lc.first.second, lc.second.sequence_number,
- lc.second.event_time, lc.second.event_count);
+ AddLatencyNumberWithTimestamp(lc.first.first,
+ lc.first.second,
+ lc.second.sequence_number,
+ lc.second.event_time,
+ lc.second.event_count);
}
}
}
@@ -235,9 +243,12 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
// not when we actually issue the ASYNC_BEGIN trace event.
LatencyComponent begin_component;
int64_t ts = 0;
- if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
+ if (FindLatency(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
+ 0,
&begin_component) ||
- FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, &begin_component)) {
+ FindLatency(INPUT_EVENT_LATENCY_UI_COMPONENT,
+ 0,
+ &begin_component)) {
ts = begin_component.event_time.ToInternalValue();
} else {
ts = base::TimeTicks::Now().ToInternalValue();
@@ -251,13 +262,17 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
}
TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(
- kTraceCategoriesForAsyncEvents, trace_name_.c_str(),
- TRACE_ID_DONT_MANGLE(trace_id_), ts);
+ kTraceCategoriesForAsyncEvents,
+ trace_name_.c_str(),
+ TRACE_ID_DONT_MANGLE(trace_id_),
+ ts);
}
- TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow",
+ TRACE_EVENT_WITH_FLOW1("input,benchmark",
+ "LatencyInfo.Flow",
TRACE_ID_DONT_MANGLE(trace_id_),
- TRACE_EVENT_FLAG_FLOW_OUT, "trace_id", trace_id_);
+ TRACE_EVENT_FLAG_FLOW_OUT,
+ "trace_id", trace_id_);
}
LatencyMap::key_type key = std::make_pair(component, id);
@@ -266,15 +281,15 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
LatencyComponent info = {component_sequence_number, time, event_count};
latency_components_[key] = info;
} else {
- it->second.sequence_number =
- std::max(component_sequence_number, it->second.sequence_number);
+ it->second.sequence_number = std::max(component_sequence_number,
+ it->second.sequence_number);
uint32_t new_count = event_count + it->second.event_count;
if (event_count > 0 && new_count != 0) {
// Do a weighted average, so that the new event_time is the average of
// the times of events currently in this structure with the time passed
// into this method.
- it->second.event_time +=
- (time - it->second.event_time) * event_count / new_count;
+ it->second.event_time += (time - it->second.event_time) * event_count /
+ new_count;
it->second.event_count = new_count;
}
}
@@ -285,13 +300,15 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
terminated_ = true;
if (*latency_info_enabled) {
- TRACE_EVENT_COPY_ASYNC_END2(
- kTraceCategoriesForAsyncEvents, trace_name_.c_str(),
- TRACE_ID_DONT_MANGLE(trace_id_), "data", AsTraceableData(),
- "coordinates", CoordinatesAsTraceableData());
+ TRACE_EVENT_COPY_ASYNC_END2(kTraceCategoriesForAsyncEvents,
+ trace_name_.c_str(),
+ TRACE_ID_DONT_MANGLE(trace_id_),
+ "data", AsTraceableData(),
+ "coordinates", CoordinatesAsTraceableData());
}
- TRACE_EVENT_WITH_FLOW0("input,benchmark", "LatencyInfo.Flow",
+ TRACE_EVENT_WITH_FLOW0("input,benchmark",
+ "LatencyInfo.Flow",
TRACE_ID_DONT_MANGLE(trace_id_),
TRACE_EVENT_FLAG_FLOW_IN);
}
@@ -306,9 +323,11 @@ LatencyInfo::AsTraceableData() {
new base::DictionaryValue());
component_info->SetDouble("comp_id", static_cast<double>(lc.first.second));
component_info->SetDouble(
- "time", static_cast<double>(lc.second.event_time.ToInternalValue()));
+ "time",
+ static_cast<double>(lc.second.event_time.ToInternalValue()));
component_info->SetDouble("count", lc.second.event_count);
- component_info->SetDouble("sequence_number", lc.second.sequence_number);
+ component_info->SetDouble("sequence_number",
+ lc.second.sequence_number);
record_data->Set(GetComponentName(lc.first.first),
std::move(component_info));
}
@@ -332,8 +351,8 @@ LatencyInfo::CoordinatesAsTraceableData() {
bool LatencyInfo::FindLatency(LatencyComponentType type,
int64_t id,
LatencyComponent* output) const {
- LatencyMap::const_iterator it =
- latency_components_.find(std::make_pair(type, id));
+ LatencyMap::const_iterator it = latency_components_.find(
+ std::make_pair(type, id));
if (it == latency_components_.end())
return false;
if (output)
« no previous file with comments | « ui/events/latency_info.h ('k') | ui/events/latency_info.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698