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

Side by Side Diff: chrome/browser/metrics/plugin_metrics_provider.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 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 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 <string> 10 #include <string>
11 #include <utility>
10 12
11 #include "base/stl_util.h" 13 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/plugins/plugin_prefs.h" 18 #include "chrome/browser/plugins/plugin_prefs.h"
17 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "components/metrics/proto/system_profile.pb.h" 21 #include "components/metrics/proto/system_profile.pb.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Now go through and add dictionaries for plugins that didn't already have 263 // Now go through and add dictionaries for plugins that didn't already have
262 // reports in Local State. 264 // reports in Local State.
263 for (auto cache_iter = child_process_stats_buffer_.begin(); 265 for (auto cache_iter = child_process_stats_buffer_.begin();
264 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) { 266 cache_iter != child_process_stats_buffer_.end(); ++cache_iter) {
265 ChildProcessStats stats = cache_iter->second; 267 ChildProcessStats stats = cache_iter->second;
266 268
267 // Insert only plugins information into the plugins list. 269 // Insert only plugins information into the plugins list.
268 if (!IsPluginProcess(stats.process_type)) 270 if (!IsPluginProcess(stats.process_type))
269 continue; 271 continue;
270 272
271 base::DictionaryValue* plugin_dict = new base::DictionaryValue; 273 std::unique_ptr<base::DictionaryValue> plugin_dict(
274 new base::DictionaryValue);
272 275
273 plugin_dict->SetString(prefs::kStabilityPluginName, cache_iter->first); 276 plugin_dict->SetString(prefs::kStabilityPluginName, cache_iter->first);
274 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 277 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches,
275 stats.process_launches); 278 stats.process_launches);
276 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 279 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes,
277 stats.process_crashes); 280 stats.process_crashes);
278 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 281 plugin_dict->SetInteger(prefs::kStabilityPluginInstances,
279 stats.instances); 282 stats.instances);
280 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 283 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors,
281 stats.loading_errors); 284 stats.loading_errors);
282 plugins->Append(plugin_dict); 285 plugins->Append(std::move(plugin_dict));
283 } 286 }
284 child_process_stats_buffer_.clear(); 287 child_process_stats_buffer_.clear();
285 } 288 }
286 289
287 void PluginMetricsProvider::LogPluginLoadingError( 290 void PluginMetricsProvider::LogPluginLoadingError(
288 const base::FilePath& plugin_path) { 291 const base::FilePath& plugin_path) {
289 content::WebPluginInfo plugin; 292 content::WebPluginInfo plugin;
290 bool success = 293 bool success =
291 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path, 294 content::PluginService::GetInstance()->GetPluginInfoByPath(plugin_path,
292 &plugin); 295 &plugin);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 377 }
375 378
376 bool PluginMetricsProvider::RecordCurrentStateIfPending() { 379 bool PluginMetricsProvider::RecordCurrentStateIfPending() {
377 if (!weak_ptr_factory_.HasWeakPtrs()) 380 if (!weak_ptr_factory_.HasWeakPtrs())
378 return false; 381 return false;
379 382
380 weak_ptr_factory_.InvalidateWeakPtrs(); 383 weak_ptr_factory_.InvalidateWeakPtrs();
381 RecordCurrentState(); 384 RecordCurrentState();
382 return true; 385 return true;
383 } 386 }
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_galleries_test_util.cc ('k') | chrome/browser/net/predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698