OLD | NEW |
---|---|
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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 #endif | 195 #endif |
196 | 196 |
197 #if defined(USE_AURA) | 197 #if defined(USE_AURA) |
198 #include "ui/aura/env.h" | 198 #include "ui/aura/env.h" |
199 #endif | 199 #endif |
200 | 200 |
201 using content::BrowserThread; | 201 using content::BrowserThread; |
202 | 202 |
203 namespace { | 203 namespace { |
204 | 204 |
205 const int64 kEphemeralProfilesCleanUpDelaySec = 10; | |
206 | |
205 // This function provides some ways to test crash and assertion handling | 207 // This function provides some ways to test crash and assertion handling |
206 // behavior of the program. | 208 // behavior of the program. |
207 void HandleTestParameters(const CommandLine& command_line) { | 209 void HandleTestParameters(const CommandLine& command_line) { |
208 // This parameter causes an assertion. | 210 // This parameter causes an assertion. |
209 if (command_line.HasSwitch(switches::kBrowserAssertTest)) { | 211 if (command_line.HasSwitch(switches::kBrowserAssertTest)) { |
210 DCHECK(false); | 212 DCHECK(false); |
211 } | 213 } |
212 | 214 |
213 // This parameter causes a null pointer crash (crash reporter trigger). | 215 // This parameter causes a null pointer crash (crash reporter trigger). |
214 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { | 216 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 // First check if any ephemeral profiles are left behind because of browser | 1037 // First check if any ephemeral profiles are left behind because of browser |
1036 // crash and schedule them for deletion and then proceed with getting the set | 1038 // crash and schedule them for deletion and then proceed with getting the set |
1037 // of profiles to open. | 1039 // of profiles to open. |
1038 ProfileInfoCache& profile_cache = profile_manager->GetProfileInfoCache(); | 1040 ProfileInfoCache& profile_cache = profile_manager->GetProfileInfoCache(); |
1039 size_t profiles_count = profile_cache.GetNumberOfProfiles(); | 1041 size_t profiles_count = profile_cache.GetNumberOfProfiles(); |
1040 std::vector<base::FilePath> profiles_to_delete; | 1042 std::vector<base::FilePath> profiles_to_delete; |
1041 for (size_t i = 0;i < profiles_count; ++i) { | 1043 for (size_t i = 0;i < profiles_count; ++i) { |
1042 if (profile_cache.ProfileIsEphemeralAtIndex(i)) | 1044 if (profile_cache.ProfileIsEphemeralAtIndex(i)) |
1043 profiles_to_delete.push_back(profile_cache.GetPathOfProfileAtIndex(i)); | 1045 profiles_to_delete.push_back(profile_cache.GetPathOfProfileAtIndex(i)); |
1044 } | 1046 } |
1045 for (size_t i = 0;i < profiles_to_delete.size(); ++i) { | 1047 |
1046 profile_manager->ScheduleProfileForDeletion( | 1048 if (profiles_to_delete.size()) { |
1047 profiles_to_delete[i], ProfileManager::CreateCallback()); | 1049 for (size_t i = 0;i < profiles_to_delete.size(); ++i) { |
1050 profile_manager->ScheduleProfileForDeletion( | |
1051 profiles_to_delete[i], ProfileManager::CreateCallback()); | |
1052 } | |
1053 // Clean up the profiles soon after browser start, but not immediately not | |
1054 // to delay browser start-up. | |
rpetterson
2013/11/04 18:18:59
Was there noticeable slow down for startup without
pastarmovj
2013/11/05 08:58:17
To be honest I have never tried. Since I need to p
jochen (gone - plz use gerrit)
2013/11/05 13:03:25
I don't think we should do that, unless you have d
pastarmovj
2013/11/05 16:11:02
After discussing this with Jochen. I can see the p
| |
1055 BrowserThread::PostDelayedTask( | |
1056 BrowserThread::FILE, FROM_HERE, | |
1057 base::Bind(&ProfileManager::CleanUpStaleProfiles, profiles_to_delete), | |
1058 base::TimeDelta::FromSeconds(kEphemeralProfilesCleanUpDelaySec)); | |
1048 } | 1059 } |
1049 #endif // OS_ANDROID | 1060 #endif // OS_ANDROID |
1050 | 1061 |
1051 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1062 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1052 chrome_extra_parts_[i]->PreProfileInit(); | 1063 chrome_extra_parts_[i]->PreProfileInit(); |
1053 } | 1064 } |
1054 | 1065 |
1055 void ChromeBrowserMainParts::PostProfileInit() { | 1066 void ChromeBrowserMainParts::PostProfileInit() { |
1056 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); | 1067 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); |
1057 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); | 1068 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1693 chromeos::CrosSettings::Shutdown(); | 1704 chromeos::CrosSettings::Shutdown(); |
1694 #endif | 1705 #endif |
1695 #endif | 1706 #endif |
1696 } | 1707 } |
1697 | 1708 |
1698 // Public members: | 1709 // Public members: |
1699 | 1710 |
1700 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1711 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1701 chrome_extra_parts_.push_back(parts); | 1712 chrome_extra_parts_.push_back(parts); |
1702 } | 1713 } |
OLD | NEW |