Chromium Code Reviews
Description[Sync] Reimplement proto value conversions on top of field visitors.
Sync component can allocate nontrivial amounts of memory, and browser
memory team would like to add MemoryDumpProvider to track sync memory
usage.
While ~1/4 of all used memory comes from protobuf messages (see the bug),
there is no easy way to get memory usage of a proto message. All we can
do is to estimate on per-field basis. For that we need a way to enumerate
fields of a given proto.
Fortunately, proto_value_conversions.cc already has functions that go
through fields for all sync protos. The only problem is that those
functions (ProtoToValue) are tied to a specific purpose of generating
base::DictionaryValues.
This CL refactors field enumeration out of ProtoToValue functions so that
next CL could use that to estimate proto memory usage.
In particular, this CL:
1. Extracts field enumeration from ProtoToValue functions into
VisitProtoFields(visitor, proto) function templates.
2. Implements ToValueVisitor that uses VisitProtoFields() to convert
protos to base::DictionaryValues. ToValueVisitor also includes all
logic from ProtoToValue functions.
3. Reimplements ProtoToValue() functions on top of ToValueVisitor.
Additionally this CL renames functions that convert proto enums to strings
to better play with templates.
BUG=649065
Committed: https://crrev.com/05476f9a8e8c076a8752b549d14269a6eca006c1
Cr-Commit-Position: refs/heads/master@{#426655}
Patch Set 1 #Patch Set 2 : Minor tweaks #Patch Set 3 : Rebase #
Total comments: 2
Patch Set 4 : Address comments; fix MSVC build #Patch Set 5 : Rebase; fix damage; regenerate test data #Patch Set 6 : Remove temporary tests #Messages
Total messages: 24 (18 generated)
|