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

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
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_metrics.h » ('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) 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 12 matching lines...) Expand all
411 if (browser) { 413 if (browser) {
412 browser->window()->Activate(); 414 browser->window()->Activate();
413 } else { 415 } else {
414 UserMetrics::RecordAction(UserMetricsAction("NewWindow")); 416 UserMetrics::RecordAction(UserMetricsAction("NewWindow"));
415 CommandLine command_line(CommandLine::NO_PROGRAM); 417 CommandLine command_line(CommandLine::NO_PROGRAM);
416 int return_code; 418 int return_code;
417 BrowserInit browser_init; 419 BrowserInit browser_init;
418 browser_init.LaunchBrowser(command_line, profile, FilePath(), 420 browser_init.LaunchBrowser(command_line, profile, FilePath(),
419 process_startup, is_first_run, &return_code); 421 process_startup, is_first_run, &return_code);
420 } 422 }
423 FilePath profile_path = profile->GetPath();
424 ProfileMetrics::LogProfileLaunch(profile_path);
sky 2011/12/09 23:29:43 I believe NewWindowWithProfile is not invoked for
421 } 425 }
422 426
423 void ProfileManager::Observe( 427 void ProfileManager::Observe(
424 int type, 428 int type,
425 const content::NotificationSource& source, 429 const content::NotificationSource& source,
426 const content::NotificationDetails& details) { 430 const content::NotificationDetails& details) {
427 #if defined(OS_CHROMEOS) 431 #if defined(OS_CHROMEOS)
428 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { 432 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
429 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 433 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
430 if (!command_line.HasSwitch(switches::kTestType)) { 434 if (!command_line.HasSwitch(switches::kTestType)) {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (profile) { 683 if (profile) {
680 BrowserList::CloseAllBrowsersWithProfile(profile); 684 BrowserList::CloseAllBrowsersWithProfile(profile);
681 685
682 // Disable sync for doomed profile. 686 // Disable sync for doomed profile.
683 if (profile->HasProfileSyncService()) 687 if (profile->HasProfileSyncService())
684 profile->GetProfileSyncService()->DisableForUser(); 688 profile->GetProfileSyncService()->DisableForUser();
685 } 689 }
686 690
687 QueueProfileDirectoryForDeletion(profile_dir); 691 QueueProfileDirectoryForDeletion(profile_dir);
688 cache.DeleteProfileFromCache(profile_dir); 692 cache.DeleteProfileFromCache(profile_dir);
693
694 ProfileMetrics::LogNumberOfProfiles(this,
695 ProfileMetrics::DELETE_PROFILE_EVENT);
689 } 696 }
690 697
691 // static 698 // static
692 bool ProfileManager::IsMultipleProfilesEnabled() { 699 bool ProfileManager::IsMultipleProfilesEnabled() {
693 #if defined(OS_CHROMEOS) 700 #if defined(OS_CHROMEOS)
694 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles); 701 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles);
695 #else 702 #else
696 return true; 703 return true;
697 #endif 704 #endif
698 } 705 }
699 706
700 void ProfileManager::AutoloadProfiles() { 707 void ProfileManager::AutoloadProfiles() {
701 ProfileInfoCache& cache = GetProfileInfoCache(); 708 ProfileInfoCache& cache = GetProfileInfoCache();
702 size_t number_of_profiles = cache.GetNumberOfProfiles(); 709 size_t number_of_profiles = cache.GetNumberOfProfiles();
703 for (size_t p = 0; p < number_of_profiles; ++p) { 710 for (size_t p = 0; p < number_of_profiles; ++p) {
704 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) { 711 if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
705 // If status is true, that profile is running background apps. By calling 712 // If status is true, that profile is running background apps. By calling
706 // GetProfile, we automatically cause the profile to be loaded which will 713 // GetProfile, we automatically cause the profile to be loaded which will
707 // register it with the BackgroundModeManager. 714 // register it with the BackgroundModeManager.
708 GetProfile(cache.GetPathOfProfileAtIndex(p)); 715 GetProfile(cache.GetPathOfProfileAtIndex(p));
709 } 716 }
710 } 717 }
718 ProfileMetrics::LogNumberOfProfiles(this,
719 ProfileMetrics::STARTUP_PROFILE_EVENT);
711 } 720 }
712 721
713 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 722 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
714 const FilePath& user_data_dir) : ProfileManager(user_data_dir) { 723 const FilePath& user_data_dir) : ProfileManager(user_data_dir) {
715 } 724 }
716 725
717 void ProfileManager::RegisterTestingProfile(Profile* profile, 726 void ProfileManager::RegisterTestingProfile(Profile* profile,
718 bool add_to_cache) { 727 bool add_to_cache) {
719 RegisterProfile(profile, true); 728 RegisterProfile(profile, true);
720 if (add_to_cache) 729 if (add_to_cache)
721 AddProfileToCache(profile); 730 AddProfileToCache(profile);
722 } 731 }
723 732
724 #if defined(OS_WIN) 733 #if defined(OS_WIN)
725 void ProfileManager::RemoveProfileShortcutManagerForTesting() { 734 void ProfileManager::RemoveProfileShortcutManagerForTesting() {
726 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get()); 735 profile_info_cache_->RemoveObserver(profile_shortcut_manager_.get());
727 } 736 }
728 #endif 737 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698