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/extensions_metrics_provider.h" | 5 #include "chrome/browser/metrics/extensions_metrics_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // If there is a cached profile, reuse that. However, check that it is still | 141 // If there is a cached profile, reuse that. However, check that it is still |
142 // valid first. | 142 // valid first. |
143 if (cached_profile_ && profile_manager->IsValidProfile(cached_profile_)) | 143 if (cached_profile_ && profile_manager->IsValidProfile(cached_profile_)) |
144 return cached_profile_; | 144 return cached_profile_; |
145 | 145 |
146 // Find a suitable profile to use, and cache it so that we continue to report | 146 // Find a suitable profile to use, and cache it so that we continue to report |
147 // statistics on the same profile. We would simply use | 147 // statistics on the same profile. We would simply use |
148 // ProfileManager::GetLastUsedProfile(), except that that has the side effect | 148 // ProfileManager::GetLastUsedProfile(), except that that has the side effect |
149 // of creating a profile if it does not yet exist. | 149 // of creating a profile if it does not yet exist. |
150 cached_profile_ = profile_manager->GetProfileByPath( | 150 cached_profile_ = profile_manager->GetProfileByPath( |
151 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir())); | 151 profile_manager->GetLastUsedProfileDir()); |
152 if (cached_profile_) { | 152 if (cached_profile_) { |
153 // Ensure that the returned profile is not an incognito profile. | 153 // Ensure that the returned profile is not an incognito profile. |
154 cached_profile_ = cached_profile_->GetOriginalProfile(); | 154 cached_profile_ = cached_profile_->GetOriginalProfile(); |
155 } | 155 } |
156 return cached_profile_; | 156 return cached_profile_; |
157 } | 157 } |
158 | 158 |
159 scoped_ptr<extensions::ExtensionSet> | 159 scoped_ptr<extensions::ExtensionSet> |
160 ExtensionsMetricsProvider::GetInstalledExtensions(Profile* profile) { | 160 ExtensionsMetricsProvider::GetInstalledExtensions(Profile* profile) { |
161 if (profile) { | 161 if (profile) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 it != extensions->end(); | 226 it != extensions->end(); |
227 ++it) { | 227 ++it) { |
228 buckets.insert(HashExtension((*it)->id(), client_key)); | 228 buckets.insert(HashExtension((*it)->id(), client_key)); |
229 } | 229 } |
230 | 230 |
231 for (std::set<int>::const_iterator it = buckets.begin(); it != buckets.end(); | 231 for (std::set<int>::const_iterator it = buckets.begin(); it != buckets.end(); |
232 ++it) { | 232 ++it) { |
233 system_profile->add_occupied_extension_bucket(*it); | 233 system_profile->add_occupied_extension_bucket(*it); |
234 } | 234 } |
235 } | 235 } |
OLD | NEW |