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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 8890054: Adding metrics to track browser launches per primary/secondary profile. Adding metrics to track n... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <set> 5 #include <set>
6 6
7 #include "chrome/browser/profiles/profile_manager.h" 7 #include "chrome/browser/profiles/profile_manager.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/default_apps_trial.h" 19 #include "chrome/browser/extensions/default_apps_trial.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/prefs/scoped_user_pref_update.h" 22 #include "chrome/browser/prefs/scoped_user_pref_update.h"
23 #include "chrome/browser/profiles/profile_info_cache.h" 23 #include "chrome/browser/profiles/profile_info_cache.h"
24 #include "chrome/browser/profiles/profile_metrics.h"
24 #include "chrome/browser/sessions/session_service_factory.h" 25 #include "chrome/browser/sessions/session_service_factory.h"
25 #include "chrome/browser/sync/profile_sync_service.h" 26 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/webui/sync_promo_ui.h" 29 #include "chrome/browser/ui/webui/sync_promo_ui.h"
29 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/logging_chrome.h" 33 #include "chrome/common/logging_chrome.h"
33 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // that's already loaded. 380 // that's already loaded.
380 if (GetProfileByPath(profile->GetPath())) { 381 if (GetProfileByPath(profile->GetPath())) {
381 NOTREACHED() << "Attempted to add profile with the same path (" << 382 NOTREACHED() << "Attempted to add profile with the same path (" <<
382 profile->GetPath().value() << 383 profile->GetPath().value() <<
383 ") as an already-loaded profile."; 384 ") as an already-loaded profile.";
384 return false; 385 return false;
385 } 386 }
386 387
387 RegisterProfile(profile, true); 388 RegisterProfile(profile, true);
388 DoFinalInit(profile, ShouldGoOffTheRecord()); 389 DoFinalInit(profile, ShouldGoOffTheRecord());
390 ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT);
389 return true; 391 return true;
390 } 392 }
391 393
392 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile, 394 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile,
393 bool created) { 395 bool created) {
394 ProfileInfo* info = new ProfileInfo(profile, created); 396 ProfileInfo* info = new ProfileInfo(profile, created);
395 profiles_info_.insert(std::make_pair(profile->GetPath(), info)); 397 profiles_info_.insert(std::make_pair(profile->GetPath(), info));
396 return info; 398 return info;
397 } 399 }
398 400
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (profile) { 681 if (profile) {
680 BrowserList::CloseAllBrowsersWithProfile(profile); 682 BrowserList::CloseAllBrowsersWithProfile(profile);
681 683
682 // Disable sync for doomed profile. 684 // Disable sync for doomed profile.
683 if (profile->HasProfileSyncService()) 685 if (profile->HasProfileSyncService())
684 profile->GetProfileSyncService()->DisableForUser(); 686 profile->GetProfileSyncService()->DisableForUser();
685 } 687 }
686 688
687 QueueProfileDirectoryForDeletion(profile_dir); 689 QueueProfileDirectoryForDeletion(profile_dir);
688 cache.DeleteProfileFromCache(profile_dir); 690 cache.DeleteProfileFromCache(profile_dir);
691
692 ProfileMetrics::LogNumberOfProfiles(this,
693 ProfileMetrics::DELETE_PROFILE_EVENT);
689 } 694 }
690 695
691 // static 696 // static
692 bool ProfileManager::IsMultipleProfilesEnabled() { 697 bool ProfileManager::IsMultipleProfilesEnabled() {
693 #if defined(OS_CHROMEOS) 698 #if defined(OS_CHROMEOS)
694 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); 699 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles);
695 #else 700 #else
696 return true; 701 return true;
697 #endif 702 #endif
698 } 703 }
699 704
700 void ProfileManager::AutoloadProfiles() { 705 void ProfileManager::AutoloadProfiles() {
701 ProfileInfoCache& cache = GetProfileInfoCache(); 706 ProfileInfoCache& cache = GetProfileInfoCache();
702 size_t number_of_profiles = cache.GetNumberOfProfiles(); 707 size_t number_of_profiles = cache.GetNumberOfProfiles();
703 for (size_t p = 0; p < number_of_profiles; ++p) { 708 for (size_t p = 0; p < number_of_profiles; ++p) {
704 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) { 709 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
705 // If status is true, that profile is running background apps. By calling 710 // If status is true, that profile is running background apps. By calling
706 // GetProfile, we automatically cause the profile to be loaded which will 711 // GetProfile, we automatically cause the profile to be loaded which will
707 // register it with the BackgroundModeManager. 712 // register it with the BackgroundModeManager.
708 GetProfile(cache.GetPathOfProfileAtIndex(p)); 713 GetProfile(cache.GetPathOfProfileAtIndex(p));
709 } 714 }
710 } 715 }
716 ProfileMetrics::LogNumberOfProfiles(this,
717 ProfileMetrics::STARTUP_PROFILE_EVENT);
711 } 718 }
712 719
713 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 720 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
714 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { 721 const FilePath& user_data_dir) : ProfileManager(user_data_dir) {
715 } 722 }
716 723
717 void ProfileManager::RegisterTestingProfile(Profile* profile, 724 void ProfileManager::RegisterTestingProfile(Profile* profile,
718 bool add_to_cache) { 725 bool add_to_cache) {
719 RegisterProfile(profile, true); 726 RegisterProfile(profile, true);
720 if (add_to_cache) 727 if (add_to_cache)
721 AddProfileToCache(profile); 728 AddProfileToCache(profile);
722 } 729 }
723 730
724 #if defined(OS_WIN) 731 #if defined(OS_WIN)
725 void ProfileManager::RemoveProfileShortcutManagerForTesting() { 732 void ProfileManager::RemoveProfileShortcutManagerForTesting() {
726 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); 733 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get());
727 } 734 }
728 #endif 735 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_metrics.h » ('j') | chrome/browser/profiles/profile_metrics.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698