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

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: Created 5 years, 10 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 (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 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
Alexei Svitkine (slow) 2015/02/25 16:10:53 This should actually be a DCHECK.
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.LoadAllTime");
Yoyo Zhou 2015/02/25 00:19:58 Can we put lines 234-308 inside a scope block, so
rkaplow 2015/02/25 16:37:49 I did mention this in my description - and I agree
Yoyo Zhou 2015/02/25 19:34:29 Ah, I see why it's confusing. It seemed intuitive
rkaplow 2015/02/25 19:59:50 Ok. Added a TODO. Will follow up - just want to se
234 235
235 base::TimeTicks start_time = base::TimeTicks::Now(); 236 base::TimeTicks start_time = base::TimeTicks::Now();
236 237
237 Profile* profile = extension_service_->profile(); 238 Profile* profile = extension_service_->profile();
238 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( 239 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info(
239 extension_prefs_->GetInstalledExtensionsInfo()); 240 extension_prefs_->GetInstalledExtensionsInfo());
240 241
241 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0); 242 std::vector<int> reload_reason_counts(NUM_MANIFEST_RELOAD_REASONS, 0);
242 bool should_write_prefs = false; 243 bool should_write_prefs = false;
243 244
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir", 299 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadUnpackedDir",
299 reload_reason_counts[UNPACKED_DIR]); 300 reload_reason_counts[UNPACKED_DIR]);
300 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization", 301 UMA_HISTOGRAM_COUNTS_100("Extensions.ManifestReloadNeedsRelocalization",
301 reload_reason_counts[NEEDS_RELOCALIZATION]); 302 reload_reason_counts[NEEDS_RELOCALIZATION]);
302 303
303 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll", 304 UMA_HISTOGRAM_COUNTS_100("Extensions.LoadAll",
304 extension_registry_->enabled_extensions().size()); 305 extension_registry_->enabled_extensions().size());
305 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled", 306 UMA_HISTOGRAM_COUNTS_100("Extensions.Disabled",
306 extension_registry_->disabled_extensions().size()); 307 extension_registry_->disabled_extensions().size());
307 308
308 UMA_HISTOGRAM_TIMES("Extensions.LoadAllTime", 309 LoadExtensionsMetrics();
309 base::TimeTicks::Now() - start_time); 310 }
Yoyo Zhou 2015/02/25 00:19:58 nit: new line after
rkaplow 2015/02/25 16:37:49 Done.
311 void InstalledLoader::LoadExtensionsMetrics() {
312 Profile* profile = extension_service_->profile();
310 313
311 int app_user_count = 0; 314 int app_user_count = 0;
312 int app_external_count = 0; 315 int app_external_count = 0;
313 int hosted_app_count = 0; 316 int hosted_app_count = 0;
314 int legacy_packaged_app_count = 0; 317 int legacy_packaged_app_count = 0;
315 int platform_app_count = 0; 318 int platform_app_count = 0;
316 int user_script_count = 0; 319 int user_script_count = 0;
317 int content_pack_count = 0; 320 int content_pack_count = 0;
318 int extension_user_count = 0; 321 int extension_user_count = 0;
319 int extension_external_count = 0; 322 int extension_external_count = 0;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 580 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
578 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 581 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
579 if (!Manifest::IsUnpackedLocation(info->extension_location)) 582 if (!Manifest::IsUnpackedLocation(info->extension_location))
580 flags |= Extension::REQUIRE_KEY; 583 flags |= Extension::REQUIRE_KEY;
581 if (extension_prefs_->AllowFileAccess(info->extension_id)) 584 if (extension_prefs_->AllowFileAccess(info->extension_id))
582 flags |= Extension::ALLOW_FILE_ACCESS; 585 flags |= Extension::ALLOW_FILE_ACCESS;
583 return flags; 586 return flags;
584 } 587 }
585 588
586 } // namespace extensions 589 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698