| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ProfilerEventProto::TrackedObject::ProcessType process_type, | 100 ProfilerEventProto::TrackedObject::ProcessType process_type, |
| 101 int profiling_phase, | 101 int profiling_phase, |
| 102 base::TimeDelta phase_start, | 102 base::TimeDelta phase_start, |
| 103 base::TimeDelta phase_finish, | 103 base::TimeDelta phase_finish, |
| 104 const ProfilerEvents& past_events) { | 104 const ProfilerEvents& past_events) { |
| 105 // 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 |
| 106 // for us to upload it. | 106 // for us to upload it. |
| 107 if (IsCellularLogicEnabled()) | 107 if (IsCellularLogicEnabled()) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 const bool new_phase = !ContainsKey(profiler_events_cache_, profiling_phase); | 110 const bool new_phase = |
| 111 !base::ContainsKey(profiler_events_cache_, profiling_phase); |
| 111 ProfilerEventProto* profiler_event = &profiler_events_cache_[profiling_phase]; | 112 ProfilerEventProto* profiler_event = &profiler_events_cache_[profiling_phase]; |
| 112 | 113 |
| 113 if (new_phase) { | 114 if (new_phase) { |
| 114 profiler_event->set_profile_version( | 115 profiler_event->set_profile_version( |
| 115 ProfilerEventProto::VERSION_SPLIT_PROFILE); | 116 ProfilerEventProto::VERSION_SPLIT_PROFILE); |
| 116 profiler_event->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); | 117 profiler_event->set_time_source(ProfilerEventProto::WALL_CLOCK_TIME); |
| 117 profiler_event->set_profiling_start_ms(phase_start.InMilliseconds()); | 118 profiler_event->set_profiling_start_ms(phase_start.InMilliseconds()); |
| 118 profiler_event->set_profiling_finish_ms(phase_finish.InMilliseconds()); | 119 profiler_event->set_profiling_finish_ms(phase_finish.InMilliseconds()); |
| 119 for (const auto& event : past_events) { | 120 for (const auto& event : past_events) { |
| 120 profiler_event->add_past_session_event(event); | 121 profiler_event->add_past_session_event(event); |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 | 124 |
| 124 WriteProfilerData(process_data_phase, process_id, process_type, | 125 WriteProfilerData(process_data_phase, process_id, process_type, |
| 125 profiler_event); | 126 profiler_event); |
| 126 } | 127 } |
| 127 | 128 |
| 128 bool ProfilerMetricsProvider::IsCellularLogicEnabled() { | 129 bool ProfilerMetricsProvider::IsCellularLogicEnabled() { |
| 129 if (cellular_callback_.is_null()) | 130 if (cellular_callback_.is_null()) |
| 130 return false; | 131 return false; |
| 131 | 132 |
| 132 return cellular_callback_.Run(); | 133 return cellular_callback_.Run(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace metrics | 136 } // namespace metrics |
| OLD | NEW |