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

Side by Side Diff: components/metrics/profiler/profiler_metrics_provider.cc

Issue 1640223002: profiler: cleanup unused alternate_timer code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: doc Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « base/tracked_objects_unittest.cc ('k') | tools/gn/bootstrap/bootstrap.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/profiler/profiler_metrics_provider.h" 5 #include "components/metrics/profiler/profiler_metrics_provider.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ProfilerMetricsProvider::ProfilerMetricsProvider( 78 ProfilerMetricsProvider::ProfilerMetricsProvider(
79 const base::Callback<bool(void)>& cellular_callback) 79 const base::Callback<bool(void)>& cellular_callback)
80 : cellular_callback_(cellular_callback) { 80 : cellular_callback_(cellular_callback) {
81 } 81 }
82 82
83 ProfilerMetricsProvider::~ProfilerMetricsProvider() { 83 ProfilerMetricsProvider::~ProfilerMetricsProvider() {
84 } 84 }
85 85
86 void ProfilerMetricsProvider::ProvideGeneralMetrics( 86 void ProfilerMetricsProvider::ProvideGeneralMetrics(
87 ChromeUserMetricsExtension* uma_proto) { 87 ChromeUserMetricsExtension* uma_proto) {
88 DCHECK_EQ(tracked_objects::TIME_SOURCE_TYPE_WALL_TIME,
89 tracked_objects::GetTimeSourceType());
90
91 DCHECK_EQ(0, uma_proto->profiler_event_size()); 88 DCHECK_EQ(0, uma_proto->profiler_event_size());
92 89
93 for (auto& event : profiler_events_cache_) { 90 for (auto& event : profiler_events_cache_) {
94 uma_proto->add_profiler_event()->Swap(&event.second); 91 uma_proto->add_profiler_event()->Swap(&event.second);
95 } 92 }
96 93
97 profiler_events_cache_.clear(); 94 profiler_events_cache_.clear();
98 } 95 }
99 96
100 void ProfilerMetricsProvider::RecordProfilerData( 97 void ProfilerMetricsProvider::RecordProfilerData(
101 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, 98 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase,
102 base::ProcessId process_id, 99 base::ProcessId process_id,
103 ProfilerEventProto::TrackedObject::ProcessType process_type, 100 ProfilerEventProto::TrackedObject::ProcessType process_type,
104 int profiling_phase, 101 int profiling_phase,
105 base::TimeDelta phase_start, 102 base::TimeDelta phase_start,
106 base::TimeDelta phase_finish, 103 base::TimeDelta phase_finish,
107 const ProfilerEvents& past_events) { 104 const ProfilerEvents& past_events) {
108 // Omit profiler data on connections where it's likely to cost the user money 105 // Omit profiler data on connections where it's likely to cost the user money
109 // for us to upload it. 106 // for us to upload it.
110 if (IsCellularLogicEnabled()) 107 if (IsCellularLogicEnabled())
111 return; 108 return;
112 109
113 if (tracked_objects::GetTimeSourceType() !=
114 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) {
115 // We currently only support the default time source, wall clock time.
116 return;
117 }
118
119 const bool new_phase = !ContainsKey(profiler_events_cache_, profiling_phase); 110 const bool new_phase = !ContainsKey(profiler_events_cache_, profiling_phase);
120 ProfilerEventProto* profiler_event = &profiler_events_cache_[profiling_phase]; 111 ProfilerEventProto* profiler_event = &profiler_events_cache_[profiling_phase];
121 112
122 if (new_phase) { 113 if (new_phase) {
123 profiler_event->set_profile_version( 114 profiler_event->set_profile_version(
124 ProfilerEventProto::VERSION_SPLIT_PROFILE); 115 ProfilerEventProto::VERSION_SPLIT_PROFILE);
125 profiler_event->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); 116 profiler_event->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME);
126 profiler_event->set_profiling_start_ms(phase_start.InMilliseconds()); 117 profiler_event->set_profiling_start_ms(phase_start.InMilliseconds());
127 profiler_event->set_profiling_finish_ms(phase_finish.InMilliseconds()); 118 profiler_event->set_profiling_finish_ms(phase_finish.InMilliseconds());
128 for (const auto& event : past_events) { 119 for (const auto& event : past_events) {
129 profiler_event->add_past_session_event(event); 120 profiler_event->add_past_session_event(event);
130 } 121 }
131 } 122 }
132 123
133 WriteProfilerData(process_data_phase, process_id, process_type, 124 WriteProfilerData(process_data_phase, process_id, process_type,
134 profiler_event); 125 profiler_event);
135 } 126 }
136 127
137 bool ProfilerMetricsProvider::IsCellularLogicEnabled() { 128 bool ProfilerMetricsProvider::IsCellularLogicEnabled() {
138 if (cellular_callback_.is_null()) 129 if (cellular_callback_.is_null())
139 return false; 130 return false;
140 131
141 return cellular_callback_.Run(); 132 return cellular_callback_.Run();
142 } 133 }
143 134
144 } // namespace metrics 135 } // namespace metrics
OLDNEW
« no previous file with comments | « base/tracked_objects_unittest.cc ('k') | tools/gn/bootstrap/bootstrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698