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

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

Issue 2906503003: ARC: Add BootType parameter to ReportBootProgress() in metrics.mojom (Closed)
Patch Set: Created 3 years, 6 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
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"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/session_manager_client.h" 14 #include "chromeos/dbus/session_manager_client.h"
15 #include "components/arc/arc_bridge_service.h" 15 #include "components/arc/arc_bridge_service.h"
16 16
17 #define RECORD_ARC_UMA(suffix, elapsed_time, max_seconds) \
18 do { \
19 UMA_HISTOGRAM_CUSTOM_TIMES("Arc.AndroidBootTime" suffix, (elapsed_time), \
cywang 2017/05/25 04:26:06 You seem to use "UNKNOWN" for backward compatibili
Yusuke Sato 2017/05/25 05:57:07 So the current idea is to keep "Arc.AndroidBootTim
20 base::TimeDelta::FromMilliseconds(1), \
21 base::TimeDelta::FromSeconds(max_seconds), 50); \
22 } while (false)
23
24 namespace arc {
25
17 namespace { 26 namespace {
18 27
19 const int kRequestProcessListPeriodInMinutes = 5; 28 const int kRequestProcessListPeriodInMinutes = 5;
Luis Héctor Chávez 2017/05/25 16:00:35 not your fault, but can these be constexpr? Can th
Yusuke Sato 2017/05/25 18:21:13 Done.
20 const char kArcProcessNamePrefix[] = "org.chromium.arc."; 29 const char kArcProcessNamePrefix[] = "org.chromium.arc.";
21 const char kGmsProcessNamePrefix[] = "com.google.android.gms"; 30 const char kGmsProcessNamePrefix[] = "com.google.android.gms";
22 const char kBootProgressEnableScreen[] = "boot_progress_enable_screen"; 31 const char kBootProgressEnableScreen[] = "boot_progress_enable_screen";
23 32
33 std::string BootTypeToString(mojom::BootType boot_type) {
34 switch (boot_type) {
35 case mojom::BootType::UNKNOWN:
36 return ""; // for backward compatibility.
37 case mojom::BootType::FIRST_BOOT:
38 return ".FIRST_BOOT";
39 case mojom::BootType::FIRST_BOOT_AFTER_UPDATE:
40 return ".FIRST_BOOT_AFTER_UPDATE";
41 case mojom::BootType::REGULAR_BOOT:
42 return ".REGULAR_BOOT";
43 }
44 NOTREACHED();
45 return "";
46 }
47
24 } // namespace 48 } // namespace
25 49
26 namespace arc {
27
28 ArcMetricsService::ArcMetricsService(ArcBridgeService* bridge_service) 50 ArcMetricsService::ArcMetricsService(ArcBridgeService* bridge_service)
29 : ArcService(bridge_service), 51 : ArcService(bridge_service),
30 binding_(this), 52 binding_(this),
31 process_observer_(this), 53 process_observer_(this),
32 weak_ptr_factory_(this) { 54 weak_ptr_factory_(this) {
33 arc_bridge_service()->metrics()->AddObserver(this); 55 arc_bridge_service()->metrics()->AddObserver(this);
34 arc_bridge_service()->process()->AddObserver(&process_observer_); 56 arc_bridge_service()->process()->AddObserver(&process_observer_);
35 } 57 }
36 58
37 ArcMetricsService::~ArcMetricsService() { 59 ArcMetricsService::~ArcMetricsService() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 mojom::MetricsHostPtr host_ptr; 152 mojom::MetricsHostPtr host_ptr;
131 binding_.Bind(mojo::MakeRequest(&host_ptr)); 153 binding_.Bind(mojo::MakeRequest(&host_ptr));
132 instance->Init(std::move(host_ptr)); 154 instance->Init(std::move(host_ptr));
133 } 155 }
134 arc_start_time_ = arc_start_time; 156 arc_start_time_ = arc_start_time;
135 VLOG(2) << "ARC start @" << arc_start_time_; 157 VLOG(2) << "ARC start @" << arc_start_time_;
136 } 158 }
137 159
138 void ArcMetricsService::ReportBootProgress( 160 void ArcMetricsService::ReportBootProgress(
139 std::vector<mojom::BootProgressEventPtr> events) { 161 std::vector<mojom::BootProgressEventPtr> events) {
162 // TODO(yusukes): Replace this with NOTREACHED().
163 ReportBootProgressWithType(std::move(events), mojom::BootType::UNKNOWN);
164 }
165
166 void ArcMetricsService::ReportBootProgressWithType(
167 std::vector<mojom::BootProgressEventPtr> events,
168 mojom::BootType boot_type) {
140 DCHECK(CalledOnValidThread()); 169 DCHECK(CalledOnValidThread());
170 // TODO(yusukes): Return immediately with with LOG(ERROR) when |boot_type| is
171 // UNKNOWN. Once the container is updated, we'll never see the boot type.
141 int64_t arc_start_time_in_ms = 172 int64_t arc_start_time_in_ms =
142 (arc_start_time_ - base::TimeTicks()).InMilliseconds(); 173 (arc_start_time_ - base::TimeTicks()).InMilliseconds();
143 for (const auto& event : events) { 174 for (const auto& event : events) {
144 VLOG(2) << "Report boot progress event:" << event->event << "@" 175 VLOG(2) << "Report boot progress event:" << event->event << "@"
145 << event->uptimeMillis; 176 << event->uptimeMillis;
146 std::string title = "Arc." + event->event; 177 // TODO(yusukes): Always use 60.
178 const int max_seconds = (boot_type == mojom::BootType::UNKNOWN) ? 30 : 60;
179 std::string title = "Arc." + event->event + BootTypeToString(boot_type);
147 base::TimeDelta elapsed_time = base::TimeDelta::FromMilliseconds( 180 base::TimeDelta elapsed_time = base::TimeDelta::FromMilliseconds(
148 event->uptimeMillis - arc_start_time_in_ms); 181 event->uptimeMillis - arc_start_time_in_ms);
149 // Note: This leaks memory, which is expected behavior. 182 // Note: This leaks memory, which is expected behavior.
150 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 183 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
151 title, base::TimeDelta::FromMilliseconds(1), 184 title, base::TimeDelta::FromMilliseconds(1),
152 base::TimeDelta::FromSeconds(30), 50, 185 base::TimeDelta::FromSeconds(max_seconds), 50,
153 base::HistogramBase::kUmaTargetedHistogramFlag); 186 base::HistogramBase::kUmaTargetedHistogramFlag);
154 histogram->AddTime(elapsed_time); 187 histogram->AddTime(elapsed_time);
155 if (event->event.compare(kBootProgressEnableScreen) == 0) 188 if (event->event.compare(kBootProgressEnableScreen) != 0)
156 UMA_HISTOGRAM_CUSTOM_TIMES("Arc.AndroidBootTime", elapsed_time, 189 continue;
157 base::TimeDelta::FromMilliseconds(1), 190 switch (boot_type) {
cywang 2017/05/25 04:26:06 std::string name = "Arc.AndroidBootTime2" + BootTy
Yusuke Sato 2017/05/25 05:37:56 IIUC, the macro UMA_HISTOGRAM_CUSTOM_TIMES require
158 base::TimeDelta::FromSeconds(30), 50); 191 case mojom::BootType::UNKNOWN:
192 // For backward compatibility, use "".
193 // TODO(yusukes): Replace this with NOTREACHED().
194 RECORD_ARC_UMA("", elapsed_time, max_seconds);
195 break;
196 case mojom::BootType::FIRST_BOOT:
197 RECORD_ARC_UMA(".FIRST_BOOT", elapsed_time, max_seconds);
198 break;
199 case mojom::BootType::FIRST_BOOT_AFTER_UPDATE:
200 RECORD_ARC_UMA(".FIRST_BOOT_AFTER_UPDATE", elapsed_time, max_seconds);
201 break;
202 case mojom::BootType::REGULAR_BOOT:
203 RECORD_ARC_UMA(".REGULAR_BOOT", elapsed_time, max_seconds);
204 break;
205 }
159 } 206 }
160 } 207 }
161 208
162 ArcMetricsService::ProcessObserver::ProcessObserver( 209 ArcMetricsService::ProcessObserver::ProcessObserver(
163 ArcMetricsService* arc_metrics_service) 210 ArcMetricsService* arc_metrics_service)
164 : arc_metrics_service_(arc_metrics_service) {} 211 : arc_metrics_service_(arc_metrics_service) {}
165 212
166 ArcMetricsService::ProcessObserver::~ProcessObserver() = default; 213 ArcMetricsService::ProcessObserver::~ProcessObserver() = default;
167 214
168 void ArcMetricsService::ProcessObserver::OnInstanceReady() { 215 void ArcMetricsService::ProcessObserver::OnInstanceReady() {
169 arc_metrics_service_->OnProcessInstanceReady(); 216 arc_metrics_service_->OnProcessInstanceReady();
170 } 217 }
171 218
172 void ArcMetricsService::ProcessObserver::OnInstanceClosed() { 219 void ArcMetricsService::ProcessObserver::OnInstanceClosed() {
173 arc_metrics_service_->OnProcessInstanceClosed(); 220 arc_metrics_service_->OnProcessInstanceClosed();
174 } 221 }
175 222
176 } // namespace arc 223 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698