| Index: components/metrics/call_stack_profile_metrics_provider.cc
|
| diff --git a/components/metrics/call_stack_profile_metrics_provider.cc b/components/metrics/call_stack_profile_metrics_provider.cc
|
| index 77b27e0ba9689113b9773970fde963cf39153cd9..9bd823b34e917b1793907a8f3fd118a5ef1c842e 100644
|
| --- a/components/metrics/call_stack_profile_metrics_provider.cc
|
| +++ b/components/metrics/call_stack_profile_metrics_provider.cc
|
| @@ -33,13 +33,14 @@ namespace metrics {
|
|
|
| namespace {
|
|
|
| -// Provide a mapping from the C++ "enum" definition of various process phases
|
| -// to the equivalent protobuf "enum" definition. This table-lookup conversion
|
| -// allows for the implementation to evolve and still be compatible with the
|
| -// protobuf -- even if there are ever more than 32 defined proto values, though
|
| -// never more than 32 could be in-use in a given C++ version of the code.
|
| +// Provide a mapping from the C++ "enum" definition of various process mile-
|
| +// stones to the equivalent protobuf "enum" definition. This table-lookup
|
| +// conversion allows for the implementation to evolve and still be compatible
|
| +// with the protobuf -- even if there are ever more than 32 defined proto
|
| +// values, though never more than 32 could be in-use in a given C++ version
|
| +// of the code.
|
| const ProcessPhase
|
| - kProtoPhases[CallStackProfileMetricsProvider::PHASES_MAX_VALUE] = {
|
| + kProtoPhases[CallStackProfileMetricsProvider::MILESTONES_MAX_VALUE] = {
|
| ProcessPhase::MAIN_LOOP_START,
|
| ProcessPhase::MAIN_NAVIGATION_START,
|
| ProcessPhase::MAIN_NAVIGATION_FINISHED,
|
| @@ -259,17 +260,18 @@ void CopySampleToProto(
|
| // protobuf uses a repeated field of individual values. Conversion tables
|
| // allow for arbitrary mapping, though no more than 32 in any given version
|
| // of the code.
|
| -void CopyAnnotationsToProto(uint32_t new_phases,
|
| +void CopyAnnotationsToProto(uint32_t new_milestones,
|
| CallStackProfile::Sample* sample_proto) {
|
| - for (size_t bit = 0; new_phases != 0 && bit < sizeof(new_phases) * 8; ++bit) {
|
| + for (size_t bit = 0; new_milestones != 0 && bit < sizeof(new_milestones) * 8;
|
| + ++bit) {
|
| const uint32_t flag = 1U << bit;
|
| - if (new_phases & flag) {
|
| + if (new_milestones & flag) {
|
| if (bit >= arraysize(kProtoPhases)) {
|
| NOTREACHED();
|
| continue;
|
| }
|
| sample_proto->add_process_phase(kProtoPhases[bit]);
|
| - new_phases ^= flag; // Bit is set so XOR will clear it.
|
| + new_milestones ^= flag; // Bit is set so XOR will clear it.
|
| }
|
| }
|
| }
|
| @@ -285,7 +287,7 @@ void CopyProfileToProto(
|
| if (ordering_spec == CallStackProfileParams::PRESERVE_ORDER) {
|
| // Collapse only consecutive repeated samples together.
|
| CallStackProfile::Sample* current_sample_proto = nullptr;
|
| - uint32_t phases = 0;
|
| + uint32_t milestones = 0;
|
| for (auto it = profile.samples.begin(); it != profile.samples.end(); ++it) {
|
| // Check if the sample is different than the previous one. Samples match
|
| // if the frame and all annotations are the same.
|
| @@ -293,9 +295,9 @@ void CopyProfileToProto(
|
| current_sample_proto = proto_profile->add_sample();
|
| CopySampleToProto(*it, profile.modules, current_sample_proto);
|
| current_sample_proto->set_count(1);
|
| - CopyAnnotationsToProto(it->process_phases & ~phases,
|
| + CopyAnnotationsToProto(it->process_milestones & ~milestones,
|
| current_sample_proto);
|
| - phases = it->process_phases;
|
| + milestones = it->process_milestones;
|
| } else {
|
| current_sample_proto->set_count(current_sample_proto->count() + 1);
|
| }
|
| @@ -303,7 +305,7 @@ void CopyProfileToProto(
|
| } else {
|
| // Collapse all repeated samples together.
|
| std::map<StackSamplingProfiler::Sample, int> sample_index;
|
| - uint32_t phases = 0;
|
| + uint32_t milestones = 0;
|
| for (auto it = profile.samples.begin(); it != profile.samples.end(); ++it) {
|
| // Check for a sample already seen. Samples match if the frame and all
|
| // annotations are the same.
|
| @@ -312,11 +314,12 @@ void CopyProfileToProto(
|
| CallStackProfile::Sample* sample_proto = proto_profile->add_sample();
|
| CopySampleToProto(*it, profile.modules, sample_proto);
|
| sample_proto->set_count(1);
|
| - CopyAnnotationsToProto(it->process_phases & ~phases, sample_proto);
|
| + CopyAnnotationsToProto(it->process_milestones & ~milestones,
|
| + sample_proto);
|
| sample_index.insert(
|
| std::make_pair(
|
| *it, static_cast<int>(proto_profile->sample().size()) - 1));
|
| - phases = it->process_phases;
|
| + milestones = it->process_milestones;
|
| } else {
|
| CallStackProfile::Sample* sample_proto =
|
| proto_profile->mutable_sample()->Mutable(location->second);
|
|
|