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

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

Issue 1428973003: Utilize ProfileInfoCache to support data type counts in profile deletion flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments, minor edits Created 4 years, 11 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 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/deferred_sequenced_task_runner.h" 14 #include "base/deferred_sequenced_task_runner.h"
14 #include "base/files/file_enumerator.h" 15 #include "base/files/file_enumerator.h"
15 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
17 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
18 #include "base/prefs/pref_service.h" 19 #include "base/prefs/pref_service.h"
19 #include "base/prefs/scoped_user_pref_update.h" 20 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 14 matching lines...) Expand all
34 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
35 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" 36 #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" 37 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv ice_factory.h"
37 #include "chrome/browser/password_manager/password_store_factory.h" 38 #include "chrome/browser/password_manager/password_store_factory.h"
38 #include "chrome/browser/prefs/incognito_mode_prefs.h" 39 #include "chrome/browser/prefs/incognito_mode_prefs.h"
39 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" 40 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 41 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
41 #include "chrome/browser/profiles/profile_destroyer.h" 42 #include "chrome/browser/profiles/profile_destroyer.h"
42 #include "chrome/browser/profiles/profile_info_cache.h" 43 #include "chrome/browser/profiles/profile_info_cache.h"
43 #include "chrome/browser/profiles/profile_metrics.h" 44 #include "chrome/browser/profiles/profile_metrics.h"
45 #include "chrome/browser/profiles/profile_statistics.h"
44 #include "chrome/browser/profiles/profiles_state.h" 46 #include "chrome/browser/profiles/profiles_state.h"
45 #include "chrome/browser/signin/account_fetcher_service_factory.h" 47 #include "chrome/browser/signin/account_fetcher_service_factory.h"
46 #include "chrome/browser/signin/account_reconcilor_factory.h" 48 #include "chrome/browser/signin/account_reconcilor_factory.h"
47 #include "chrome/browser/signin/account_tracker_service_factory.h" 49 #include "chrome/browser/signin/account_tracker_service_factory.h"
48 #include "chrome/browser/signin/cross_device_promo.h" 50 #include "chrome/browser/signin/cross_device_promo.h"
49 #include "chrome/browser/signin/cross_device_promo_factory.h" 51 #include "chrome/browser/signin/cross_device_promo_factory.h"
50 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 52 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
51 #include "chrome/browser/signin/signin_manager_factory.h" 53 #include "chrome/browser/signin/signin_manager_factory.h"
52 #include "chrome/browser/sync/profile_sync_service_factory.h" 54 #include "chrome/browser/sync/profile_sync_service_factory.h"
53 #include "chrome/browser/ui/browser.h" 55 #include "chrome/browser/ui/browser.h"
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1053
1052 DoFinalInitForServices(profile, go_off_the_record); 1054 DoFinalInitForServices(profile, go_off_the_record);
1053 AddProfileToCache(profile); 1055 AddProfileToCache(profile);
1054 DoFinalInitLogging(profile); 1056 DoFinalInitLogging(profile);
1055 1057
1056 ProfileMetrics::LogNumberOfProfiles(this); 1058 ProfileMetrics::LogNumberOfProfiles(this);
1057 content::NotificationService::current()->Notify( 1059 content::NotificationService::current()->Notify(
1058 chrome::NOTIFICATION_PROFILE_ADDED, 1060 chrome::NOTIFICATION_PROFILE_ADDED,
1059 content::Source<Profile>(profile), 1061 content::Source<Profile>(profile),
1060 content::NotificationService::NoDetails()); 1062 content::NotificationService::NoDetails());
1063
1064 // Record statistics to ProfileInfoCache if statistics were not recorded
1065 // during shutdown, i.e. the last shutdown was a system shutdown or a crash.
1066 if (!profile->IsGuestSession() && !profile->IsSystemProfile() &&
1067 !profile->IsNewProfile() && !go_off_the_record &&
1068 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) {
1069 profiles::GatherProfileStatistics(
1070 profile, profiles::ProfileStatisticsCallback(), nullptr);
1071 }
1061 } 1072 }
1062 1073
1063 void ProfileManager::DoFinalInitForServices(Profile* profile, 1074 void ProfileManager::DoFinalInitForServices(Profile* profile,
1064 bool go_off_the_record) { 1075 bool go_off_the_record) {
1065 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); 1076 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices");
1066 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); 1077 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices");
1067 1078
1068 #if defined(ENABLE_EXTENSIONS) 1079 #if defined(ENABLE_EXTENSIONS)
1069 ProfileInfoCache& cache = GetProfileInfoCache(); 1080 ProfileInfoCache& cache = GetProfileInfoCache();
1070 1081
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 ProfileManager::BrowserListObserver::~BrowserListObserver() { 1462 ProfileManager::BrowserListObserver::~BrowserListObserver() {
1452 BrowserList::RemoveObserver(this); 1463 BrowserList::RemoveObserver(this);
1453 } 1464 }
1454 1465
1455 void ProfileManager::BrowserListObserver::OnBrowserAdded( 1466 void ProfileManager::BrowserListObserver::OnBrowserAdded(
1456 Browser* browser) {} 1467 Browser* browser) {}
1457 1468
1458 void ProfileManager::BrowserListObserver::OnBrowserRemoved( 1469 void ProfileManager::BrowserListObserver::OnBrowserRemoved(
1459 Browser* browser) { 1470 Browser* browser) {
1460 Profile* profile = browser->profile(); 1471 Profile* profile = browser->profile();
1472 Profile* original_profile = profile->GetOriginalProfile();
1473 // Do nothing if the closed window is not the last window of the same profile.
1461 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 1474 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
1462 if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile()) 1475 if (it->profile()->GetOriginalProfile() == original_profile)
1463 // Not the last window for this profile.
1464 return; 1476 return;
1465 } 1477 }
1466 1478
1467 // If the last browser of a profile that is scheduled for deletion is closed
1468 // do that now.
1469 base::FilePath path = profile->GetPath(); 1479 base::FilePath path = profile->GetPath();
1470 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && 1480 if (IsProfileMarkedForDeletion(path)) {
1471 !IsProfileMarkedForDeletion(path)) { 1481 // Do nothing if the profile is already being deleted.
1482 } else if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1483 // Delete if the profile is an ephemeral profile.
1472 g_browser_process->profile_manager()->ScheduleProfileForDeletion( 1484 g_browser_process->profile_manager()->ScheduleProfileForDeletion(
1473 path, ProfileManager::CreateCallback()); 1485 path, ProfileManager::CreateCallback());
1486 } else if (!profile->IsSystemProfile()) {
1487 // Gather statistics and store into ProfileInfoCache. For incognito profile
1488 // we gather the statistics of its parent profile instead, because a window
1489 // of the parent profile was open.
1490 profiles::GatherProfileStatistics(
1491 original_profile, profiles::ProfileStatisticsCallback(), nullptr);
1474 } 1492 }
1475 } 1493 }
1476 1494
1477 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( 1495 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive(
1478 Browser* browser) { 1496 Browser* browser) {
1479 // If all browsers are being closed (e.g. the user is in the process of 1497 // If all browsers are being closed (e.g. the user is in the process of
1480 // shutting down), this event will be fired after each browser is 1498 // shutting down), this event will be fired after each browser is
1481 // closed. This does not represent a user intention to change the active 1499 // closed. This does not represent a user intention to change the active
1482 // browser so is not handled here. 1500 // browser so is not handled here.
1483 if (profile_manager_->closing_all_browsers_) 1501 if (profile_manager_->closing_all_browsers_)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 1534
1517 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1535 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1518 if (!original_callback.is_null()) 1536 if (!original_callback.is_null())
1519 original_callback.Run(loaded_profile, status); 1537 original_callback.Run(loaded_profile, status);
1520 } 1538 }
1521 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 1539 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
1522 1540
1523 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1541 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1524 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1542 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1525 } 1543 }
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