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

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

Issue 1579433002: Make profile statistics tasks inspectable by tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed ProfileAttributesStorage related functions in profile_statistics.* Created 4 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 | « no previous file | chrome/browser/profiles/profile_statistics.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) 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/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
36 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv ice_factory.h" 36 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv ice_factory.h"
37 #include "chrome/browser/password_manager/password_store_factory.h" 37 #include "chrome/browser/password_manager/password_store_factory.h"
38 #include "chrome/browser/prefs/incognito_mode_prefs.h" 38 #include "chrome/browser/prefs/incognito_mode_prefs.h"
39 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 39 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
40 #include "chrome/browser/profiles/profile_attributes_storage.h" 40 #include "chrome/browser/profiles/profile_attributes_storage.h"
41 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 41 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
42 #include "chrome/browser/profiles/profile_destroyer.h" 42 #include "chrome/browser/profiles/profile_destroyer.h"
43 #include "chrome/browser/profiles/profile_info_cache.h" 43 #include "chrome/browser/profiles/profile_info_cache.h"
44 #include "chrome/browser/profiles/profile_metrics.h" 44 #include "chrome/browser/profiles/profile_metrics.h"
45 #include "chrome/browser/profiles/profile_statistics.h"
46 #include "chrome/browser/profiles/profiles_state.h" 45 #include "chrome/browser/profiles/profiles_state.h"
47 #include "chrome/browser/sessions/session_service_factory.h" 46 #include "chrome/browser/sessions/session_service_factory.h"
48 #include "chrome/browser/signin/account_fetcher_service_factory.h" 47 #include "chrome/browser/signin/account_fetcher_service_factory.h"
49 #include "chrome/browser/signin/account_reconcilor_factory.h" 48 #include "chrome/browser/signin/account_reconcilor_factory.h"
50 #include "chrome/browser/signin/account_tracker_service_factory.h" 49 #include "chrome/browser/signin/account_tracker_service_factory.h"
51 #include "chrome/browser/signin/cross_device_promo.h" 50 #include "chrome/browser/signin/cross_device_promo.h"
52 #include "chrome/browser/signin/cross_device_promo_factory.h" 51 #include "chrome/browser/signin/cross_device_promo_factory.h"
53 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 52 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
54 #include "chrome/browser/signin/signin_manager_factory.h" 53 #include "chrome/browser/signin/signin_manager_factory.h"
55 #include "chrome/browser/sync/profile_sync_service_factory.h" 54 #include "chrome/browser/sync/profile_sync_service_factory.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #if defined(OS_CHROMEOS) 115 #if defined(OS_CHROMEOS)
117 #include "chrome/browser/browser_process_platform_part_chromeos.h" 116 #include "chrome/browser/browser_process_platform_part_chromeos.h"
118 #include "chrome/browser/chromeos/profiles/profile_helper.h" 117 #include "chrome/browser/chromeos/profiles/profile_helper.h"
119 #include "chromeos/chromeos_switches.h" 118 #include "chromeos/chromeos_switches.h"
120 #include "chromeos/dbus/cryptohome_client.h" 119 #include "chromeos/dbus/cryptohome_client.h"
121 #include "chromeos/dbus/dbus_thread_manager.h" 120 #include "chromeos/dbus/dbus_thread_manager.h"
122 #include "components/user_manager/user.h" 121 #include "components/user_manager/user.h"
123 #include "components/user_manager/user_manager.h" 122 #include "components/user_manager/user_manager.h"
124 #endif 123 #endif
125 124
125 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
126 #include "chrome/browser/profiles/profile_statistics.h"
127 #include "chrome/browser/profiles/profile_statistics_factory.h"
128 #endif
129
126 using base::UserMetricsAction; 130 using base::UserMetricsAction;
127 using content::BrowserThread; 131 using content::BrowserThread;
128 132
129 namespace { 133 namespace {
130 134
131 // Profiles that should be deleted on shutdown. 135 // Profiles that should be deleted on shutdown.
132 std::vector<base::FilePath>& ProfilesToDelete() { 136 std::vector<base::FilePath>& ProfilesToDelete() {
133 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); 137 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ());
134 return profiles_to_delete; 138 return profiles_to_delete;
135 } 139 }
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 DoFinalInitForServices(profile, go_off_the_record); 1062 DoFinalInitForServices(profile, go_off_the_record);
1059 AddProfileToCache(profile); 1063 AddProfileToCache(profile);
1060 DoFinalInitLogging(profile); 1064 DoFinalInitLogging(profile);
1061 1065
1062 ProfileMetrics::LogNumberOfProfiles(this); 1066 ProfileMetrics::LogNumberOfProfiles(this);
1063 content::NotificationService::current()->Notify( 1067 content::NotificationService::current()->Notify(
1064 chrome::NOTIFICATION_PROFILE_ADDED, 1068 chrome::NOTIFICATION_PROFILE_ADDED,
1065 content::Source<Profile>(profile), 1069 content::Source<Profile>(profile),
1066 content::NotificationService::NoDetails()); 1070 content::NotificationService::NoDetails());
1067 1071
1072 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1068 // Record statistics to ProfileInfoCache if statistics were not recorded 1073 // Record statistics to ProfileInfoCache if statistics were not recorded
1069 // during shutdown, i.e. the last shutdown was a system shutdown or a crash. 1074 // during shutdown, i.e. the last shutdown was a system shutdown or a crash.
1070 if (!profile->IsGuestSession() && !profile->IsSystemProfile() && 1075 if (!profile->IsGuestSession() && !profile->IsSystemProfile() &&
1071 !profile->IsNewProfile() && !go_off_the_record && 1076 !profile->IsNewProfile() && !go_off_the_record &&
1072 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) { 1077 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) {
1073 profiles::GatherProfileStatistics( 1078 ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics(
1074 profile, profiles::ProfileStatisticsCallback(), nullptr); 1079 profiles::ProfileStatisticsCallback());
1075 } 1080 }
1081 #endif
1076 } 1082 }
1077 1083
1078 void ProfileManager::DoFinalInitForServices(Profile* profile, 1084 void ProfileManager::DoFinalInitForServices(Profile* profile,
1079 bool go_off_the_record) { 1085 bool go_off_the_record) {
1080 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); 1086 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices");
1081 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); 1087 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices");
1082 1088
1083 #if defined(ENABLE_EXTENSIONS) 1089 #if defined(ENABLE_EXTENSIONS)
1084 ProfileInfoCache& cache = GetProfileInfoCache(); 1090 ProfileInfoCache& cache = GetProfileInfoCache();
1085 1091
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 return; 1503 return;
1498 } 1504 }
1499 1505
1500 base::FilePath path = profile->GetPath(); 1506 base::FilePath path = profile->GetPath();
1501 if (IsProfileMarkedForDeletion(path)) { 1507 if (IsProfileMarkedForDeletion(path)) {
1502 // Do nothing if the profile is already being deleted. 1508 // Do nothing if the profile is already being deleted.
1503 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1509 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1504 // Delete if the profile is an ephemeral profile. 1510 // Delete if the profile is an ephemeral profile.
1505 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1511 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
1506 path, ProfileManager::CreateCallback()); 1512 path, ProfileManager::CreateCallback());
1507 } else if (!profile->IsSystemProfile()) { 1513 } else {
1514 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1508 // Gather statistics and store into ProfileInfoCache. For incognito profile 1515 // Gather statistics and store into ProfileInfoCache. For incognito profile
1509 // we gather the statistics of its parent profile instead, because a window 1516 // we gather the statistics of its parent profile instead, because a window
1510 // of the parent profile was open. 1517 // of the parent profile was open.
1511 profiles::GatherProfileStatistics( 1518 if (!profile->IsSystemProfile()) {
1512 original_profile, profiles::ProfileStatisticsCallback(), nullptr); 1519 ProfileStatisticsFactory::GetForProfile(original_profile)->
1520 GatherStatistics(profiles::ProfileStatisticsCallback());
1521 }
1522 #endif
1513 } 1523 }
1514 } 1524 }
1515 1525
1516 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( 1526 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
1517 Browser* browser) { 1527 Browser* browser) {
1518 // If all browsers are being closed (e.g. the user is in the process of 1528 // If all browsers are being closed (e.g. the user is in the process of
1519 // shutting down), this event will be fired after each browser is 1529 // shutting down), this event will be fired after each browser is
1520 // closed. This does not represent a user intention to change the active 1530 // closed. This does not represent a user intention to change the active
1521 // browser so is not handled here. 1531 // browser so is not handled here.
1522 if (profile_manager_->closing_all_browsers_) 1532 if (profile_manager_->closing_all_browsers_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 1565
1556 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1566 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1557 if (!original_callback.is_null()) 1567 if (!original_callback.is_null())
1558 original_callback.Run(loaded_profile, status); 1568 original_callback.Run(loaded_profile, status);
1559 } 1569 }
1560 #endif // !defined(OS_ANDROID) 1570 #endif // !defined(OS_ANDROID)
1561 1571
1562 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1572 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1563 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1573 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1564 } 1574 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_statistics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698