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

Side by Side Diff: components/arc/metrics/arc_metrics_service.cc

Issue 2495913002: arc: Convert more Mojo types to STL (Closed)
Patch Set: Rebased to ToT Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/arc/metrics/arc_metrics_service.h" 5 #include "components/arc/metrics/arc_metrics_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 arc_bridge_service()->process()->GetInstanceForMethod( 80 arc_bridge_service()->process()->GetInstanceForMethod(
81 "RequestProcessList"); 81 "RequestProcessList");
82 if (!process_instance) 82 if (!process_instance)
83 return; 83 return;
84 VLOG(2) << "RequestProcessList"; 84 VLOG(2) << "RequestProcessList";
85 process_instance->RequestProcessList(base::Bind( 85 process_instance->RequestProcessList(base::Bind(
86 &ArcMetricsService::ParseProcessList, weak_ptr_factory_.GetWeakPtr())); 86 &ArcMetricsService::ParseProcessList, weak_ptr_factory_.GetWeakPtr()));
87 } 87 }
88 88
89 void ArcMetricsService::ParseProcessList( 89 void ArcMetricsService::ParseProcessList(
90 mojo::Array<mojom::RunningAppProcessInfoPtr> processes) { 90 std::vector<mojom::RunningAppProcessInfoPtr> processes) {
91 int running_app_count = 0; 91 int running_app_count = 0;
92 for (const auto& process : processes) { 92 for (const auto& process : processes) {
93 const mojo::String& process_name = process->process_name; 93 const std::string& process_name = process->process_name;
94 const mojom::ProcessState& process_state = process->process_state; 94 const mojom::ProcessState& process_state = process->process_state;
95 95
96 // Processes like the ARC launcher and intent helper are always running 96 // Processes like the ARC launcher and intent helper are always running
97 // and not counted as apps running by users. With the same reasoning, 97 // and not counted as apps running by users. With the same reasoning,
98 // GMS (Google Play Services) and its related processes are skipped as 98 // GMS (Google Play Services) and its related processes are skipped as
99 // well. The process_state check below filters out system processes, 99 // well. The process_state check below filters out system processes,
100 // services, apps that are cached because they've run before. 100 // services, apps that are cached because they've run before.
101 if (base::StartsWith(process_name.get(), kArcProcessNamePrefix, 101 if (base::StartsWith(process_name, kArcProcessNamePrefix,
102 base::CompareCase::SENSITIVE) || 102 base::CompareCase::SENSITIVE) ||
103 base::StartsWith(process_name.get(), kGmsProcessNamePrefix, 103 base::StartsWith(process_name, kGmsProcessNamePrefix,
104 base::CompareCase::SENSITIVE) || 104 base::CompareCase::SENSITIVE) ||
105 process_state != mojom::ProcessState::TOP) { 105 process_state != mojom::ProcessState::TOP) {
106 VLOG(2) << "Skipped " << process_name << " " << process_state; 106 VLOG(2) << "Skipped " << process_name << " " << process_state;
107 } else { 107 } else {
108 ++running_app_count; 108 ++running_app_count;
109 } 109 }
110 } 110 }
111 111
112 UMA_HISTOGRAM_COUNTS_100("Arc.AppCount", running_app_count); 112 UMA_HISTOGRAM_COUNTS_100("Arc.AppCount", running_app_count);
113 } 113 }
(...skipping 17 matching lines...) Expand all
131 if (!binding_.is_bound()) { 131 if (!binding_.is_bound()) {
132 mojom::MetricsHostPtr host_ptr; 132 mojom::MetricsHostPtr host_ptr;
133 binding_.Bind(mojo::GetProxy(&host_ptr)); 133 binding_.Bind(mojo::GetProxy(&host_ptr));
134 instance->Init(std::move(host_ptr)); 134 instance->Init(std::move(host_ptr));
135 } 135 }
136 arc_start_time_ = arc_start_time; 136 arc_start_time_ = arc_start_time;
137 VLOG(2) << "ARC start @" << arc_start_time_; 137 VLOG(2) << "ARC start @" << arc_start_time_;
138 } 138 }
139 139
140 void ArcMetricsService::ReportBootProgress( 140 void ArcMetricsService::ReportBootProgress(
141 mojo::Array<mojom::BootProgressEventPtr> events) { 141 std::vector<mojom::BootProgressEventPtr> events) {
142 DCHECK(CalledOnValidThread()); 142 DCHECK(CalledOnValidThread());
143 int64_t arc_start_time_in_ms = 143 int64_t arc_start_time_in_ms =
144 (arc_start_time_ - base::TimeTicks()).InMilliseconds(); 144 (arc_start_time_ - base::TimeTicks()).InMilliseconds();
145 for (const auto& event : events) { 145 for (const auto& event : events) {
146 VLOG(2) << "Report boot progress event:" << event->event << "@" 146 VLOG(2) << "Report boot progress event:" << event->event << "@"
147 << event->uptimeMillis; 147 << event->uptimeMillis;
148 std::string title = "Arc." + event->event.get(); 148 std::string title = "Arc." + event->event;
149 base::TimeDelta elapsed_time = base::TimeDelta::FromMilliseconds( 149 base::TimeDelta elapsed_time = base::TimeDelta::FromMilliseconds(
150 event->uptimeMillis - arc_start_time_in_ms); 150 event->uptimeMillis - arc_start_time_in_ms);
151 // Note: This leaks memory, which is expected behavior. 151 // Note: This leaks memory, which is expected behavior.
152 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 152 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
153 title, base::TimeDelta::FromMilliseconds(1), 153 title, base::TimeDelta::FromMilliseconds(1),
154 base::TimeDelta::FromSeconds(30), 50, 154 base::TimeDelta::FromSeconds(30), 50,
155 base::HistogramBase::kUmaTargetedHistogramFlag); 155 base::HistogramBase::kUmaTargetedHistogramFlag);
156 histogram->AddTime(elapsed_time); 156 histogram->AddTime(elapsed_time);
157 if (event->event.get().compare(kBootProgressEnableScreen) == 0) 157 if (event->event.compare(kBootProgressEnableScreen) == 0)
158 UMA_HISTOGRAM_CUSTOM_TIMES("Arc.AndroidBootTime", elapsed_time, 158 UMA_HISTOGRAM_CUSTOM_TIMES("Arc.AndroidBootTime", elapsed_time,
159 base::TimeDelta::FromMilliseconds(1), 159 base::TimeDelta::FromMilliseconds(1),
160 base::TimeDelta::FromSeconds(30), 50); 160 base::TimeDelta::FromSeconds(30), 50);
161 } 161 }
162 } 162 }
163 163
164 ArcMetricsService::ProcessObserver::ProcessObserver( 164 ArcMetricsService::ProcessObserver::ProcessObserver(
165 ArcMetricsService* arc_metrics_service) 165 ArcMetricsService* arc_metrics_service)
166 : arc_metrics_service_(arc_metrics_service) {} 166 : arc_metrics_service_(arc_metrics_service) {}
167 167
168 ArcMetricsService::ProcessObserver::~ProcessObserver() = default; 168 ArcMetricsService::ProcessObserver::~ProcessObserver() = default;
169 169
170 void ArcMetricsService::ProcessObserver::OnInstanceReady() { 170 void ArcMetricsService::ProcessObserver::OnInstanceReady() {
171 arc_metrics_service_->OnProcessInstanceReady(); 171 arc_metrics_service_->OnProcessInstanceReady();
172 } 172 }
173 173
174 void ArcMetricsService::ProcessObserver::OnInstanceClosed() { 174 void ArcMetricsService::ProcessObserver::OnInstanceClosed() {
175 arc_metrics_service_->OnProcessInstanceClosed(); 175 arc_metrics_service_->OnProcessInstanceClosed();
176 } 176 }
177 177
178 } // namespace arc 178 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/metrics/arc_metrics_service.h ('k') | components/arc/obb_mounter/arc_obb_mounter_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698