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

Unified Diff: ui/latency_info/latency_info.cc

Issue 1871233002: Move LatencyInfo to ui/latency_info (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some more gyp issues 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/latency_info/latency_info.h ('k') | ui/latency_info/latency_info.dot » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/latency_info/latency_info.cc
diff --git a/ui/events/latency_info.cc b/ui/latency_info/latency_info.cc
similarity index 81%
rename from ui/events/latency_info.cc
rename to ui/latency_info/latency_info.cc
index 799279a6eba07871ebded6e8d7cef699f0e6f64b..56570eef1b73b517cb1f47a65b30d6fb403539a7 100644
--- a/ui/events/latency_info.cc
+++ b/ui/latency_info/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/events/latency_info.h"
+#include "ui/latency_info/latency_info.h"
#include <stddef.h>
@@ -20,7 +20,9 @@ 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,8 +108,7 @@ 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;
@@ -116,32 +117,28 @@ 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),
@@ -164,8 +161,7 @@ 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;
@@ -175,11 +171,9 @@ 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);
}
}
}
@@ -187,11 +181,9 @@ 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);
}
}
}
@@ -245,12 +237,9 @@ 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();
@@ -264,17 +253,13 @@ 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);
@@ -283,15 +268,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;
}
}
@@ -302,15 +287,13 @@ 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);
}
@@ -325,11 +308,9 @@ 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));
}
@@ -353,8 +334,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/latency_info/latency_info.h ('k') | ui/latency_info/latency_info.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698