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

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

Issue 478753002: Readding null checks for the set of extensions returned by GetInstalledExtensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions_metrics_provider.h" 5 #include "chrome/browser/metrics/extensions_metrics_provider.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // The off-store metric includes information from all loaded profiles at the 187 // The off-store metric includes information from all loaded profiles at the
188 // time when this metric is generated. 188 // time when this metric is generated.
189 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); 189 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
190 for (size_t i = 0u; i < profiles.size() && state < OFF_STORE; ++i) { 190 for (size_t i = 0u; i < profiles.size() && state < OFF_STORE; ++i) {
191 extensions::InstallVerifier* verifier = 191 extensions::InstallVerifier* verifier =
192 extensions::ExtensionSystem::Get(profiles[i])->install_verifier(); 192 extensions::ExtensionSystem::Get(profiles[i])->install_verifier();
193 193
194 scoped_ptr<extensions::ExtensionSet> extensions( 194 scoped_ptr<extensions::ExtensionSet> extensions(
195 GetInstalledExtensions(profiles[i])); 195 GetInstalledExtensions(profiles[i]));
196 if (!extensions)
197 continue;
196 198
197 // Combine the state from each profile, always favoring the higher state as 199 // Combine the state from each profile, always favoring the higher state as
198 // defined by the order of ExtensionState. 200 // defined by the order of ExtensionState.
199 state = std::max(state, CheckForOffStore(*extensions.get(), *verifier)); 201 state = std::max(state, CheckForOffStore(*extensions.get(), *verifier));
200 } 202 }
201 203
202 system_profile->set_offstore_extensions_state(ExtensionStateAsProto(state)); 204 system_profile->set_offstore_extensions_state(ExtensionStateAsProto(state));
203 } 205 }
204 206
205 void ExtensionsMetricsProvider::ProvideOccupiedBucketMetric( 207 void ExtensionsMetricsProvider::ProvideOccupiedBucketMetric(
206 metrics::SystemProfileProto* system_profile) { 208 metrics::SystemProfileProto* system_profile) {
207 // UMA reports do not support multiple profiles, but extensions are installed 209 // UMA reports do not support multiple profiles, but extensions are installed
208 // per-profile. We return the extensions installed in the primary profile. 210 // per-profile. We return the extensions installed in the primary profile.
209 // In the future, we might consider reporting data about extensions in all 211 // In the future, we might consider reporting data about extensions in all
210 // profiles. 212 // profiles.
211 Profile* profile = GetMetricsProfile(); 213 Profile* profile = GetMetricsProfile();
212 214
213 scoped_ptr<extensions::ExtensionSet> extensions( 215 scoped_ptr<extensions::ExtensionSet> extensions(
214 GetInstalledExtensions(profile)); 216 GetInstalledExtensions(profile));
217 if (!extensions)
218 return;
215 219
216 const int client_key = GetClientID() % kExtensionListClientKeys; 220 const int client_key = GetClientID() % kExtensionListClientKeys;
217 221
218 std::set<int> buckets; 222 std::set<int> buckets;
219 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); 223 for (extensions::ExtensionSet::const_iterator it = extensions->begin();
220 it != extensions->end(); 224 it != extensions->end();
221 ++it) { 225 ++it) {
222 buckets.insert(HashExtension((*it)->id(), client_key)); 226 buckets.insert(HashExtension((*it)->id(), client_key));
223 } 227 }
224 228
225 for (std::set<int>::const_iterator it = buckets.begin(); it != buckets.end(); 229 for (std::set<int>::const_iterator it = buckets.begin(); it != buckets.end();
226 ++it) { 230 ++it) {
227 system_profile->add_occupied_extension_bucket(*it); 231 system_profile->add_occupied_extension_bucket(*it);
228 } 232 }
229 } 233 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698