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

Side by Side Diff: chrome/browser/extensions/installed_loader.cc

Issue 959513002: Refactor Extension initialization logic. Add tracing and additional histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yoz comments Created 5 years, 9 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
« no previous file with comments | « chrome/browser/extensions/installed_loader.h ('k') | extensions/browser/process_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/installed_loader.h" 5 #include "chrome/browser/extensions/installed_loader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return; 222 return;
223 } 223 }
224 224
225 if (write_to_prefs) 225 if (write_to_prefs)
226 extension_prefs_->UpdateManifest(extension.get()); 226 extension_prefs_->UpdateManifest(extension.get());
227 227
228 extension_service_->AddExtension(extension.get()); 228 extension_service_->AddExtension(extension.get());
229 } 229 }
230 230
231 void InstalledLoader::LoadAllExtensions() { 231 void InstalledLoader::LoadAllExtensions() {
232 DCHECK_CURRENTLY_ON(BrowserThread::UI);
232 TRACE_EVENT0("browser,startup", "InstalledLoader::LoadAllExtensions"); 233 TRACE_EVENT0("browser,startup", "InstalledLoader::LoadAllExtensions");
233 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 234 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.LoadAllTime2");
234
235 base::TimeTicks start_time = base::TimeTicks::Now(); 235 base::TimeTicks start_time = base::TimeTicks::Now();
236 236
237 Profile* profile = extension_service_->profile(); 237 Profile* profile = extension_service_->profile();
238 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( 238 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info(
239 extension_prefs_->GetInstalledExtensionsInfo()); 239 extension_prefs_->GetInstalledExtensionsInfo());
240 240
241 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0); 241 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0);
242 bool should_write_prefs = false; 242 bool should_write_prefs = false;
243 243
244 for (size_t i = 0; i < extensions_info->size(); ++i) { 244 for (size_t i = 0; i < extensions_info->size(); ++i) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir", 298 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir",
299 reload_reason_counts[UNPACKED_DIR]); 299 reload_reason_counts[UNPACKED_DIR]);
300 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization", 300 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization",
301 reload_reason_counts[NEEDS_RELOCALIZATION]); 301 reload_reason_counts[NEEDS_RELOCALIZATION]);
302 302
303 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll", 303 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll",
304 extension_registry_->enabled_extensions().size()); 304 extension_registry_->enabled_extensions().size());
305 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled", 305 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled",
306 extension_registry_->disabled_extensions().size()); 306 extension_registry_->disabled_extensions().size());
307 307
308 // TODO(rkaplow): Obsolete this when verified similar to LoadAllTime2.
308 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime", 309 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime",
309 base::TimeTicks::Now() - start_time); 310 base::TimeTicks::Now() - start_time);
311 RecordExtensionsMetrics();
312 }
313
314 void InstalledLoader::RecordExtensionsMetrics() {
315 Profile* profile = extension_service_->profile();
310 316
311 int app_user_count = 0; 317 int app_user_count = 0;
312 int app_external_count = 0; 318 int app_external_count = 0;
313 int hosted_app_count = 0; 319 int hosted_app_count = 0;
314 int legacy_packaged_app_count = 0; 320 int legacy_packaged_app_count = 0;
315 int platform_app_count = 0; 321 int platform_app_count = 0;
316 int user_script_count = 0; 322 int user_script_count = 0;
317 int content_pack_count = 0; 323 int content_pack_count = 0;
318 int extension_user_count = 0; 324 int extension_user_count = 0;
319 int extension_external_count = 0; 325 int extension_external_count = 0;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 583 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
578 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 584 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
579 if (!Manifest::IsUnpackedLocation(info->extension_location)) 585 if (!Manifest::IsUnpackedLocation(info->extension_location))
580 flags |= Extension::REQUIRE_KEY; 586 flags |= Extension::REQUIRE_KEY;
581 if (extension_prefs_->AllowFileAccess(info->extension_id)) 587 if (extension_prefs_->AllowFileAccess(info->extension_id))
582 flags |= Extension::ALLOW_FILE_ACCESS; 588 flags |= Extension::ALLOW_FILE_ACCESS;
583 return flags; 589 return flags;
584 } 590 }
585 591
586 } // namespace extensions 592 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/installed_loader.h ('k') | extensions/browser/process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698