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

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

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: rebased to catch up tot Created 4 years, 2 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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 this, &ArcMetricsService::RequestProcessList); 69 this, &ArcMetricsService::RequestProcessList);
70 } 70 }
71 71
72 void ArcMetricsService::OnProcessInstanceClosed() { 72 void ArcMetricsService::OnProcessInstanceClosed() {
73 VLOG(2) << "Stop updating process list."; 73 VLOG(2) << "Stop updating process list.";
74 timer_.Stop(); 74 timer_.Stop();
75 } 75 }
76 76
77 void ArcMetricsService::RequestProcessList() { 77 void ArcMetricsService::RequestProcessList() {
78 mojom::ProcessInstance* process_instance = 78 mojom::ProcessInstance* process_instance =
79 arc_bridge_service()->process()->instance(); 79 arc_bridge_service()->process()->GetInstanceForMethod(
80 if (!process_instance) { 80 "RequestProcessList");
81 LOG(ERROR) << "No process instance found before RequestProcessList"; 81 if (!process_instance)
82 return; 82 return;
83 }
84
85 VLOG(2) << "RequestProcessList"; 83 VLOG(2) << "RequestProcessList";
86 process_instance->RequestProcessList(base::Bind( 84 process_instance->RequestProcessList(base::Bind(
87 &ArcMetricsService::ParseProcessList, weak_ptr_factory_.GetWeakPtr())); 85 &ArcMetricsService::ParseProcessList, weak_ptr_factory_.GetWeakPtr()));
88 } 86 }
89 87
90 void ArcMetricsService::ParseProcessList( 88 void ArcMetricsService::ParseProcessList(
91 mojo::Array<arc::mojom::RunningAppProcessInfoPtr> processes) { 89 mojo::Array<arc::mojom::RunningAppProcessInfoPtr> processes) {
92 int running_app_count = 0; 90 int running_app_count = 0;
93 for (const auto& process : processes) { 91 for (const auto& process : processes) {
94 const mojo::String& process_name = process->process_name; 92 const mojo::String& process_name = process->process_name;
(...skipping 19 matching lines...) Expand all
114 } 112 }
115 113
116 void ArcMetricsService::OnArcStartTimeRetrieved( 114 void ArcMetricsService::OnArcStartTimeRetrieved(
117 bool success, 115 bool success,
118 base::TimeTicks arc_start_time) { 116 base::TimeTicks arc_start_time) {
119 DCHECK(CalledOnValidThread()); 117 DCHECK(CalledOnValidThread());
120 if (!success) { 118 if (!success) {
121 LOG(ERROR) << "Failed to retrieve ARC start timeticks."; 119 LOG(ERROR) << "Failed to retrieve ARC start timeticks.";
122 return; 120 return;
123 } 121 }
124 if (!arc_bridge_service()->metrics()->instance()) { 122 auto* instance =
125 LOG(ERROR) << "ARC metrics instance went away while retrieving start time."; 123 arc_bridge_service()->metrics()->GetInstanceForMethod("Init");
124 if (!instance)
126 return; 125 return;
127 }
128 126
129 // The binding of host interface is deferred until the ARC start time is 127 // The binding of host interface is deferred until the ARC start time is
130 // retrieved here because it prevents race condition of the ARC start 128 // retrieved here because it prevents race condition of the ARC start
131 // time availability in ReportBootProgress(). 129 // time availability in ReportBootProgress().
132 if (!binding_.is_bound()) { 130 if (!binding_.is_bound()) {
133 mojom::MetricsHostPtr host_ptr; 131 mojom::MetricsHostPtr host_ptr;
134 binding_.Bind(mojo::GetProxy(&host_ptr)); 132 binding_.Bind(mojo::GetProxy(&host_ptr));
135 arc_bridge_service()->metrics()->instance()->Init(std::move(host_ptr)); 133 instance->Init(std::move(host_ptr));
136 } 134 }
137 arc_start_time_ = arc_start_time; 135 arc_start_time_ = arc_start_time;
138 VLOG(2) << "ARC start @" << arc_start_time_; 136 VLOG(2) << "ARC start @" << arc_start_time_;
139 } 137 }
140 138
141 void ArcMetricsService::ReportBootProgress( 139 void ArcMetricsService::ReportBootProgress(
142 mojo::Array<arc::mojom::BootProgressEventPtr> events) { 140 mojo::Array<arc::mojom::BootProgressEventPtr> events) {
143 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
144 int64_t arc_start_time_in_ms = 142 int64_t arc_start_time_in_ms =
145 (arc_start_time_ - base::TimeTicks()).InMilliseconds(); 143 (arc_start_time_ - base::TimeTicks()).InMilliseconds();
(...skipping 24 matching lines...) Expand all
170 168
171 void ArcMetricsService::ProcessObserver::OnInstanceReady() { 169 void ArcMetricsService::ProcessObserver::OnInstanceReady() {
172 arc_metrics_service_->OnProcessInstanceReady(); 170 arc_metrics_service_->OnProcessInstanceReady();
173 } 171 }
174 172
175 void ArcMetricsService::ProcessObserver::OnInstanceClosed() { 173 void ArcMetricsService::ProcessObserver::OnInstanceClosed() {
176 arc_metrics_service_->OnProcessInstanceClosed(); 174 arc_metrics_service_->OnProcessInstanceClosed();
177 } 175 }
178 176
179 } // namespace arc 177 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698