| Index: components/metrics/profiler/profiler_metrics_provider.cc
|
| diff --git a/components/metrics/profiler/profiler_metrics_provider.cc b/components/metrics/profiler/profiler_metrics_provider.cc
|
| index b10dc29a2e7bb706545fdab86f63b32e25398c4a..aa00c87d531382a38713d0c4a3ba2fce3bd22bfa 100644
|
| --- a/components/metrics/profiler/profiler_metrics_provider.cc
|
| +++ b/components/metrics/profiler/profiler_metrics_provider.cc
|
| @@ -14,8 +14,6 @@
|
| #include "components/variations/variations_associated_data.h"
|
| #include "content/public/common/process_type.h"
|
|
|
| -using tracked_objects::ProcessDataSnapshot;
|
| -
|
| namespace metrics {
|
|
|
| namespace {
|
| @@ -77,33 +75,31 @@ std::string NormalizeFileName(const std::string& file_name) {
|
| return offset != std::string::npos ? file_name.substr(offset + 1) : file_name;
|
| }
|
|
|
| -void WriteProfilerData(const ProcessDataSnapshot& profiler_data,
|
| - int process_type,
|
| - ProfilerEventProto* performance_profile) {
|
| - for (std::vector<tracked_objects::TaskSnapshot>::const_iterator it =
|
| - profiler_data.tasks.begin();
|
| - it != profiler_data.tasks.end();
|
| - ++it) {
|
| - const tracked_objects::DeathDataSnapshot& death_data = it->death_data;
|
| +void WriteProfilerData(
|
| + const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase,
|
| + int process_id,
|
| + int process_type,
|
| + ProfilerEventProto* performance_profile) {
|
| + for (const auto& i : process_data_phase.tasks) {
|
| + const tracked_objects::DeathDataSnapshot& death_data = i.death_data;
|
| ProfilerEventProto::TrackedObject* tracked_object =
|
| performance_profile->add_tracked_object();
|
| tracked_object->set_birth_thread_name_hash(
|
| - MetricsLog::Hash(MapThreadName(it->birth.thread_name)));
|
| + MetricsLog::Hash(MapThreadName(i.birth.thread_name)));
|
| tracked_object->set_exec_thread_name_hash(
|
| - MetricsLog::Hash(MapThreadName(it->death_thread_name)));
|
| + MetricsLog::Hash(MapThreadName(i.death_thread_name)));
|
| tracked_object->set_source_file_name_hash(
|
| - MetricsLog::Hash(NormalizeFileName(
|
| - it->birth.location.file_name)));
|
| + MetricsLog::Hash(NormalizeFileName(i.birth.location.file_name)));
|
| tracked_object->set_source_function_name_hash(
|
| - MetricsLog::Hash(it->birth.location.function_name));
|
| - tracked_object->set_source_line_number(it->birth.location.line_number);
|
| + MetricsLog::Hash(i.birth.location.function_name));
|
| + tracked_object->set_source_line_number(i.birth.location.line_number);
|
| tracked_object->set_exec_count(death_data.count);
|
| tracked_object->set_exec_time_total(death_data.run_duration_sum);
|
| tracked_object->set_exec_time_sampled(death_data.run_duration_sample);
|
| tracked_object->set_queue_time_total(death_data.queue_duration_sum);
|
| tracked_object->set_queue_time_sampled(death_data.queue_duration_sample);
|
| tracked_object->set_process_type(AsProtobufProcessType(process_type));
|
| - tracked_object->set_process_id(profiler_data.process_id);
|
| + tracked_object->set_process_id(process_id);
|
| }
|
| }
|
|
|
| @@ -117,12 +113,11 @@ bool IsCellularEnabledByExperiment() {
|
|
|
| } // namespace
|
|
|
| -ProfilerMetricsProvider::ProfilerMetricsProvider() : has_profiler_data_(false) {
|
| +ProfilerMetricsProvider::ProfilerMetricsProvider() {
|
| }
|
|
|
| ProfilerMetricsProvider::ProfilerMetricsProvider(
|
| - const base::Callback<void(bool*)>& cellular_callback)
|
| - : has_profiler_data_(false), cellular_callback_(cellular_callback) {
|
| + const base::Callback<void(bool*)>& cellular_callback) {
|
| }
|
|
|
| ProfilerMetricsProvider::~ProfilerMetricsProvider() {
|
| @@ -130,21 +125,26 @@ ProfilerMetricsProvider::~ProfilerMetricsProvider() {
|
|
|
| void ProfilerMetricsProvider::ProvideGeneralMetrics(
|
| ChromeUserMetricsExtension* uma_proto) {
|
| - if (!has_profiler_data_)
|
| - return;
|
| -
|
| DCHECK_EQ(tracked_objects::TIME_SOURCE_TYPE_WALL_TIME,
|
| tracked_objects::GetTimeSourceType());
|
|
|
| DCHECK_EQ(0, uma_proto->profiler_event_size());
|
| - ProfilerEventProto* profile = uma_proto->add_profiler_event();
|
| - profile->Swap(&profiler_event_cache_);
|
| - has_profiler_data_ = false;
|
| +
|
| + for (const auto& i : profiler_events_cache_) {
|
| + uma_proto->add_profiler_event()->CopyFrom(i.second);
|
| + }
|
| +
|
| + profiler_events_cache_.clear();
|
| }
|
|
|
| void ProfilerMetricsProvider::RecordProfilerData(
|
| - const tracked_objects::ProcessDataSnapshot& process_data,
|
| - int process_type) {
|
| + const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase,
|
| + int process_id,
|
| + int process_type,
|
| + int profiling_phase,
|
| + const base::TimeDelta& profiling_phase_start,
|
| + const base::TimeDelta& profiling_phase_finish,
|
| + const ProfilerEventsSet& past_profiler_events) {
|
| if (IsCellularConnection() && IsCellularEnabledByExperiment())
|
| return;
|
| if (tracked_objects::GetTimeSourceType() !=
|
| @@ -153,11 +153,25 @@ void ProfilerMetricsProvider::RecordProfilerData(
|
| return;
|
| }
|
|
|
| - has_profiler_data_ = true;
|
| - profiler_event_cache_.set_profile_version(
|
| - ProfilerEventProto::VERSION_STARTUP_PROFILE);
|
| - profiler_event_cache_.set_time_source(ProfilerEventProto::WALL_CLOCK_TIME);
|
| - WriteProfilerData(process_data, process_type, &profiler_event_cache_);
|
| + const bool new_phase = profiler_events_cache_.find(profiling_phase) ==
|
| + profiler_events_cache_.end();
|
| + ProfilerEventProto* profiler_event = &profiler_events_cache_[profiling_phase];
|
| +
|
| + if (new_phase) {
|
| + profiler_event->set_profile_version(
|
| + ProfilerEventProto::VERSION_SPLIT_PROFILE);
|
| + profiler_event->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME);
|
| + profiler_event->set_profiling_start_ms(
|
| + profiling_phase_start.InMilliseconds());
|
| + profiler_event->set_profiling_finish_ms(
|
| + profiling_phase_finish.InMilliseconds());
|
| + for (const auto& i : past_profiler_events) {
|
| + profiler_event->add_past_session_events(i);
|
| + }
|
| + }
|
| +
|
| + WriteProfilerData(process_data_phase, process_id, process_type,
|
| + profiler_event);
|
| }
|
|
|
| bool ProfilerMetricsProvider::IsCellularConnection() {
|
|
|