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 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 #include "net/url_request/url_request.h" | 137 #include "net/url_request/url_request.h" |
138 #include "ui/base/l10n/l10n_util.h" | 138 #include "ui/base/l10n/l10n_util.h" |
139 #include "ui/base/layout.h" | 139 #include "ui/base/layout.h" |
140 #include "ui/base/resource/resource_bundle.h" | 140 #include "ui/base/resource/resource_bundle.h" |
141 #include "ui/strings/grit/app_locale_settings.h" | 141 #include "ui/strings/grit/app_locale_settings.h" |
142 | 142 |
143 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
144 #include "chrome/browser/metrics/thread_watcher_android.h" | 144 #include "chrome/browser/metrics/thread_watcher_android.h" |
145 #else | 145 #else |
146 #include "chrome/browser/feedback/feedback_profile_observer.h" | 146 #include "chrome/browser/feedback/feedback_profile_observer.h" |
147 #endif | 147 #endif // defined(OS_ANDROID) |
148 | 148 |
149 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 149 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
150 #include "chrome/browser/first_run/upgrade_util_linux.h" | 150 #include "chrome/browser/first_run/upgrade_util_linux.h" |
151 #include "chrome/browser/sxs_linux.h" | 151 #include "chrome/browser/sxs_linux.h" |
152 #endif | 152 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
153 | 153 |
154 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
155 #include "chrome/browser/chromeos/settings/cros_settings.h" | 155 #include "chrome/browser/chromeos/settings/cros_settings.h" |
156 #include "chromeos/chromeos_switches.h" | 156 #include "chromeos/chromeos_switches.h" |
157 #include "chromeos/settings/cros_settings_names.h" | 157 #include "chromeos/settings/cros_settings_names.h" |
158 #endif | 158 #endif // defined(OS_CHROMEOS) |
159 | 159 |
160 // TODO(port): several win-only methods have been pulled out of this, but | 160 // TODO(port): several win-only methods have been pulled out of this, but |
161 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 161 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
162 // other platforms. For now, it's just a stub. This is a serious work in | 162 // other platforms. For now, it's just a stub. This is a serious work in |
163 // progress and should not be taken as an indication of a real refactoring. | 163 // progress and should not be taken as an indication of a real refactoring. |
164 | 164 |
165 #if defined(OS_WIN) | 165 #if defined(OS_WIN) |
166 #include "base/environment.h" // For PreRead experiment. | 166 #include "base/environment.h" // For PreRead experiment. |
167 #include "base/win/windows_version.h" | 167 #include "base/win/windows_version.h" |
168 #include "chrome/browser/browser_util_win.h" | 168 #include "chrome/browser/browser_util_win.h" |
169 #include "chrome/browser/chrome_browser_main_win.h" | 169 #include "chrome/browser/chrome_browser_main_win.h" |
170 #include "chrome/browser/chrome_select_file_dialog_factory_win.h" | 170 #include "chrome/browser/chrome_select_file_dialog_factory_win.h" |
171 #include "chrome/browser/component_updater/caps_installer_win.h" | 171 #include "chrome/browser/component_updater/caps_installer_win.h" |
172 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" | 172 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
173 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 173 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
174 #include "chrome/browser/first_run/upgrade_util_win.h" | 174 #include "chrome/browser/first_run/upgrade_util_win.h" |
175 #include "chrome/browser/ui/network_profile_bubble.h" | 175 #include "chrome/browser/ui/network_profile_bubble.h" |
176 #include "chrome/installer/util/helper.h" | 176 #include "chrome/installer/util/helper.h" |
177 #include "chrome/installer/util/install_util.h" | 177 #include "chrome/installer/util/install_util.h" |
178 #include "chrome/installer/util/shell_util.h" | 178 #include "chrome/installer/util/shell_util.h" |
179 #include "components/browser_watcher/exit_funnel_win.h" | 179 #include "components/browser_watcher/exit_funnel_win.h" |
180 #include "net/base/net_util.h" | 180 #include "net/base/net_util.h" |
181 #include "ui/base/l10n/l10n_util_win.h" | 181 #include "ui/base/l10n/l10n_util_win.h" |
182 #include "ui/gfx/win/dpi.h" | 182 #include "ui/gfx/win/dpi.h" |
183 #include "ui/shell_dialogs/select_file_dialog.h" | 183 #include "ui/shell_dialogs/select_file_dialog.h" |
184 #endif // defined(OS_WIN) | 184 #endif // defined(OS_WIN) |
Alexei Svitkine (slow)
2015/03/02 22:35:51
Nit: Why did you put two spaces after the // for t
| |
185 | 185 |
186 #if defined(OS_MACOSX) | 186 #if defined(OS_MACOSX) |
187 #include <Security/Security.h> | 187 #include <Security/Security.h> |
188 | 188 |
189 #include "base/mac/scoped_nsautorelease_pool.h" | 189 #include "base/mac/scoped_nsautorelease_pool.h" |
190 #include "chrome/browser/mac/keystone_glue.h" | 190 #include "chrome/browser/mac/keystone_glue.h" |
191 #endif | 191 #endif // defined(OS_MACOSX) |
192 | 192 |
193 #if !defined(OS_IOS) | 193 #if !defined(OS_IOS) |
194 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" | 194 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" |
195 #endif | 195 #endif // !defined(OS_IOS) |
196 | 196 |
197 #if !defined(DISABLE_NACL) | 197 #if !defined(DISABLE_NACL) |
198 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 198 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
199 #include "components/nacl/browser/nacl_process_host.h" | 199 #include "components/nacl/browser/nacl_process_host.h" |
200 #endif | 200 #endif // !defined(DISABLE_NACL) |
201 | 201 |
202 #if defined(ENABLE_EXTENSIONS) | 202 #if defined(ENABLE_EXTENSIONS) |
203 #include "chrome/browser/extensions/startup_helper.h" | 203 #include "chrome/browser/extensions/startup_helper.h" |
204 #include "extensions/browser/extension_protocols.h" | 204 #include "extensions/browser/extension_protocols.h" |
205 #include "extensions/components/javascript_dialog_extensions_client/javascript_d ialog_extension_client_impl.h" | 205 #include "extensions/components/javascript_dialog_extensions_client/javascript_d ialog_extension_client_impl.h" |
206 #endif | 206 #endif // defined(ENABLE_EXTENSIONS) |
207 | 207 |
208 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) | 208 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) |
209 #include "printing/printed_document.h" | 209 #include "printing/printed_document.h" |
210 #endif | 210 #endif // defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) |
211 | 211 |
212 #if defined(ENABLE_RLZ) | 212 #if defined(ENABLE_RLZ) |
213 #include "chrome/browser/rlz/rlz.h" | 213 #include "chrome/browser/rlz/rlz.h" |
214 #endif | 214 #endif // defined(ENABLE_RLZ) |
215 | 215 |
216 #if defined(ENABLE_WEBRTC) | 216 #if defined(ENABLE_WEBRTC) |
217 #include "chrome/browser/media/webrtc_log_util.h" | 217 #include "chrome/browser/media/webrtc_log_util.h" |
218 #endif | 218 #endif // defined(ENABLE_WEBRTC) |
219 | 219 |
220 #if defined(USE_AURA) | 220 #if defined(USE_AURA) |
221 #include "ui/aura/env.h" | 221 #include "ui/aura/env.h" |
222 #endif | 222 #endif // defined(USE_AURA) |
223 | 223 |
224 using content::BrowserThread; | 224 using content::BrowserThread; |
225 | 225 |
226 namespace { | 226 namespace { |
227 | 227 |
228 // This function provides some ways to test crash and assertion handling | 228 // This function provides some ways to test crash and assertion handling |
229 // behavior of the program. | 229 // behavior of the program. |
230 void HandleTestParameters(const base::CommandLine& command_line) { | 230 void HandleTestParameters(const base::CommandLine& command_line) { |
231 // This parameter causes a null pointer crash (crash reporter trigger). | 231 // This parameter causes a null pointer crash (crash reporter trigger). |
232 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { | 232 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 #if defined(OS_CHROMEOS) | 311 #if defined(OS_CHROMEOS) |
312 if (parsed_command_line.HasSwitch(chromeos::switches::kLoginManager)) { | 312 if (parsed_command_line.HasSwitch(chromeos::switches::kLoginManager)) { |
313 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); | 313 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); |
314 // Ensure that we start with owner's locale. | 314 // Ensure that we start with owner's locale. |
315 if (!owner_locale.empty() && | 315 if (!owner_locale.empty() && |
316 local_state->GetString(prefs::kApplicationLocale) != owner_locale && | 316 local_state->GetString(prefs::kApplicationLocale) != owner_locale && |
317 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { | 317 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { |
318 local_state->SetString(prefs::kApplicationLocale, owner_locale); | 318 local_state->SetString(prefs::kApplicationLocale, owner_locale); |
319 } | 319 } |
320 } | 320 } |
321 #endif | 321 #endif // defined(OS_CHROMEOS) |
322 | 322 |
323 return local_state; | 323 return local_state; |
324 } | 324 } |
325 | 325 |
326 // Initializes the primary profile, possibly doing some user prompting to pick | 326 // Initializes the primary profile, possibly doing some user prompting to pick |
327 // a fallback profile. Returns the newly created profile, or NULL if startup | 327 // a fallback profile. Returns the newly created profile, or NULL if startup |
328 // should not continue. | 328 // should not continue. |
329 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, | 329 Profile* CreatePrimaryProfile(const content::MainFunctionParams& parameters, |
330 const base::FilePath& user_data_dir, | 330 const base::FilePath& user_data_dir, |
331 const base::CommandLine& parsed_command_line) { | 331 const base::CommandLine& parsed_command_line) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 profile && | 372 profile && |
373 !profile->IsGuestSession()) { | 373 !profile->IsGuestSession()) { |
374 ProfileInfoCache& cache = | 374 ProfileInfoCache& cache = |
375 g_browser_process->profile_manager()->GetProfileInfoCache(); | 375 g_browser_process->profile_manager()->GetProfileInfoCache(); |
376 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); | 376 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); |
377 | 377 |
378 if (cache.ProfileIsSigninRequiredAtIndex(profile_index)) | 378 if (cache.ProfileIsSigninRequiredAtIndex(profile_index)) |
379 profile = g_browser_process->profile_manager()->GetProfile( | 379 profile = g_browser_process->profile_manager()->GetProfile( |
380 ProfileManager::GetGuestProfilePath()); | 380 ProfileManager::GetGuestProfilePath()); |
381 } | 381 } |
382 #endif | 382 #endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) |
383 if (profile) { | 383 if (profile) { |
384 UMA_HISTOGRAM_LONG_TIMES( | 384 UMA_HISTOGRAM_LONG_TIMES( |
385 "Startup.CreateFirstProfile", base::Time::Now() - start); | 385 "Startup.CreateFirstProfile", base::Time::Now() - start); |
386 return profile; | 386 return profile; |
387 } | 387 } |
388 | 388 |
389 #if !defined(OS_WIN) | 389 #if !defined(OS_WIN) |
390 // TODO(port): fix this. See comments near the definition of | 390 // TODO(port): fix this. See comments near the definition of |
391 // user_data_dir. It is better to CHECK-fail here than it is to | 391 // user_data_dir. It is better to CHECK-fail here than it is to |
392 // silently exit because of missing code in the above test. | 392 // silently exit because of missing code in the above test. |
393 CHECK(profile) << "Cannot get default profile."; | 393 CHECK(profile) << "Cannot get default profile."; |
394 #endif | 394 #endif // !defined(OS_WIN) |
395 | 395 |
396 return NULL; | 396 return NULL; |
397 } | 397 } |
398 | 398 |
399 #if defined(OS_MACOSX) | 399 #if defined(OS_MACOSX) |
400 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 400 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
401 SecKeychainCallbackInfo* info, void* context) { | 401 SecKeychainCallbackInfo* info, void* context) { |
402 return noErr; | 402 return noErr; |
403 } | 403 } |
404 #endif | 404 #endif // defined(OS_MACOSX) |
405 | 405 |
406 void RegisterComponentsForUpdate() { | 406 void RegisterComponentsForUpdate() { |
407 component_updater::ComponentUpdateService* cus = | 407 component_updater::ComponentUpdateService* cus = |
408 g_browser_process->component_updater(); | 408 g_browser_process->component_updater(); |
409 | 409 |
410 // Registration can be before or after cus->Start() so it is ok to post | 410 // Registration can be before or after cus->Start() so it is ok to post |
411 // a task to the UI thread to do registration once you done the necessary | 411 // a task to the UI thread to do registration once you done the necessary |
412 // file IO to know you existing component version. | 412 // file IO to know you existing component version. |
413 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) | 413 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
414 RegisterRecoveryComponent(cus, g_browser_process->local_state()); | 414 RegisterRecoveryComponent(cus, g_browser_process->local_state()); |
415 RegisterPepperFlashComponent(cus); | 415 RegisterPepperFlashComponent(cus); |
416 RegisterSwiftShaderComponent(cus); | 416 RegisterSwiftShaderComponent(cus); |
417 RegisterWidevineCdmComponent(cus); | 417 RegisterWidevineCdmComponent(cus); |
418 #endif | 418 #endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) |
419 | 419 |
420 #if !defined(DISABLE_NACL) && !defined(OS_ANDROID) | 420 #if !defined(DISABLE_NACL) && !defined(OS_ANDROID) |
421 #if defined(OS_CHROMEOS) | 421 #if defined(OS_CHROMEOS) |
422 // PNaCl on Chrome OS is on rootfs and there is no need to download it. But | 422 // PNaCl on Chrome OS is on rootfs and there is no need to download it. But |
423 // Chrome4ChromeOS on Linux doesn't contain PNaCl so enable component | 423 // Chrome4ChromeOS on Linux doesn't contain PNaCl so enable component |
424 // installer when running on Linux. See crbug.com/422121 for more details. | 424 // installer when running on Linux. See crbug.com/422121 for more details. |
425 if (!base::SysInfo::IsRunningOnChromeOS()) | 425 if (!base::SysInfo::IsRunningOnChromeOS()) |
426 #endif | 426 #endif // defined(OS_CHROMEOS) |
427 g_browser_process->pnacl_component_installer()->RegisterPnaclComponent(cus); | 427 g_browser_process->pnacl_component_installer()->RegisterPnaclComponent(cus); |
428 #endif | 428 #endif // !defined(DISABLE_NACL) && !defined(OS_ANDROID) |
429 | 429 |
430 // Registration of the CLD Component is a no-op unless the CLD data source has | 430 // Registration of the CLD Component is a no-op unless the CLD data source has |
431 // been configured to be the "Component" data source. | 431 // been configured to be the "Component" data source. |
432 RegisterCldComponent(cus); | 432 RegisterCldComponent(cus); |
433 | 433 |
434 component_updater::SupervisedUserWhitelistInstaller* whitelist_installer = | 434 component_updater::SupervisedUserWhitelistInstaller* whitelist_installer = |
435 g_browser_process->supervised_user_whitelist_installer(); | 435 g_browser_process->supervised_user_whitelist_installer(); |
436 whitelist_installer->RegisterComponents(); | 436 whitelist_installer->RegisterComponents(); |
437 | 437 |
438 base::FilePath path; | 438 base::FilePath path; |
439 if (PathService::Get(chrome::DIR_USER_DATA, &path)) { | 439 if (PathService::Get(chrome::DIR_USER_DATA, &path)) { |
440 #if defined(OS_ANDROID) | 440 #if defined(OS_ANDROID) |
441 // The CRLSet component was enabled for some releases. This code attempts to | 441 // The CRLSet component was enabled for some releases. This code attempts to |
442 // delete it from the local disk of those how may have downloaded it. | 442 // delete it from the local disk of those how may have downloaded it. |
443 g_browser_process->crl_set_fetcher()->DeleteFromDisk(path); | 443 g_browser_process->crl_set_fetcher()->DeleteFromDisk(path); |
444 #elif !defined(OS_CHROMEOS) | 444 #elif !defined(OS_CHROMEOS) |
445 // CRLSetFetcher attempts to load a CRL set from either the local disk or | 445 // CRLSetFetcher attempts to load a CRL set from either the local disk or |
446 // network. | 446 // network. |
447 // For Chrome OS this registration is delayed until user login. | 447 // For Chrome OS this registration is delayed until user login. |
448 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus, path); | 448 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus, path); |
449 // Registration of the EV Whitelist component here is not necessary for: | 449 // Registration of the EV Whitelist component here is not necessary for: |
450 // 1. Android: Because it currently does not have the EV indicator. | 450 // 1. Android: Because it currently does not have the EV indicator. |
451 // 2. Chrome OS: On Chrome OS this registration is delayed until user login. | 451 // 2. Chrome OS: On Chrome OS this registration is delayed until user login. |
452 RegisterEVWhitelistComponent(cus, path); | 452 RegisterEVWhitelistComponent(cus, path); |
453 #endif | 453 #endif // defined(OS_ANDROID) |
454 } | 454 } |
455 | 455 |
456 #if defined(OS_WIN) | 456 #if defined(OS_WIN) |
457 RegisterSwReporterComponent(cus, g_browser_process->local_state()); | 457 RegisterSwReporterComponent(cus, g_browser_process->local_state()); |
458 RegisterCAPSComponent(cus); | 458 RegisterCAPSComponent(cus); |
459 #endif | 459 #endif // defined(OS_WIN) |
460 | 460 |
461 cus->Start(); | 461 cus->Start(); |
462 } | 462 } |
463 | 463 |
464 #if !defined(OS_ANDROID) | 464 #if !defined(OS_ANDROID) |
465 bool ProcessSingletonNotificationCallback( | 465 bool ProcessSingletonNotificationCallback( |
466 const base::CommandLine& command_line, | 466 const base::CommandLine& command_line, |
467 const base::FilePath& current_directory) { | 467 const base::FilePath& current_directory) { |
468 // Drop the request if the browser process is already in shutdown path. | 468 // Drop the request if the browser process is already in shutdown path. |
469 if (!g_browser_process || g_browser_process->IsShuttingDown()) { | 469 if (!g_browser_process || g_browser_process->IsShuttingDown()) { |
470 #if defined(OS_WIN) | 470 #if defined(OS_WIN) |
471 browser_watcher::ExitFunnel::RecordSingleEvent( | 471 browser_watcher::ExitFunnel::RecordSingleEvent( |
472 chrome::kBrowserExitCodesRegistryPath, | 472 chrome::kBrowserExitCodesRegistryPath, |
473 L"ProcessSingletonIsShuttingDown"); | 473 L"ProcessSingletonIsShuttingDown"); |
474 #endif | 474 #endif // defined(OS_WIN) |
475 | 475 |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { | 479 if (command_line.HasSwitch(switches::kOriginalProcessStartTime)) { |
480 std::string start_time_string = | 480 std::string start_time_string = |
481 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); | 481 command_line.GetSwitchValueASCII(switches::kOriginalProcessStartTime); |
482 int64 remote_start_time; | 482 int64 remote_start_time; |
483 if (base::StringToInt64(start_time_string, &remote_start_time)) { | 483 if (base::StringToInt64(start_time_string, &remote_start_time)) { |
484 base::TimeDelta elapsed = | 484 base::TimeDelta elapsed = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 }; | 549 }; |
550 | 550 |
551 } // namespace | 551 } // namespace |
552 | 552 |
553 namespace chrome_browser { | 553 namespace chrome_browser { |
554 | 554 |
555 // This error message is not localized because we failed to load the | 555 // This error message is not localized because we failed to load the |
556 // localization data files. | 556 // localization data files. |
557 #if defined(OS_WIN) | 557 #if defined(OS_WIN) |
558 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 558 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
559 #endif | 559 #endif // defined(OS_WIN) |
560 | 560 |
561 #if defined(OS_WIN) | 561 #if defined(OS_WIN) |
562 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969 | 562 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969 |
563 const char kMissingLocaleDataMessage[] = | 563 const char kMissingLocaleDataMessage[] = |
564 "Unable to find locale data files. Please reinstall."; | 564 "Unable to find locale data files. Please reinstall."; |
565 #endif | 565 #endif // defined(OS_WIN) |
566 | 566 |
567 } // namespace chrome_browser | 567 } // namespace chrome_browser |
568 | 568 |
569 // BrowserMainParts ------------------------------------------------------------ | 569 // BrowserMainParts ------------------------------------------------------------ |
570 | 570 |
571 ChromeBrowserMainParts::ChromeBrowserMainParts( | 571 ChromeBrowserMainParts::ChromeBrowserMainParts( |
572 const content::MainFunctionParams& parameters) | 572 const content::MainFunctionParams& parameters) |
573 : parameters_(parameters), | 573 : parameters_(parameters), |
574 parsed_command_line_(parameters.command_line), | 574 parsed_command_line_(parameters.command_line), |
575 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 575 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 return; | 695 return; |
696 | 696 |
697 #if defined(OS_ANDROID) | 697 #if defined(OS_ANDROID) |
698 // On Android the first run is handled in Java code, and the C++ side of | 698 // On Android the first run is handled in Java code, and the C++ side of |
699 // Chrome doesn't know if this is the first run. This will cause some | 699 // Chrome doesn't know if this is the first run. This will cause some |
700 // inaccuracy in the UMA statistics, but this should be minor (first runs are | 700 // inaccuracy in the UMA statistics, but this should be minor (first runs are |
701 // rare). | 701 // rare). |
702 bool is_first_run = false; | 702 bool is_first_run = false; |
703 #else | 703 #else |
704 bool is_first_run = first_run::IsChromeFirstRun(); | 704 bool is_first_run = first_run::IsChromeFirstRun(); |
705 #endif | 705 #endif // defined(OS_ANDROID) |
706 | 706 |
707 // CurrentProcessInfo::CreationTime() is currently only implemented on some | 707 // CurrentProcessInfo::CreationTime() is currently only implemented on some |
708 // platforms. | 708 // platforms. |
709 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 709 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
710 const base::Time process_creation_time = | 710 const base::Time process_creation_time = |
711 base::CurrentProcessInfo::CreationTime(); | 711 base::CurrentProcessInfo::CreationTime(); |
712 | 712 |
713 if (!is_first_run && !process_creation_time.is_null()) { | 713 if (!is_first_run && !process_creation_time.is_null()) { |
714 base::TimeDelta delay = base::Time::Now() - process_creation_time; | 714 base::TimeDelta delay = base::Time::Now() - process_creation_time; |
715 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserMessageLoopStartTime", delay); | 715 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserMessageLoopStartTime", delay); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 | 780 |
781 int ChromeBrowserMainParts::PreCreateThreads() { | 781 int ChromeBrowserMainParts::PreCreateThreads() { |
782 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); | 782 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); |
783 result_code_ = PreCreateThreadsImpl(); | 783 result_code_ = PreCreateThreadsImpl(); |
784 | 784 |
785 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { | 785 if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { |
786 #if !defined(OS_ANDROID) | 786 #if !defined(OS_ANDROID) |
787 // These members must be initialized before exiting this function normally. | 787 // These members must be initialized before exiting this function normally. |
788 DCHECK(master_prefs_.get()); | 788 DCHECK(master_prefs_.get()); |
789 DCHECK(browser_creator_.get()); | 789 DCHECK(browser_creator_.get()); |
790 #endif | 790 #endif // !defined(OS_ANDROID) |
791 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 791 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
792 chrome_extra_parts_[i]->PreCreateThreads(); | 792 chrome_extra_parts_[i]->PreCreateThreads(); |
793 } | 793 } |
794 | 794 |
795 return result_code_; | 795 return result_code_; |
796 } | 796 } |
797 | 797 |
798 int ChromeBrowserMainParts::PreCreateThreadsImpl() { | 798 int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
799 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") | 799 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") |
800 run_message_loop_ = false; | 800 run_message_loop_ = false; |
801 #if !defined(OS_ANDROID) | 801 #if !defined(OS_ANDROID) |
802 chrome::MaybeShowInvalidUserDataDirWarningDialog(); | 802 chrome::MaybeShowInvalidUserDataDirWarningDialog(); |
803 #endif | 803 #endif // !defined(OS_ANDROID) |
804 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) | 804 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) |
805 return chrome::RESULT_CODE_MISSING_DATA; | 805 return chrome::RESULT_CODE_MISSING_DATA; |
806 | 806 |
807 // Force MediaCaptureDevicesDispatcher to be created on UI thread. | 807 // Force MediaCaptureDevicesDispatcher to be created on UI thread. |
808 MediaCaptureDevicesDispatcher::GetInstance(); | 808 MediaCaptureDevicesDispatcher::GetInstance(); |
809 | 809 |
810 // Android's first run is done in Java instead of native. | 810 // Android's first run is done in Java instead of native. |
811 #if !defined(OS_ANDROID) | 811 #if !defined(OS_ANDROID) |
812 process_singleton_.reset(new ChromeProcessSingleton( | 812 process_singleton_.reset(new ChromeProcessSingleton( |
813 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 813 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
814 | 814 |
815 // Cache first run state early. | 815 // Cache first run state early. |
816 first_run::IsChromeFirstRun(); | 816 first_run::IsChromeFirstRun(); |
817 #endif | 817 #endif // !defined(OS_ANDROID) |
818 | 818 |
819 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | 819 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
820 JsonPrefStore::GetTaskRunnerForFile( | 820 JsonPrefStore::GetTaskRunnerForFile( |
821 base::FilePath(chrome::kLocalStorePoolName), | 821 base::FilePath(chrome::kLocalStorePoolName), |
822 BrowserThread::GetBlockingPool()); | 822 BrowserThread::GetBlockingPool()); |
823 | 823 |
824 { | 824 { |
825 TRACE_EVENT0("startup", | 825 TRACE_EVENT0("startup", |
826 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); | 826 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); |
827 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner.get(), | 827 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner.get(), |
(...skipping 25 matching lines...) Expand all Loading... | |
853 local_state_ = InitializeLocalState( | 853 local_state_ = InitializeLocalState( |
854 local_state_task_runner.get(), parsed_command_line()); | 854 local_state_task_runner.get(), parsed_command_line()); |
855 | 855 |
856 #if !defined(OS_ANDROID) | 856 #if !defined(OS_ANDROID) |
857 // These members must be initialized before returning from this function. | 857 // These members must be initialized before returning from this function. |
858 master_prefs_.reset(new first_run::MasterPrefs); | 858 master_prefs_.reset(new first_run::MasterPrefs); |
859 // Android doesn't use StartupBrowserCreator. | 859 // Android doesn't use StartupBrowserCreator. |
860 browser_creator_.reset(new StartupBrowserCreator); | 860 browser_creator_.reset(new StartupBrowserCreator); |
861 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver | 861 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver |
862 chrome::UMABrowsingActivityObserver::Init(); | 862 chrome::UMABrowsingActivityObserver::Init(); |
863 #endif | 863 #endif // !defined(OS_ANDROID) |
864 | 864 |
865 #if !defined(OS_CHROMEOS) | 865 #if !defined(OS_CHROMEOS) |
866 // Convert active labs into switches. This needs to be done before | 866 // Convert active labs into switches. This needs to be done before |
867 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are | 867 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are |
868 // affected by experiment flags (--touch-optimized-ui in particular). | 868 // affected by experiment flags (--touch-optimized-ui in particular). |
869 // On ChromeOS system level flags are applied from the device settings from | 869 // On ChromeOS system level flags are applied from the device settings from |
870 // the session manager. | 870 // the session manager. |
871 { | 871 { |
872 TRACE_EVENT0("startup", | 872 TRACE_EVENT0("startup", |
873 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); | 873 "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); |
874 about_flags::PrefServiceFlagsStorage flags_storage_( | 874 about_flags::PrefServiceFlagsStorage flags_storage_( |
875 g_browser_process->local_state()); | 875 g_browser_process->local_state()); |
876 about_flags::ConvertFlagsToSwitches(&flags_storage_, | 876 about_flags::ConvertFlagsToSwitches(&flags_storage_, |
877 base::CommandLine::ForCurrentProcess(), | 877 base::CommandLine::ForCurrentProcess(), |
878 about_flags::kAddSentinels); | 878 about_flags::kAddSentinels); |
879 } | 879 } |
880 #endif | 880 #endif // !defined(OS_CHROMEOS) |
881 | 881 |
882 local_state_->UpdateCommandLinePrefStore( | 882 local_state_->UpdateCommandLinePrefStore( |
883 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())); | 883 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())); |
884 | 884 |
885 // Reset the command line in the crash report details, since we may have | 885 // Reset the command line in the crash report details, since we may have |
886 // just changed it to include experiments. | 886 // just changed it to include experiments. |
887 crash_keys::SetSwitchesFromCommandLine( | 887 crash_keys::SetSwitchesFromCommandLine( |
888 base::CommandLine::ForCurrentProcess()); | 888 base::CommandLine::ForCurrentProcess()); |
889 | 889 |
890 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is | 890 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 local_state_->SetInt64(prefs::kVariationsSeedDate, | 975 local_state_->SetInt64(prefs::kVariationsSeedDate, |
976 base::Time::Now().ToInternalValue()); | 976 base::Time::Now().ToInternalValue()); |
977 } | 977 } |
978 | 978 |
979 if (!master_prefs_->suppress_default_browser_prompt_for_version.empty()) { | 979 if (!master_prefs_->suppress_default_browser_prompt_for_version.empty()) { |
980 local_state_->SetString( | 980 local_state_->SetString( |
981 prefs::kBrowserSuppressDefaultBrowserPrompt, | 981 prefs::kBrowserSuppressDefaultBrowserPrompt, |
982 master_prefs_->suppress_default_browser_prompt_for_version); | 982 master_prefs_->suppress_default_browser_prompt_for_version); |
983 } | 983 } |
984 } | 984 } |
985 #endif | 985 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
986 | 986 |
987 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) | 987 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) |
988 // Set the product channel for crash reports. | 988 // Set the product channel for crash reports. |
989 base::debug::SetCrashKeyValue(crash_keys::kChannel, | 989 base::debug::SetCrashKeyValue(crash_keys::kChannel, |
990 chrome::VersionInfo::GetVersionStringModifier()); | 990 chrome::VersionInfo::GetVersionStringModifier()); |
991 #endif | 991 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) |
992 | 992 |
993 // Initialize tracking synchronizer system. | 993 // Initialize tracking synchronizer system. |
994 tracking_synchronizer_ = new metrics::TrackingSynchronizer(); | 994 tracking_synchronizer_ = new metrics::TrackingSynchronizer(); |
995 | 995 |
996 #if defined(OS_MACOSX) | 996 #if defined(OS_MACOSX) |
997 // Get the Keychain API to register for distributed notifications on the main | 997 // Get the Keychain API to register for distributed notifications on the main |
998 // thread, which has a proper CFRunloop, instead of later on the I/O thread, | 998 // thread, which has a proper CFRunloop, instead of later on the I/O thread, |
999 // which doesn't. This ensures those notifications will get delivered | 999 // which doesn't. This ensures those notifications will get delivered |
1000 // properly. See issue 37766. | 1000 // properly. See issue 37766. |
1001 // (Note that the callback mask here is empty. I don't want to register for | 1001 // (Note that the callback mask here is empty. I don't want to register for |
1002 // any callbacks, I just want to initialize the mechanism.) | 1002 // any callbacks, I just want to initialize the mechanism.) |
1003 SecKeychainAddCallback(&KeychainCallback, 0, NULL); | 1003 SecKeychainAddCallback(&KeychainCallback, 0, NULL); |
1004 #endif | 1004 #endif // defined(OS_MACOSX) |
1005 | 1005 |
1006 #if defined(OS_CHROMEOS) | 1006 #if defined(OS_CHROMEOS) |
1007 // Must be done after g_browser_process is constructed, before | 1007 // Must be done after g_browser_process is constructed, before |
1008 // SetupMetricsAndFieldTrials(). | 1008 // SetupMetricsAndFieldTrials(). |
1009 chromeos::CrosSettings::Initialize(); | 1009 chromeos::CrosSettings::Initialize(); |
1010 #endif | 1010 #endif // defined(OS_CHROMEOS) |
1011 | 1011 |
1012 // Now the command line has been mutated based on about:flags, we can setup | 1012 // Now the command line has been mutated based on about:flags, we can setup |
1013 // metrics and initialize field trials. The field trials are needed by | 1013 // metrics and initialize field trials. The field trials are needed by |
1014 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. | 1014 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. |
1015 SetupMetricsAndFieldTrials(); | 1015 SetupMetricsAndFieldTrials(); |
1016 | 1016 |
1017 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. | 1017 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. |
1018 browser_process_->PreCreateThreads(); | 1018 browser_process_->PreCreateThreads(); |
1019 | 1019 |
1020 return content::RESULT_CODE_NORMAL_EXIT; | 1020 return content::RESULT_CODE_NORMAL_EXIT; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 if (profiles_to_delete.size()) { | 1066 if (profiles_to_delete.size()) { |
1067 for (size_t i = 0; i < profiles_to_delete.size(); ++i) { | 1067 for (size_t i = 0; i < profiles_to_delete.size(); ++i) { |
1068 profile_manager->ScheduleProfileForDeletion( | 1068 profile_manager->ScheduleProfileForDeletion( |
1069 profiles_to_delete[i], ProfileManager::CreateCallback()); | 1069 profiles_to_delete[i], ProfileManager::CreateCallback()); |
1070 } | 1070 } |
1071 // Clean up stale profiles immediately after browser start. | 1071 // Clean up stale profiles immediately after browser start. |
1072 BrowserThread::PostTask( | 1072 BrowserThread::PostTask( |
1073 BrowserThread::FILE, FROM_HERE, | 1073 BrowserThread::FILE, FROM_HERE, |
1074 base::Bind(&ProfileManager::CleanUpStaleProfiles, profiles_to_delete)); | 1074 base::Bind(&ProfileManager::CleanUpStaleProfiles, profiles_to_delete)); |
1075 } | 1075 } |
1076 #endif // OS_ANDROID | 1076 #endif // !defined(OS_ANDROID) |
1077 | 1077 |
1078 #if defined(ENABLE_EXTENSIONS) | 1078 #if defined(ENABLE_EXTENSIONS) |
1079 javascript_dialog_extensions_client::InstallClient(); | 1079 javascript_dialog_extensions_client::InstallClient(); |
1080 #endif | 1080 #endif // defined(ENABLE_EXTENSIONS) |
1081 | 1081 |
1082 #if !defined(OS_IOS) | 1082 #if !defined(OS_IOS) |
1083 InstallChromeJavaScriptNativeDialogFactory(); | 1083 InstallChromeJavaScriptNativeDialogFactory(); |
1084 #endif | 1084 #endif // !defined(OS_IOS) |
1085 } | 1085 } |
1086 | 1086 |
1087 void ChromeBrowserMainParts::PostProfileInit() { | 1087 void ChromeBrowserMainParts::PostProfileInit() { |
1088 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); | 1088 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); |
1089 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); | 1089 LaunchDevToolsHandlerIfNeeded(parsed_command_line()); |
1090 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1090 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1091 chrome_extra_parts_[i]->PostProfileInit(); | 1091 chrome_extra_parts_[i]->PostProfileInit(); |
1092 } | 1092 } |
1093 | 1093 |
1094 void ChromeBrowserMainParts::PreBrowserStart() { | 1094 void ChromeBrowserMainParts::PreBrowserStart() { |
1095 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreBrowserStart"); | 1095 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreBrowserStart"); |
1096 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1096 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1097 chrome_extra_parts_[i]->PreBrowserStart(); | 1097 chrome_extra_parts_[i]->PreBrowserStart(); |
1098 | 1098 |
1099 three_d_observer_.reset(new ThreeDAPIObserver()); | 1099 three_d_observer_.reset(new ThreeDAPIObserver()); |
1100 } | 1100 } |
1101 | 1101 |
1102 void ChromeBrowserMainParts::PostBrowserStart() { | 1102 void ChromeBrowserMainParts::PostBrowserStart() { |
1103 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostBrowserStart"); | 1103 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostBrowserStart"); |
1104 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1104 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1105 chrome_extra_parts_[i]->PostBrowserStart(); | 1105 chrome_extra_parts_[i]->PostBrowserStart(); |
1106 #if !defined(OS_ANDROID) | 1106 #if !defined(OS_ANDROID) |
1107 // Allow ProcessSingleton to process messages. | 1107 // Allow ProcessSingleton to process messages. |
1108 process_singleton_->Unlock(); | 1108 process_singleton_->Unlock(); |
1109 #endif | 1109 #endif // !defined(OS_ANDROID) |
1110 #if defined(ENABLE_WEBRTC) | 1110 #if defined(ENABLE_WEBRTC) |
1111 // Set up a task to delete old WebRTC log files for all profiles. Use a delay | 1111 // Set up a task to delete old WebRTC log files for all profiles. Use a delay |
1112 // to reduce the impact on startup time. | 1112 // to reduce the impact on startup time. |
1113 BrowserThread::PostDelayedTask( | 1113 BrowserThread::PostDelayedTask( |
1114 BrowserThread::UI, | 1114 BrowserThread::UI, |
1115 FROM_HERE, | 1115 FROM_HERE, |
1116 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), | 1116 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), |
1117 base::TimeDelta::FromMinutes(1)); | 1117 base::TimeDelta::FromMinutes(1)); |
1118 #endif | 1118 #endif // defined(ENABLE_WEBRTC) |
1119 } | 1119 } |
1120 | 1120 |
1121 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1121 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
1122 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); | 1122 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); |
1123 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); | 1123 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime"); |
1124 const base::TimeTicks start_time_step1 = base::TimeTicks::Now(); | |
1124 // Android updates the metrics service dynamically depending on whether the | 1125 // Android updates the metrics service dynamically depending on whether the |
1125 // application is in the foreground or not. Do not start here. | 1126 // application is in the foreground or not. Do not start here. |
1126 #if !defined(OS_ANDROID) | 1127 #if !defined(OS_ANDROID) |
1127 // Now that the file thread has been started, start recording. | 1128 // Now that the file thread has been started, start recording. |
1128 StartMetricsRecording(); | 1129 StartMetricsRecording(); |
1129 #endif | 1130 #endif // !defined(OS_ANDROID) |
1130 | 1131 |
1131 if (!base::debug::BeingDebugged()) { | 1132 if (!base::debug::BeingDebugged()) { |
1132 // Create watchdog thread after creating all other threads because it will | 1133 // Create watchdog thread after creating all other threads because it will |
1133 // watch the other threads and they must be running. | 1134 // watch the other threads and they must be running. |
1134 browser_process_->watchdog_thread(); | 1135 browser_process_->watchdog_thread(); |
1135 } | 1136 } |
1136 | 1137 |
1137 // Do any initializating in the browser process that requires all threads | 1138 // Do any initializating in the browser process that requires all threads |
1138 // running. | 1139 // running. |
1139 browser_process_->PreMainMessageLoopRun(); | 1140 browser_process_->PreMainMessageLoopRun(); |
(...skipping 14 matching lines...) Expand all Loading... | |
1154 } | 1155 } |
1155 | 1156 |
1156 if (parsed_command_line().HasSwitch(switches::kHideIcons) || | 1157 if (parsed_command_line().HasSwitch(switches::kHideIcons) || |
1157 parsed_command_line().HasSwitch(switches::kShowIcons)) { | 1158 parsed_command_line().HasSwitch(switches::kShowIcons)) { |
1158 return ChromeBrowserMainPartsWin::HandleIconsCommands( | 1159 return ChromeBrowserMainPartsWin::HandleIconsCommands( |
1159 parsed_command_line_); | 1160 parsed_command_line_); |
1160 } | 1161 } |
1161 | 1162 |
1162 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( | 1163 ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory( |
1163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 1164 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
1164 #endif | 1165 #endif // defined(OS_WIN) |
1165 | 1166 |
1166 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { | 1167 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { |
1167 return ShellIntegration::SetAsDefaultBrowser() ? | 1168 return ShellIntegration::SetAsDefaultBrowser() ? |
1168 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : | 1169 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : |
1169 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); | 1170 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); |
1170 } | 1171 } |
1171 | 1172 |
1172 #if defined(USE_AURA) | 1173 #if defined(USE_AURA) |
1173 // Make sure aura::Env has been initialized. | 1174 // Make sure aura::Env has been initialized. |
1174 CHECK(aura::Env::GetInstance()); | 1175 CHECK(aura::Env::GetInstance()); |
1175 #endif | 1176 #endif // defined(USE_AURA) |
1176 | 1177 |
1177 // Android doesn't support extensions and doesn't implement ProcessSingleton. | 1178 // Android doesn't support extensions and doesn't implement ProcessSingleton. |
1178 #if !defined(OS_ANDROID) | 1179 #if !defined(OS_ANDROID) |
1179 // If the command line specifies --pack-extension, attempt the pack extension | 1180 // If the command line specifies --pack-extension, attempt the pack extension |
1180 // startup action and exit. | 1181 // startup action and exit. |
1181 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1182 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1182 extensions::StartupHelper extension_startup_helper; | 1183 extensions::StartupHelper extension_startup_helper; |
1183 if (extension_startup_helper.PackExtension(parsed_command_line())) | 1184 if (extension_startup_helper.PackExtension(parsed_command_line())) |
1184 return content::RESULT_CODE_NORMAL_EXIT; | 1185 return content::RESULT_CODE_NORMAL_EXIT; |
1185 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1186 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
(...skipping 12 matching lines...) Expand all Loading... | |
1198 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1199 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
1199 switch (notify_result_) { | 1200 switch (notify_result_) { |
1200 case ProcessSingleton::PROCESS_NONE: | 1201 case ProcessSingleton::PROCESS_NONE: |
1201 // No process already running, fall through to starting a new one. | 1202 // No process already running, fall through to starting a new one. |
1202 break; | 1203 break; |
1203 | 1204 |
1204 case ProcessSingleton::PROCESS_NOTIFIED: | 1205 case ProcessSingleton::PROCESS_NOTIFIED: |
1205 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1206 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1206 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( | 1207 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( |
1207 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1208 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1208 #endif | 1209 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
1210 | |
1209 // Having a differentiated return type for testing allows for tests to | 1211 // Having a differentiated return type for testing allows for tests to |
1210 // verify proper handling of some switches. When not testing, stick to | 1212 // verify proper handling of some switches. When not testing, stick to |
1211 // the standard Unix convention of returning zero when things went as | 1213 // the standard Unix convention of returning zero when things went as |
1212 // expected. | 1214 // expected. |
1213 if (parsed_command_line().HasSwitch(switches::kTestType)) | 1215 if (parsed_command_line().HasSwitch(switches::kTestType)) |
1214 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; | 1216 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; |
1215 return content::RESULT_CODE_NORMAL_EXIT; | 1217 return content::RESULT_CODE_NORMAL_EXIT; |
1216 | 1218 |
1217 case ProcessSingleton::PROFILE_IN_USE: | 1219 case ProcessSingleton::PROFILE_IN_USE: |
1218 return chrome::RESULT_CODE_PROFILE_IN_USE; | 1220 return chrome::RESULT_CODE_PROFILE_IN_USE; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1288 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1287 | 1289 |
1288 // Desktop construction occurs here, (required before profile creation). | 1290 // Desktop construction occurs here, (required before profile creation). |
1289 PreProfileInit(); | 1291 PreProfileInit(); |
1290 | 1292 |
1291 // Profile creation ---------------------------------------------------------- | 1293 // Profile creation ---------------------------------------------------------- |
1292 | 1294 |
1293 metrics::MetricsService::SetExecutionPhase( | 1295 metrics::MetricsService::SetExecutionPhase( |
1294 metrics::MetricsService::CREATE_PROFILE, | 1296 metrics::MetricsService::CREATE_PROFILE, |
1295 g_browser_process->local_state()); | 1297 g_browser_process->local_state()); |
1298 | |
1299 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time", | |
1300 base::TimeTicks::Now() - start_time_step1); | |
1301 | |
1302 // This step is costly and is already measured in Startup.CreateFirstProfile | |
1303 // and more directly Profile.CreateAndInitializeProfile. | |
1296 profile_ = CreatePrimaryProfile(parameters(), | 1304 profile_ = CreatePrimaryProfile(parameters(), |
1297 user_data_dir_, | 1305 user_data_dir_, |
1298 parsed_command_line()); | 1306 parsed_command_line()); |
1299 if (!profile_) | 1307 if (!profile_) |
1300 return content::RESULT_CODE_NORMAL_EXIT; | 1308 return content::RESULT_CODE_NORMAL_EXIT; |
1301 | 1309 |
1302 #if !defined(OS_ANDROID) | 1310 #if !defined(OS_ANDROID) |
1311 const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); | |
1303 // The first run sentinel must be created after the process singleton was | 1312 // The first run sentinel must be created after the process singleton was |
1304 // grabbed and no early return paths were otherwise hit above. | 1313 // grabbed and no early return paths were otherwise hit above. |
1305 first_run::CreateSentinelIfNeeded(); | 1314 first_run::CreateSentinelIfNeeded(); |
1306 #endif // !defined(OS_ANDROID) | 1315 #endif // !defined(OS_ANDROID) |
1307 | 1316 |
1308 #if defined(ENABLE_BACKGROUND) | 1317 #if defined(ENABLE_BACKGROUND) |
1309 // Autoload any profiles which are running background apps. | 1318 // Autoload any profiles which are running background apps. |
1310 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1319 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
1311 browser_process_->profile_manager()->AutoloadProfiles(); | 1320 browser_process_->profile_manager()->AutoloadProfiles(); |
1312 #endif | 1321 #endif // defined(ENABLE_BACKGROUND) |
1313 // Post-profile init --------------------------------------------------------- | 1322 // Post-profile init --------------------------------------------------------- |
1314 | 1323 |
1315 TranslateService::Initialize(); | 1324 TranslateService::Initialize(); |
1316 | 1325 |
1317 // Needs to be done before PostProfileInit, since login manager on CrOS is | 1326 // Needs to be done before PostProfileInit, since login manager on CrOS is |
1318 // called inside PostProfileInit. | 1327 // called inside PostProfileInit. |
1319 content::WebUIControllerFactory::RegisterFactory( | 1328 content::WebUIControllerFactory::RegisterFactory( |
1320 ChromeWebUIControllerFactory::GetInstance()); | 1329 ChromeWebUIControllerFactory::GetInstance()); |
1321 | 1330 |
1322 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). | 1331 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). |
1323 // So make sure to create it before that. | 1332 // So make sure to create it before that. |
1324 #if !defined(DISABLE_NACL) | 1333 #if !defined(DISABLE_NACL) |
1325 NaClBrowserDelegateImpl* delegate = | 1334 NaClBrowserDelegateImpl* delegate = |
1326 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); | 1335 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); |
1327 nacl::NaClBrowser::SetDelegate(delegate); | 1336 nacl::NaClBrowser::SetDelegate(delegate); |
1328 #endif | 1337 #endif // !defined(DISABLE_NACL) |
1329 | 1338 |
1330 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. | 1339 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. |
1331 // (requires supporting early exit). | 1340 // (requires supporting early exit). |
1332 PostProfileInit(); | 1341 PostProfileInit(); |
1333 | 1342 |
1334 // Retrieve cached GL strings from local state and use them for GPU | 1343 // Retrieve cached GL strings from local state and use them for GPU |
1335 // blacklist decisions. | 1344 // blacklist decisions. |
1336 if (g_browser_process->gl_string_manager()) | 1345 if (g_browser_process->gl_string_manager()) |
1337 g_browser_process->gl_string_manager()->Initialize(); | 1346 g_browser_process->gl_string_manager()->Initialize(); |
1338 | 1347 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1382 parsed_command_line()); | 1391 parsed_command_line()); |
1383 } | 1392 } |
1384 | 1393 |
1385 // Verify that the profile is not on a network share and if so prepare to show | 1394 // Verify that the profile is not on a network share and if so prepare to show |
1386 // notification to the user. | 1395 // notification to the user. |
1387 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { | 1396 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { |
1388 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 1397 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
1389 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, | 1398 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, |
1390 profile_->GetPath())); | 1399 profile_->GetPath())); |
1391 } | 1400 } |
1392 #endif // OS_WIN | 1401 #endif // defined(OS_WIN) |
1393 | 1402 |
1394 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) | 1403 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) |
1395 // Init the RLZ library. This just binds the dll and schedules a task on the | 1404 // Init the RLZ library. This just binds the dll and schedules a task on the |
1396 // file thread to be run sometime later. If this is the first run we record | 1405 // file thread to be run sometime later. If this is the first run we record |
1397 // the installation event. | 1406 // the installation event. |
1398 PrefService* pref_service = profile_->GetPrefs(); | 1407 PrefService* pref_service = profile_->GetPrefs(); |
1399 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : | 1408 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : |
1400 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); | 1409 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); |
1401 // Negative ping delay means to send ping immediately after a first search is | 1410 // Negative ping delay means to send ping immediately after a first search is |
1402 // recorded. | 1411 // recorded. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1439 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) { | 1448 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) { |
1440 net::SdchManager::EnableSdchSupport(false); | 1449 net::SdchManager::EnableSdchSupport(false); |
1441 } | 1450 } |
1442 | 1451 |
1443 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) | 1452 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) |
1444 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { | 1453 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { |
1445 base::FilePath path = | 1454 base::FilePath path = |
1446 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); | 1455 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); |
1447 printing::PrintedDocument::set_debug_dump_path(path); | 1456 printing::PrintedDocument::set_debug_dump_path(path); |
1448 } | 1457 } |
1449 #endif | 1458 #endif // defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) |
1450 | 1459 |
1451 HandleTestParameters(parsed_command_line()); | 1460 HandleTestParameters(parsed_command_line()); |
1452 browser_process_->metrics_service()->RecordBreakpadHasDebugger( | 1461 browser_process_->metrics_service()->RecordBreakpadHasDebugger( |
1453 base::debug::BeingDebugged()); | 1462 base::debug::BeingDebugged()); |
1454 | 1463 |
1455 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( | 1464 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( |
1456 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1465 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
1457 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( | 1466 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( |
1458 browser_process_->GetApplicationLocale()); | 1467 browser_process_->GetApplicationLocale()); |
1459 | 1468 |
1460 // Start watching for hangs during startup. We disarm this hang detector when | 1469 // Start watching for hangs during startup. We disarm this hang detector when |
1461 // ThreadWatcher takes over or when browser is shutdown or when | 1470 // ThreadWatcher takes over or when browser is shutdown or when |
1462 // startup_watcher_ is deleted. | 1471 // startup_watcher_ is deleted. |
1463 metrics::MetricsService::SetExecutionPhase( | 1472 metrics::MetricsService::SetExecutionPhase( |
1464 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, | 1473 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, |
1465 g_browser_process->local_state()); | 1474 g_browser_process->local_state()); |
1466 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); | 1475 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); |
1467 | 1476 |
1468 // On mobile, need for clean shutdown arises only when the application comes | 1477 // On mobile, need for clean shutdown arises only when the application comes |
1469 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). | 1478 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). |
1470 // http://crbug.com/179143 | 1479 // http://crbug.com/179143 |
1471 #if !defined(OS_ANDROID) | 1480 #if !defined(OS_ANDROID) |
1472 // Start watching for a hang. | 1481 // Start watching for a hang. |
1473 browser_process_->metrics_service()->LogNeedForCleanShutdown(); | 1482 browser_process_->metrics_service()->LogNeedForCleanShutdown(); |
1474 #endif | 1483 #endif // !defined(OS_ANDROID) |
1475 | 1484 |
1476 #if defined(ENABLE_PRINT_PREVIEW) | 1485 #if defined(ENABLE_PRINT_PREVIEW) |
1477 // Create the instance of the cloud print proxy service so that it can launch | 1486 // Create the instance of the cloud print proxy service so that it can launch |
1478 // the service process if needed. This is needed because the service process | 1487 // the service process if needed. This is needed because the service process |
1479 // might have shutdown because an update was available. | 1488 // might have shutdown because an update was available. |
1480 // TODO(torne): this should maybe be done with | 1489 // TODO(torne): this should maybe be done with |
1481 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() | 1490 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() |
1482 // instead? | 1491 // instead? |
1483 CloudPrintProxyServiceFactory::GetForProfile(profile_); | 1492 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
1484 #endif | 1493 #endif // defined(ENABLE_PRINT_PREVIEW) |
1485 | 1494 |
1486 // Start watching all browser threads for responsiveness. | 1495 // Start watching all browser threads for responsiveness. |
1487 metrics::MetricsService::SetExecutionPhase( | 1496 metrics::MetricsService::SetExecutionPhase( |
1488 metrics::MetricsService::THREAD_WATCHER_START, | 1497 metrics::MetricsService::THREAD_WATCHER_START, |
1489 g_browser_process->local_state()); | 1498 g_browser_process->local_state()); |
1490 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1499 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
1491 | 1500 |
1492 #if defined(OS_ANDROID) | 1501 #if defined(OS_ANDROID) |
1493 ThreadWatcherAndroid::RegisterApplicationStatusListener(); | 1502 ThreadWatcherAndroid::RegisterApplicationStatusListener(); |
1494 #endif | 1503 #endif // defined(OS_ANDROID) |
1495 | 1504 |
1496 #if !defined(DISABLE_NACL) | 1505 #if !defined(DISABLE_NACL) |
1497 BrowserThread::PostTask( | 1506 BrowserThread::PostTask( |
1498 BrowserThread::IO, | 1507 BrowserThread::IO, |
1499 FROM_HERE, | 1508 FROM_HERE, |
1500 base::Bind(nacl::NaClProcessHost::EarlyStartup)); | 1509 base::Bind(nacl::NaClProcessHost::EarlyStartup)); |
1501 #endif | 1510 #endif // !defined(DISABLE_NACL) |
1502 | 1511 |
1503 // Make sure initial prefs are recorded | 1512 // Make sure initial prefs are recorded |
1504 PrefMetricsService::Factory::GetForProfile(profile_); | 1513 PrefMetricsService::Factory::GetForProfile(profile_); |
1505 | 1514 |
1506 PreBrowserStart(); | 1515 PreBrowserStart(); |
1507 | 1516 |
1508 // Instantiate the notification UI manager, as this triggers a perf timer | 1517 // Instantiate the notification UI manager, as this triggers a perf timer |
1509 // used to measure startup time. TODO(stevenjb): Figure out what is actually | 1518 // used to measure startup time. TODO(stevenjb): Figure out what is actually |
1510 // triggering the timer and call that explicitly in the approprate place. | 1519 // triggering the timer and call that explicitly in the approprate place. |
1511 // http://crbug.com/105065. | 1520 // http://crbug.com/105065. |
(...skipping 25 matching lines...) Expand all Loading... | |
1537 // We are in regular browser boot sequence. Open initial tabs and enter the | 1546 // We are in regular browser boot sequence. Open initial tabs and enter the |
1538 // main message loop. | 1547 // main message loop. |
1539 #if defined(OS_CHROMEOS) | 1548 #if defined(OS_CHROMEOS) |
1540 // On ChromeOS multiple profiles doesn't apply, and will break if we load | 1549 // On ChromeOS multiple profiles doesn't apply, and will break if we load |
1541 // them this early as the cryptohome hasn't yet been mounted (which happens | 1550 // them this early as the cryptohome hasn't yet been mounted (which happens |
1542 // only once we log in. | 1551 // only once we log in. |
1543 std::vector<Profile*> last_opened_profiles; | 1552 std::vector<Profile*> last_opened_profiles; |
1544 #else | 1553 #else |
1545 std::vector<Profile*> last_opened_profiles = | 1554 std::vector<Profile*> last_opened_profiles = |
1546 g_browser_process->profile_manager()->GetLastOpenedProfiles(); | 1555 g_browser_process->profile_manager()->GetLastOpenedProfiles(); |
1547 #endif | 1556 #endif // defined(OS_CHROMEOS) |
1548 | 1557 |
1549 if (browser_creator_->Start(parsed_command_line(), base::FilePath(), | 1558 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep2Time", |
1550 profile_, last_opened_profiles)) { | 1559 base::TimeTicks::Now() - start_time_step2); |
1560 | |
1561 // This step is costly and is already measured in | |
1562 // Startup.StartupBrowserCreator_Start. | |
1563 bool started = browser_creator_->Start( | |
1564 parsed_command_line(), base::FilePath(), profile_, last_opened_profiles); | |
1565 const base::TimeTicks start_time_step3 = base::TimeTicks::Now(); | |
1566 if (started) { | |
1551 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 1567 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
1552 // Initialize autoupdate timer. Timer callback costs basically nothing | 1568 // Initialize autoupdate timer. Timer callback costs basically nothing |
1553 // when browser is not in persistent mode, so it's OK to let it ride on | 1569 // when browser is not in persistent mode, so it's OK to let it ride on |
1554 // the main thread. This needs to be done here because we don't want | 1570 // the main thread. This needs to be done here because we don't want |
1555 // to start the timer when Chrome is run inside a test harness. | 1571 // to start the timer when Chrome is run inside a test harness. |
1556 browser_process_->StartAutoupdateTimer(); | 1572 browser_process_->StartAutoupdateTimer(); |
1557 #endif | 1573 #endif // defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
1558 | 1574 |
1559 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1575 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1560 // On Linux, the running exe will be updated if an upgrade becomes | 1576 // On Linux, the running exe will be updated if an upgrade becomes |
1561 // available while the browser is running. We need to save the last | 1577 // available while the browser is running. We need to save the last |
1562 // modified time of the exe, so we can compare to determine if there is | 1578 // modified time of the exe, so we can compare to determine if there is |
1563 // an upgrade while the browser is kept alive by a persistent extension. | 1579 // an upgrade while the browser is kept alive by a persistent extension. |
1564 upgrade_util::SaveLastModifiedTimeOfExe(); | 1580 upgrade_util::SaveLastModifiedTimeOfExe(); |
1565 #endif | 1581 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1566 | 1582 |
1567 // Record now as the last successful chrome start. | 1583 // Record now as the last successful chrome start. |
1568 GoogleUpdateSettings::SetLastRunTime(); | 1584 GoogleUpdateSettings::SetLastRunTime(); |
1569 | 1585 |
1570 #if defined(OS_MACOSX) | 1586 #if defined(OS_MACOSX) |
1571 // Call Recycle() here as late as possible, before going into the loop | 1587 // Call Recycle() here as late as possible, before going into the loop |
1572 // because Start() will add things to it while creating the main window. | 1588 // because Start() will add things to it while creating the main window. |
1573 if (parameters().autorelease_pool) | 1589 if (parameters().autorelease_pool) |
1574 parameters().autorelease_pool->Recycle(); | 1590 parameters().autorelease_pool->Recycle(); |
1575 #endif | 1591 #endif // defined(OS_MACOSX) |
1576 | 1592 |
1577 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; | 1593 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; |
1578 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); | 1594 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); |
1579 | 1595 |
1580 // If we're running tests (ui_task is non-null), then we don't want to | 1596 // If we're running tests (ui_task is non-null), then we don't want to |
1581 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or | 1597 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or |
1582 // RequestLanguageList | 1598 // RequestLanguageList |
1583 if (parameters().ui_task == NULL) { | 1599 if (parameters().ui_task == NULL) { |
1584 // Request new variations seed information from server. | 1600 // Request new variations seed information from server. |
1585 chrome_variations::VariationsService* variations_service = | 1601 chrome_variations::VariationsService* variations_service = |
1586 browser_process_->variations_service(); | 1602 browser_process_->variations_service(); |
1587 if (variations_service) { | 1603 if (variations_service) { |
1588 variations_service->StartRepeatedVariationsSeedFetch(); | 1604 variations_service->StartRepeatedVariationsSeedFetch(); |
1589 | 1605 |
1590 #if defined(OS_WIN) | 1606 #if defined(OS_WIN) |
1591 variations_service->StartGoogleUpdateRegistrySync(); | 1607 variations_service->StartGoogleUpdateRegistrySync(); |
1592 #endif | 1608 #endif // defined(OS_WIN) |
1593 } | 1609 } |
1594 | 1610 |
1595 translate::TranslateDownloadManager::RequestLanguageList( | 1611 translate::TranslateDownloadManager::RequestLanguageList( |
1596 profile_->GetPrefs()); | 1612 profile_->GetPrefs()); |
1597 } | 1613 } |
1598 | 1614 |
1599 run_message_loop_ = true; | 1615 run_message_loop_ = true; |
1600 } else { | 1616 } else { |
1601 run_message_loop_ = false; | 1617 run_message_loop_ = false; |
1602 } | 1618 } |
1603 browser_creator_.reset(); | 1619 browser_creator_.reset(); |
1604 | 1620 |
1605 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 | 1621 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 |
1606 if (g_browser_process->metrics_service()->reporting_active()) | 1622 if (g_browser_process->metrics_service()->reporting_active()) |
1607 content::StartPowerUsageMonitor(); | 1623 content::StartPowerUsageMonitor(); |
1608 #endif | 1624 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS) |
1609 | 1625 |
1610 process_power_collector_.reset(new ProcessPowerCollector); | 1626 process_power_collector_.reset(new ProcessPowerCollector); |
1611 process_power_collector_->Initialize(); | 1627 process_power_collector_->Initialize(); |
1612 #endif // !defined(OS_ANDROID) | 1628 #endif // !defined(OS_ANDROID) |
1613 | 1629 |
1614 PostBrowserStart(); | 1630 PostBrowserStart(); |
1615 | 1631 |
1616 if (parameters().ui_task) { | 1632 if (parameters().ui_task) { |
1617 parameters().ui_task->Run(); | 1633 parameters().ui_task->Run(); |
1618 delete parameters().ui_task; | 1634 delete parameters().ui_task; |
1619 run_message_loop_ = false; | 1635 run_message_loop_ = false; |
1620 } | 1636 } |
1621 #if defined(OS_ANDROID) | 1637 #if defined(OS_ANDROID) |
1622 // We never run the C++ main loop on Android, since the UI thread message | 1638 // We never run the C++ main loop on Android, since the UI thread message |
1623 // loop is controlled by the OS, so this is as close as we can get to | 1639 // loop is controlled by the OS, so this is as close as we can get to |
1624 // the start of the main loop | 1640 // the start of the main loop. |
1625 if (result_code_ <= 0) { | 1641 if (result_code_ <= 0) { |
1626 RecordBrowserStartupTime(); | 1642 RecordBrowserStartupTime(); |
1627 } | 1643 } |
1628 #endif | 1644 #endif // defined(OS_ANDROID) |
1645 | |
1646 #if !defined(OS_ANDROID) | |
1647 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time", | |
1648 base::TimeTicks::Now() - start_time_step3); | |
1649 #endif // !defined(OS_ANDROID) | |
1650 | |
1629 return result_code_; | 1651 return result_code_; |
1630 } | 1652 } |
1631 | 1653 |
1632 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { | 1654 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { |
1633 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); | 1655 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); |
1634 #if defined(OS_ANDROID) | 1656 #if defined(OS_ANDROID) |
1635 // Chrome on Android does not use default MessageLoop. It has its own | 1657 // Chrome on Android does not use default MessageLoop. It has its own |
1636 // Android specific MessageLoop | 1658 // Android specific MessageLoop |
1637 NOTREACHED(); | 1659 NOTREACHED(); |
1638 return true; | 1660 return true; |
(...skipping 12 matching lines...) Expand all Loading... | |
1651 base::RunLoop run_loop; | 1673 base::RunLoop run_loop; |
1652 | 1674 |
1653 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); | 1675 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); |
1654 | 1676 |
1655 metrics::MetricsService::SetExecutionPhase( | 1677 metrics::MetricsService::SetExecutionPhase( |
1656 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, | 1678 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, |
1657 g_browser_process->local_state()); | 1679 g_browser_process->local_state()); |
1658 run_loop.Run(); | 1680 run_loop.Run(); |
1659 | 1681 |
1660 return true; | 1682 return true; |
1661 #endif | 1683 #endif // defined(OS_ANDROID) |
1662 } | 1684 } |
1663 | 1685 |
1664 void ChromeBrowserMainParts::PostMainMessageLoopRun() { | 1686 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
1665 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); | 1687 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); |
1666 #if defined(OS_ANDROID) | 1688 #if defined(OS_ANDROID) |
1667 // Chrome on Android does not use default MessageLoop. It has its own | 1689 // Chrome on Android does not use default MessageLoop. It has its own |
1668 // Android specific MessageLoop | 1690 // Android specific MessageLoop |
1669 NOTREACHED(); | 1691 NOTREACHED(); |
1670 #else | 1692 #else |
1671 | 1693 |
(...skipping 22 matching lines...) Expand all Loading... | |
1694 if (notify_result_ == ProcessSingleton::PROCESS_NONE) | 1716 if (notify_result_ == ProcessSingleton::PROCESS_NONE) |
1695 process_singleton_->Cleanup(); | 1717 process_singleton_->Cleanup(); |
1696 | 1718 |
1697 // Stop all tasks that might run on WatchDogThread. | 1719 // Stop all tasks that might run on WatchDogThread. |
1698 ThreadWatcherList::StopWatchingAll(); | 1720 ThreadWatcherList::StopWatchingAll(); |
1699 | 1721 |
1700 browser_process_->metrics_service()->Stop(); | 1722 browser_process_->metrics_service()->Stop(); |
1701 | 1723 |
1702 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); | 1724 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); |
1703 browser_process_->StartTearDown(); | 1725 browser_process_->StartTearDown(); |
1704 #endif | 1726 #endif // defined(OS_ANDROID) |
1705 } | 1727 } |
1706 | 1728 |
1707 void ChromeBrowserMainParts::PostDestroyThreads() { | 1729 void ChromeBrowserMainParts::PostDestroyThreads() { |
1708 #if defined(OS_ANDROID) | 1730 #if defined(OS_ANDROID) |
1709 // On Android, there is no quit/exit. So the browser's main message loop will | 1731 // On Android, there is no quit/exit. So the browser's main message loop will |
1710 // not finish. | 1732 // not finish. |
1711 NOTREACHED(); | 1733 NOTREACHED(); |
1712 #else | 1734 #else |
1713 browser_process_->PostDestroyThreads(); | 1735 browser_process_->PostDestroyThreads(); |
1714 // browser_shutdown takes care of deleting browser_process, so we need to | 1736 // browser_shutdown takes care of deleting browser_process, so we need to |
1715 // release it. | 1737 // release it. |
1716 ignore_result(browser_process_.release()); | 1738 ignore_result(browser_process_.release()); |
1717 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); | 1739 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); |
1718 master_prefs_.reset(); | 1740 master_prefs_.reset(); |
1719 process_singleton_.reset(); | 1741 process_singleton_.reset(); |
1720 device_event_log::Shutdown(); | 1742 device_event_log::Shutdown(); |
1721 | 1743 |
1722 // We need to do this check as late as possible, but due to modularity, this | 1744 // We need to do this check as late as possible, but due to modularity, this |
1723 // may be the last point in Chrome. This would be more effective if done at | 1745 // may be the last point in Chrome. This would be more effective if done at |
1724 // a higher level on the stack, so that it is impossible for an early return | 1746 // a higher level on the stack, so that it is impossible for an early return |
1725 // to bypass this code. Perhaps we need a *final* hook that is called on all | 1747 // to bypass this code. Perhaps we need a *final* hook that is called on all |
1726 // paths from content/browser/browser_main. | 1748 // paths from content/browser/browser_main. |
1727 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown()); | 1749 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown()); |
1728 | 1750 |
1729 #if defined(OS_CHROMEOS) | 1751 #if defined(OS_CHROMEOS) |
1730 chromeos::CrosSettings::Shutdown(); | 1752 chromeos::CrosSettings::Shutdown(); |
1731 #endif | 1753 #endif // defined(OS_CHROMEOS) |
1732 #endif | 1754 #endif // defined(OS_ANDROID) |
1733 } | 1755 } |
1734 | 1756 |
1735 // Public members: | 1757 // Public members: |
1736 | 1758 |
1737 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1759 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1738 chrome_extra_parts_.push_back(parts); | 1760 chrome_extra_parts_.push_back(parts); |
1739 } | 1761 } |
OLD | NEW |