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

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

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 <string> 9 #include <string>
10 #include <utility>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "components/metrics/proto/system_profile.pb.h" 16 #include "components/metrics/proto/system_profile.pb.h"
16 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
17 #include "components/prefs/scoped_user_pref_update.h" 18 #include "components/prefs/scoped_user_pref_update.h"
18 #include "components/prefs/testing_pref_service.h" 19 #include "components/prefs/testing_pref_service.h"
19 #include "content/public/browser/child_process_data.h" 20 #include "content/public/browser/child_process_data.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 // Now set some plugin stability stats for p2 and verify they're recorded. 91 // Now set some plugin stability stats for p2 and verify they're recorded.
91 std::unique_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue); 92 std::unique_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue);
92 plugin_dict->SetString(prefs::kStabilityPluginName, "p2"); 93 plugin_dict->SetString(prefs::kStabilityPluginName, "p2");
93 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1); 94 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1);
94 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2); 95 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2);
95 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3); 96 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3);
96 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4); 97 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4);
97 { 98 {
98 ListPrefUpdate update(prefs(), prefs::kStabilityPluginStats); 99 ListPrefUpdate update(prefs(), prefs::kStabilityPluginStats);
99 update.Get()->Append(plugin_dict.release()); 100 update.Get()->Append(std::move(plugin_dict));
100 } 101 }
101 102
102 provider.ProvideStabilityMetrics(&system_profile); 103 provider.ProvideStabilityMetrics(&system_profile);
103 104
104 const metrics::SystemProfileProto_Stability& stability = 105 const metrics::SystemProfileProto_Stability& stability =
105 system_profile.stability(); 106 system_profile.stability();
106 ASSERT_EQ(1, stability.plugin_stability_size()); 107 ASSERT_EQ(1, stability.plugin_stability_size());
107 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); 108 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name());
108 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); 109 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename());
109 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); 110 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } else if (name == "p2") { 204 } else if (name == "p2") {
204 EXPECT_EQ(2, stability.plugin_stability(i).launch_count()); 205 EXPECT_EQ(2, stability.plugin_stability(i).launch_count());
205 EXPECT_EQ(2, stability.plugin_stability(i).crash_count()); 206 EXPECT_EQ(2, stability.plugin_stability(i).crash_count());
206 found++; 207 found++;
207 } else { 208 } else {
208 GTEST_FAIL() << "Unexpected plugin name : " << name; 209 GTEST_FAIL() << "Unexpected plugin name : " << name;
209 } 210 }
210 } 211 }
211 EXPECT_EQ(found, 2U); 212 EXPECT_EQ(found, 2U);
212 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698