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 "chrome/browser/metrics/plugin_metrics_provider.h" | 5 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 metrics::SystemProfileProto* system_profile_proto) { | 137 metrics::SystemProfileProto* system_profile_proto) { |
138 RecordCurrentStateIfPending(); | 138 RecordCurrentStateIfPending(); |
139 const base::ListValue* plugin_stats_list = local_state_->GetList( | 139 const base::ListValue* plugin_stats_list = local_state_->GetList( |
140 prefs::kStabilityPluginStats); | 140 prefs::kStabilityPluginStats); |
141 if (!plugin_stats_list) | 141 if (!plugin_stats_list) |
142 return; | 142 return; |
143 | 143 |
144 metrics::SystemProfileProto::Stability* stability = | 144 metrics::SystemProfileProto::Stability* stability = |
145 system_profile_proto->mutable_stability(); | 145 system_profile_proto->mutable_stability(); |
146 for (const auto& value : *plugin_stats_list) { | 146 for (const auto& value : *plugin_stats_list) { |
147 base::DictionaryValue* plugin_dict; | 147 const base::DictionaryValue* plugin_dict; |
148 if (!value->GetAsDictionary(&plugin_dict)) { | 148 if (!value.GetAsDictionary(&plugin_dict)) { |
149 NOTREACHED(); | 149 NOTREACHED(); |
150 continue; | 150 continue; |
151 } | 151 } |
152 | 152 |
153 // Note that this search is potentially a quadratic operation, but given the | 153 // Note that this search is potentially a quadratic operation, but given the |
154 // low number of plugins installed on a "reasonable" setup, this should be | 154 // low number of plugins installed on a "reasonable" setup, this should be |
155 // fine. | 155 // fine. |
156 // TODO(isherman): Verify that this does not show up as a hotspot in | 156 // TODO(isherman): Verify that this does not show up as a hotspot in |
157 // profiler runs. | 157 // profiler runs. |
158 const metrics::SystemProfileProto::Plugin* system_profile_plugin = NULL; | 158 const metrics::SystemProfileProto::Plugin* system_profile_plugin = NULL; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 local_state_->ClearPref(prefs::kStabilityPluginStats); | 203 local_state_->ClearPref(prefs::kStabilityPluginStats); |
204 } | 204 } |
205 | 205 |
206 // Saves plugin-related updates from the in-object buffer to Local State | 206 // Saves plugin-related updates from the in-object buffer to Local State |
207 // for retrieval next time we send a Profile log (generally next launch). | 207 // for retrieval next time we send a Profile log (generally next launch). |
208 void PluginMetricsProvider::RecordCurrentState() { | 208 void PluginMetricsProvider::RecordCurrentState() { |
209 ListPrefUpdate update(local_state_, prefs::kStabilityPluginStats); | 209 ListPrefUpdate update(local_state_, prefs::kStabilityPluginStats); |
210 base::ListValue* plugins = update.Get(); | 210 base::ListValue* plugins = update.Get(); |
211 DCHECK(plugins); | 211 DCHECK(plugins); |
212 | 212 |
213 for (const auto& value : *plugins) { | 213 for (auto& value : *plugins) { |
214 base::DictionaryValue* plugin_dict; | 214 base::DictionaryValue* plugin_dict; |
215 if (!value->GetAsDictionary(&plugin_dict)) { | 215 if (!value.GetAsDictionary(&plugin_dict)) { |
216 NOTREACHED(); | 216 NOTREACHED(); |
217 continue; | 217 continue; |
218 } | 218 } |
219 | 219 |
220 base::string16 plugin_name; | 220 base::string16 plugin_name; |
221 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); | 221 plugin_dict->GetString(prefs::kStabilityPluginName, &plugin_name); |
222 if (plugin_name.empty()) { | 222 if (plugin_name.empty()) { |
223 NOTREACHED(); | 223 NOTREACHED(); |
224 continue; | 224 continue; |
225 } | 225 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 377 } |
378 | 378 |
379 bool PluginMetricsProvider::RecordCurrentStateIfPending() { | 379 bool PluginMetricsProvider::RecordCurrentStateIfPending() { |
380 if (!weak_ptr_factory_.HasWeakPtrs()) | 380 if (!weak_ptr_factory_.HasWeakPtrs()) |
381 return false; | 381 return false; |
382 | 382 |
383 weak_ptr_factory_.InvalidateWeakPtrs(); | 383 weak_ptr_factory_.InvalidateWeakPtrs(); |
384 RecordCurrentState(); | 384 RecordCurrentState(); |
385 return true; | 385 return true; |
386 } | 386 } |
OLD | NEW |