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

Unified Diff: ui/events/mojo/latency_info_struct_traits.cc

Issue 2058633002: mojo::ArrayTraits: Add Support for Iterators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 4 years, 6 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/mojo/latency_info_struct_traits.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/mojo/latency_info_struct_traits.cc
diff --git a/ui/events/mojo/latency_info_struct_traits.cc b/ui/events/mojo/latency_info_struct_traits.cc
index f076162a4fd80e7651bb87d0e9c5643c92d07ae1..78705c2c16df602e03ef09aa395d44658c3a198a 100644
--- a/ui/events/mojo/latency_info_struct_traits.cc
+++ b/ui/events/mojo/latency_info_struct_traits.cc
@@ -236,30 +236,6 @@ bool StructTraits<ui::mojom::LatencyComponentId,
return true;
}
-void* StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::SetUpContext(
- const ui::LatencyInfo& info) {
- // TODO(fsamuel): It would be nice if we had IterableTraits.
- auto components = new mojo::Array<ui::mojom::LatencyComponentPairPtr>(
- info.latency_components().size());
- uint32_t i = 0;
- for (ui::LatencyInfo::LatencyMap::const_iterator
- it = info.latency_components().begin();
- it != info.latency_components().end(); ++it, ++i) {
- auto latency_component_pair = ui::mojom::LatencyComponentPair::New();
- latency_component_pair->key = it->first;
- latency_component_pair->value = it->second;
- (*components)[i] = std::move(latency_component_pair);
- }
- return components;
-}
-
-void StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::TearDownContext(
- const ui::LatencyInfo& info,
- void* context) {
- // static_cast to ensure destructor is called.
- delete static_cast<mojo::Array<ui::mojom::LatencyComponentPairPtr>*>(context);
-}
-
// static
const std::string&
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::trace_name(
@@ -267,15 +243,11 @@ StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::trace_name(
return info.trace_name_;
}
-// static
-mojo::Array<ui::mojom::LatencyComponentPairPtr>&
+const ui::LatencyInfo::LatencyMap&
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::latency_components(
- const ui::LatencyInfo& info,
- void* context) {
- return *static_cast<mojo::Array<ui::mojom::LatencyComponentPairPtr>*>(
- context);
+ const ui::LatencyInfo& info) {
+ return info.latency_components();
}
-
InputCoordinateArray
StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::input_coordinates(
const ui::LatencyInfo& info) {
@@ -304,6 +276,7 @@ bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::Read(
if (!data.ReadTraceName(&out->trace_name_))
return false;
+ // TODO(fsamuel): Figure out how to optimize deserialization.
mojo::Array<ui::mojom::LatencyComponentPairPtr> components;
if (!data.ReadLatencyComponents(&components))
return false;
« no previous file with comments | « ui/events/mojo/latency_info_struct_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698