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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 957353003: Add extra histogram latency tracking in PreMainMessageLoopRunImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove spaces and add comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('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/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
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"
(...skipping 12 matching lines...) Expand all
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)
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
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
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
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
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
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
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
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
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
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 10 matching lines...) Expand all
1196 // 20 seconds to respond. Note that this needs to be done before we attempt 1197 // 20 seconds to respond. Note that this needs to be done before we attempt
1197 // to read the profile. 1198 // to read the profile.
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)
1207 // On POSIX systems, print a message notifying the process is running.
1206 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide( 1208 printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide(
1207 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); 1209 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str());
1208 #endif 1210 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
1211
1209 // Having a differentiated return type for testing allows for tests to 1212 // Having a differentiated return type for testing allows for tests to
1210 // verify proper handling of some switches. When not testing, stick to 1213 // verify proper handling of some switches. When not testing, stick to
1211 // the standard Unix convention of returning zero when things went as 1214 // the standard Unix convention of returning zero when things went as
1212 // expected. 1215 // expected.
1213 if (parsed_command_line().HasSwitch(switches::kTestType)) 1216 if (parsed_command_line().HasSwitch(switches::kTestType))
1214 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; 1217 return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED;
1215 return content::RESULT_CODE_NORMAL_EXIT; 1218 return content::RESULT_CODE_NORMAL_EXIT;
1216 1219
1217 case ProcessSingleton::PROFILE_IN_USE: 1220 case ProcessSingleton::PROFILE_IN_USE:
1218 return chrome::RESULT_CODE_PROFILE_IN_USE; 1221 return chrome::RESULT_CODE_PROFILE_IN_USE;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) 1289 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
1287 1290
1288 // Desktop construction occurs here, (required before profile creation). 1291 // Desktop construction occurs here, (required before profile creation).
1289 PreProfileInit(); 1292 PreProfileInit();
1290 1293
1291 // Profile creation ---------------------------------------------------------- 1294 // Profile creation ----------------------------------------------------------
1292 1295
1293 metrics::MetricsService::SetExecutionPhase( 1296 metrics::MetricsService::SetExecutionPhase(
1294 metrics::MetricsService::CREATE_PROFILE, 1297 metrics::MetricsService::CREATE_PROFILE,
1295 g_browser_process->local_state()); 1298 g_browser_process->local_state());
1299
1300 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time",
1301 base::TimeTicks::Now() - start_time_step1);
1302
1303 // This step is costly and is already measured in Startup.CreateFirstProfile
1304 // and more directly Profile.CreateAndInitializeProfile.
1296 profile_ = CreatePrimaryProfile(parameters(), 1305 profile_ = CreatePrimaryProfile(parameters(),
1297 user_data_dir_, 1306 user_data_dir_,
1298 parsed_command_line()); 1307 parsed_command_line());
1299 if (!profile_) 1308 if (!profile_)
1300 return content::RESULT_CODE_NORMAL_EXIT; 1309 return content::RESULT_CODE_NORMAL_EXIT;
1301 1310
1302 #if !defined(OS_ANDROID) 1311 #if !defined(OS_ANDROID)
1312 const base::TimeTicks start_time_step2 = base::TimeTicks::Now();
1303 // The first run sentinel must be created after the process singleton was 1313 // The first run sentinel must be created after the process singleton was
1304 // grabbed and no early return paths were otherwise hit above. 1314 // grabbed and no early return paths were otherwise hit above.
1305 first_run::CreateSentinelIfNeeded(); 1315 first_run::CreateSentinelIfNeeded();
1306 #endif // !defined(OS_ANDROID) 1316 #endif // !defined(OS_ANDROID)
1307 1317
1308 #if defined(ENABLE_BACKGROUND) 1318 #if defined(ENABLE_BACKGROUND)
1309 // Autoload any profiles which are running background apps. 1319 // Autoload any profiles which are running background apps.
1310 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. 1320 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075.
1311 browser_process_->profile_manager()->AutoloadProfiles(); 1321 browser_process_->profile_manager()->AutoloadProfiles();
1312 #endif 1322 #endif // defined(ENABLE_BACKGROUND)
1313 // Post-profile init --------------------------------------------------------- 1323 // Post-profile init ---------------------------------------------------------
1314 1324
1315 TranslateService::Initialize(); 1325 TranslateService::Initialize();
1316 1326
1317 // Needs to be done before PostProfileInit, since login manager on CrOS is 1327 // Needs to be done before PostProfileInit, since login manager on CrOS is
1318 // called inside PostProfileInit. 1328 // called inside PostProfileInit.
1319 content::WebUIControllerFactory::RegisterFactory( 1329 content::WebUIControllerFactory::RegisterFactory(
1320 ChromeWebUIControllerFactory::GetInstance()); 1330 ChromeWebUIControllerFactory::GetInstance());
1321 1331
1322 // NaClBrowserDelegateImpl is accessed inside PostProfileInit(). 1332 // NaClBrowserDelegateImpl is accessed inside PostProfileInit().
1323 // So make sure to create it before that. 1333 // So make sure to create it before that.
1324 #if !defined(DISABLE_NACL) 1334 #if !defined(DISABLE_NACL)
1325 NaClBrowserDelegateImpl* delegate = 1335 NaClBrowserDelegateImpl* delegate =
1326 new NaClBrowserDelegateImpl(browser_process_->profile_manager()); 1336 new NaClBrowserDelegateImpl(browser_process_->profile_manager());
1327 nacl::NaClBrowser::SetDelegate(delegate); 1337 nacl::NaClBrowser::SetDelegate(delegate);
1328 #endif 1338 #endif // !defined(DISABLE_NACL)
1329 1339
1330 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. 1340 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts.
1331 // (requires supporting early exit). 1341 // (requires supporting early exit).
1332 PostProfileInit(); 1342 PostProfileInit();
1333 1343
1334 // Retrieve cached GL strings from local state and use them for GPU 1344 // Retrieve cached GL strings from local state and use them for GPU
1335 // blacklist decisions. 1345 // blacklist decisions.
1336 if (g_browser_process->gl_string_manager()) 1346 if (g_browser_process->gl_string_manager())
1337 g_browser_process->gl_string_manager()->Initialize(); 1347 g_browser_process->gl_string_manager()->Initialize();
1338 1348
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 parsed_command_line()); 1392 parsed_command_line());
1383 } 1393 }
1384 1394
1385 // Verify that the profile is not on a network share and if so prepare to show 1395 // Verify that the profile is not on a network share and if so prepare to show
1386 // notification to the user. 1396 // notification to the user.
1387 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) { 1397 if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) {
1388 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 1398 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
1389 base::Bind(&NetworkProfileBubble::CheckNetworkProfile, 1399 base::Bind(&NetworkProfileBubble::CheckNetworkProfile,
1390 profile_->GetPath())); 1400 profile_->GetPath()));
1391 } 1401 }
1392 #endif // OS_WIN 1402 #endif // defined(OS_WIN)
1393 1403
1394 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) 1404 #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS)
1395 // Init the RLZ library. This just binds the dll and schedules a task on the 1405 // 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 1406 // file thread to be run sometime later. If this is the first run we record
1397 // the installation event. 1407 // the installation event.
1398 PrefService* pref_service = profile_->GetPrefs(); 1408 PrefService* pref_service = profile_->GetPrefs();
1399 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay : 1409 int ping_delay = first_run::IsChromeFirstRun() ? master_prefs_->ping_delay :
1400 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); 1410 pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str());
1401 // Negative ping delay means to send ping immediately after a first search is 1411 // Negative ping delay means to send ping immediately after a first search is
1402 // recorded. 1412 // recorded.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) { 1449 } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) {
1440 net::SdchManager::EnableSdchSupport(false); 1450 net::SdchManager::EnableSdchSupport(false);
1441 } 1451 }
1442 1452
1443 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD) 1453 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
1444 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { 1454 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) {
1445 base::FilePath path = 1455 base::FilePath path =
1446 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); 1456 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint);
1447 printing::PrintedDocument::set_debug_dump_path(path); 1457 printing::PrintedDocument::set_debug_dump_path(path);
1448 } 1458 }
1449 #endif 1459 #endif // defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
1450 1460
1451 HandleTestParameters(parsed_command_line()); 1461 HandleTestParameters(parsed_command_line());
1452 browser_process_->metrics_service()->RecordBreakpadHasDebugger( 1462 browser_process_->metrics_service()->RecordBreakpadHasDebugger(
1453 base::debug::BeingDebugged()); 1463 base::debug::BeingDebugged());
1454 1464
1455 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages( 1465 language_usage_metrics::LanguageUsageMetrics::RecordAcceptLanguages(
1456 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); 1466 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
1457 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage( 1467 language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage(
1458 browser_process_->GetApplicationLocale()); 1468 browser_process_->GetApplicationLocale());
1459 1469
1460 // Start watching for hangs during startup. We disarm this hang detector when 1470 // Start watching for hangs during startup. We disarm this hang detector when
1461 // ThreadWatcher takes over or when browser is shutdown or when 1471 // ThreadWatcher takes over or when browser is shutdown or when
1462 // startup_watcher_ is deleted. 1472 // startup_watcher_ is deleted.
1463 metrics::MetricsService::SetExecutionPhase( 1473 metrics::MetricsService::SetExecutionPhase(
1464 metrics::MetricsService::STARTUP_TIMEBOMB_ARM, 1474 metrics::MetricsService::STARTUP_TIMEBOMB_ARM,
1465 g_browser_process->local_state()); 1475 g_browser_process->local_state());
1466 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600)); 1476 startup_watcher_->Arm(base::TimeDelta::FromSeconds(600));
1467 1477
1468 // On mobile, need for clean shutdown arises only when the application comes 1478 // On mobile, need for clean shutdown arises only when the application comes
1469 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). 1479 // to foreground (i.e. MetricsService::OnAppEnterForeground is called).
1470 // http://crbug.com/179143 1480 // http://crbug.com/179143
1471 #if !defined(OS_ANDROID) 1481 #if !defined(OS_ANDROID)
1472 // Start watching for a hang. 1482 // Start watching for a hang.
1473 browser_process_->metrics_service()->LogNeedForCleanShutdown(); 1483 browser_process_->metrics_service()->LogNeedForCleanShutdown();
1474 #endif 1484 #endif // !defined(OS_ANDROID)
1475 1485
1476 #if defined(ENABLE_PRINT_PREVIEW) 1486 #if defined(ENABLE_PRINT_PREVIEW)
1477 // Create the instance of the cloud print proxy service so that it can launch 1487 // 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 1488 // the service process if needed. This is needed because the service process
1479 // might have shutdown because an update was available. 1489 // might have shutdown because an update was available.
1480 // TODO(torne): this should maybe be done with 1490 // TODO(torne): this should maybe be done with
1481 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() 1491 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext()
1482 // instead? 1492 // instead?
1483 CloudPrintProxyServiceFactory::GetForProfile(profile_); 1493 CloudPrintProxyServiceFactory::GetForProfile(profile_);
1484 #endif 1494 #endif // defined(ENABLE_PRINT_PREVIEW)
1485 1495
1486 // Start watching all browser threads for responsiveness. 1496 // Start watching all browser threads for responsiveness.
1487 metrics::MetricsService::SetExecutionPhase( 1497 metrics::MetricsService::SetExecutionPhase(
1488 metrics::MetricsService::THREAD_WATCHER_START, 1498 metrics::MetricsService::THREAD_WATCHER_START,
1489 g_browser_process->local_state()); 1499 g_browser_process->local_state());
1490 ThreadWatcherList::StartWatchingAll(parsed_command_line()); 1500 ThreadWatcherList::StartWatchingAll(parsed_command_line());
1491 1501
1492 #if defined(OS_ANDROID) 1502 #if defined(OS_ANDROID)
1493 ThreadWatcherAndroid::RegisterApplicationStatusListener(); 1503 ThreadWatcherAndroid::RegisterApplicationStatusListener();
1494 #endif 1504 #endif // defined(OS_ANDROID)
1495 1505
1496 #if !defined(DISABLE_NACL) 1506 #if !defined(DISABLE_NACL)
1497 BrowserThread::PostTask( 1507 BrowserThread::PostTask(
1498 BrowserThread::IO, 1508 BrowserThread::IO,
1499 FROM_HERE, 1509 FROM_HERE,
1500 base::Bind(nacl::NaClProcessHost::EarlyStartup)); 1510 base::Bind(nacl::NaClProcessHost::EarlyStartup));
1501 #endif 1511 #endif // !defined(DISABLE_NACL)
1502 1512
1503 // Make sure initial prefs are recorded 1513 // Make sure initial prefs are recorded
1504 PrefMetricsService::Factory::GetForProfile(profile_); 1514 PrefMetricsService::Factory::GetForProfile(profile_);
1505 1515
1506 PreBrowserStart(); 1516 PreBrowserStart();
1507 1517
1508 // Instantiate the notification UI manager, as this triggers a perf timer 1518 // Instantiate the notification UI manager, as this triggers a perf timer
1509 // used to measure startup time. TODO(stevenjb): Figure out what is actually 1519 // used to measure startup time. TODO(stevenjb): Figure out what is actually
1510 // triggering the timer and call that explicitly in the approprate place. 1520 // triggering the timer and call that explicitly in the approprate place.
1511 // http://crbug.com/105065. 1521 // http://crbug.com/105065.
(...skipping 25 matching lines...) Expand all
1537 // We are in regular browser boot sequence. Open initial tabs and enter the 1547 // We are in regular browser boot sequence. Open initial tabs and enter the
1538 // main message loop. 1548 // main message loop.
1539 #if defined(OS_CHROMEOS) 1549 #if defined(OS_CHROMEOS)
1540 // On ChromeOS multiple profiles doesn't apply, and will break if we load 1550 // 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 1551 // them this early as the cryptohome hasn't yet been mounted (which happens
1542 // only once we log in. 1552 // only once we log in.
1543 std::vector<Profile*> last_opened_profiles; 1553 std::vector<Profile*> last_opened_profiles;
1544 #else 1554 #else
1545 std::vector<Profile*> last_opened_profiles = 1555 std::vector<Profile*> last_opened_profiles =
1546 g_browser_process->profile_manager()->GetLastOpenedProfiles(); 1556 g_browser_process->profile_manager()->GetLastOpenedProfiles();
1547 #endif 1557 #endif // defined(OS_CHROMEOS)
1548 1558
1549 if (browser_creator_->Start(parsed_command_line(), base::FilePath(), 1559 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep2Time",
1550 profile_, last_opened_profiles)) { 1560 base::TimeTicks::Now() - start_time_step2);
1561
1562 // This step is costly and is already measured in
1563 // Startup.StartupBrowserCreator_Start.
1564 bool started = browser_creator_->Start(
1565 parsed_command_line(), base::FilePath(), profile_, last_opened_profiles);
1566 const base::TimeTicks start_time_step3 = base::TimeTicks::Now();
1567 if (started) {
1551 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) 1568 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
1552 // Initialize autoupdate timer. Timer callback costs basically nothing 1569 // 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 1570 // 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 1571 // 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. 1572 // to start the timer when Chrome is run inside a test harness.
1556 browser_process_->StartAutoupdateTimer(); 1573 browser_process_->StartAutoupdateTimer();
1557 #endif 1574 #endif // defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
1558 1575
1559 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1576 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1560 // On Linux, the running exe will be updated if an upgrade becomes 1577 // 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 1578 // 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 1579 // 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. 1580 // an upgrade while the browser is kept alive by a persistent extension.
1564 upgrade_util::SaveLastModifiedTimeOfExe(); 1581 upgrade_util::SaveLastModifiedTimeOfExe();
1565 #endif 1582 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
1566 1583
1567 // Record now as the last successful chrome start. 1584 // Record now as the last successful chrome start.
1568 GoogleUpdateSettings::SetLastRunTime(); 1585 GoogleUpdateSettings::SetLastRunTime();
1569 1586
1570 #if defined(OS_MACOSX) 1587 #if defined(OS_MACOSX)
1571 // Call Recycle() here as late as possible, before going into the loop 1588 // 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. 1589 // because Start() will add things to it while creating the main window.
1573 if (parameters().autorelease_pool) 1590 if (parameters().autorelease_pool)
1574 parameters().autorelease_pool->Recycle(); 1591 parameters().autorelease_pool->Recycle();
1575 #endif 1592 #endif // defined(OS_MACOSX)
1576 1593
1577 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; 1594 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start;
1578 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); 1595 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay);
1579 1596
1580 // If we're running tests (ui_task is non-null), then we don't want to 1597 // If we're running tests (ui_task is non-null), then we don't want to
1581 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or 1598 // call RequestLanguageList or StartRepeatedVariationsSeedFetch or
1582 // RequestLanguageList 1599 // RequestLanguageList
1583 if (parameters().ui_task == NULL) { 1600 if (parameters().ui_task == NULL) {
1584 // Request new variations seed information from server. 1601 // Request new variations seed information from server.
1585 chrome_variations::VariationsService* variations_service = 1602 chrome_variations::VariationsService* variations_service =
1586 browser_process_->variations_service(); 1603 browser_process_->variations_service();
1587 if (variations_service) { 1604 if (variations_service) {
1588 variations_service->StartRepeatedVariationsSeedFetch(); 1605 variations_service->StartRepeatedVariationsSeedFetch();
1589 1606
1590 #if defined(OS_WIN) 1607 #if defined(OS_WIN)
1591 variations_service->StartGoogleUpdateRegistrySync(); 1608 variations_service->StartGoogleUpdateRegistrySync();
1592 #endif 1609 #endif // defined(OS_WIN)
1593 } 1610 }
1594 1611
1595 translate::TranslateDownloadManager::RequestLanguageList( 1612 translate::TranslateDownloadManager::RequestLanguageList(
1596 profile_->GetPrefs()); 1613 profile_->GetPrefs());
1597 } 1614 }
1598 1615
1599 run_message_loop_ = true; 1616 run_message_loop_ = true;
1600 } else { 1617 } else {
1601 run_message_loop_ = false; 1618 run_message_loop_ = false;
1602 } 1619 }
1603 browser_creator_.reset(); 1620 browser_creator_.reset();
1604 1621
1605 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393 1622 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393
1606 if (g_browser_process->metrics_service()->reporting_active()) 1623 if (g_browser_process->metrics_service()->reporting_active())
1607 content::StartPowerUsageMonitor(); 1624 content::StartPowerUsageMonitor();
1608 #endif 1625 #endif // !defined(OS_LINUX) || defined(OS_CHROMEOS)
1609 1626
1610 process_power_collector_.reset(new ProcessPowerCollector); 1627 process_power_collector_.reset(new ProcessPowerCollector);
1611 process_power_collector_->Initialize(); 1628 process_power_collector_->Initialize();
1612 #endif // !defined(OS_ANDROID) 1629 #endif // !defined(OS_ANDROID)
1613 1630
1614 PostBrowserStart(); 1631 PostBrowserStart();
1615 1632
1616 if (parameters().ui_task) { 1633 if (parameters().ui_task) {
1617 parameters().ui_task->Run(); 1634 parameters().ui_task->Run();
1618 delete parameters().ui_task; 1635 delete parameters().ui_task;
1619 run_message_loop_ = false; 1636 run_message_loop_ = false;
1620 } 1637 }
1621 #if defined(OS_ANDROID) 1638 #if defined(OS_ANDROID)
1622 // We never run the C++ main loop on Android, since the UI thread message 1639 // 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 1640 // loop is controlled by the OS, so this is as close as we can get to
1624 // the start of the main loop 1641 // the start of the main loop.
1625 if (result_code_ <= 0) { 1642 if (result_code_ <= 0) {
1626 RecordBrowserStartupTime(); 1643 RecordBrowserStartupTime();
1627 } 1644 }
1628 #endif 1645 #endif // defined(OS_ANDROID)
1646
1647 #if !defined(OS_ANDROID)
1648 UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time",
1649 base::TimeTicks::Now() - start_time_step3);
1650 #endif // !defined(OS_ANDROID)
1651
1629 return result_code_; 1652 return result_code_;
1630 } 1653 }
1631 1654
1632 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { 1655 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
1633 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); 1656 TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun");
1634 #if defined(OS_ANDROID) 1657 #if defined(OS_ANDROID)
1635 // Chrome on Android does not use default MessageLoop. It has its own 1658 // Chrome on Android does not use default MessageLoop. It has its own
1636 // Android specific MessageLoop 1659 // Android specific MessageLoop
1637 NOTREACHED(); 1660 NOTREACHED();
1638 return true; 1661 return true;
(...skipping 12 matching lines...) Expand all
1651 base::RunLoop run_loop; 1674 base::RunLoop run_loop;
1652 1675
1653 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); 1676 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle();
1654 1677
1655 metrics::MetricsService::SetExecutionPhase( 1678 metrics::MetricsService::SetExecutionPhase(
1656 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN, 1679 metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN,
1657 g_browser_process->local_state()); 1680 g_browser_process->local_state());
1658 run_loop.Run(); 1681 run_loop.Run();
1659 1682
1660 return true; 1683 return true;
1661 #endif 1684 #endif // defined(OS_ANDROID)
1662 } 1685 }
1663 1686
1664 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1687 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1665 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); 1688 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun");
1666 #if defined(OS_ANDROID) 1689 #if defined(OS_ANDROID)
1667 // Chrome on Android does not use default MessageLoop. It has its own 1690 // Chrome on Android does not use default MessageLoop. It has its own
1668 // Android specific MessageLoop 1691 // Android specific MessageLoop
1669 NOTREACHED(); 1692 NOTREACHED();
1670 #else 1693 #else
1671 1694
(...skipping 22 matching lines...) Expand all
1694 if (notify_result_ == ProcessSingleton::PROCESS_NONE) 1717 if (notify_result_ == ProcessSingleton::PROCESS_NONE)
1695 process_singleton_->Cleanup(); 1718 process_singleton_->Cleanup();
1696 1719
1697 // Stop all tasks that might run on WatchDogThread. 1720 // Stop all tasks that might run on WatchDogThread.
1698 ThreadWatcherList::StopWatchingAll(); 1721 ThreadWatcherList::StopWatchingAll();
1699 1722
1700 browser_process_->metrics_service()->Stop(); 1723 browser_process_->metrics_service()->Stop();
1701 1724
1702 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); 1725 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop();
1703 browser_process_->StartTearDown(); 1726 browser_process_->StartTearDown();
1704 #endif 1727 #endif // defined(OS_ANDROID)
1705 } 1728 }
1706 1729
1707 void ChromeBrowserMainParts::PostDestroyThreads() { 1730 void ChromeBrowserMainParts::PostDestroyThreads() {
1708 #if defined(OS_ANDROID) 1731 #if defined(OS_ANDROID)
1709 // On Android, there is no quit/exit. So the browser's main message loop will 1732 // On Android, there is no quit/exit. So the browser's main message loop will
1710 // not finish. 1733 // not finish.
1711 NOTREACHED(); 1734 NOTREACHED();
1712 #else 1735 #else
1713 browser_process_->PostDestroyThreads(); 1736 browser_process_->PostDestroyThreads();
1714 // browser_shutdown takes care of deleting browser_process, so we need to 1737 // browser_shutdown takes care of deleting browser_process, so we need to
1715 // release it. 1738 // release it.
1716 ignore_result(browser_process_.release()); 1739 ignore_result(browser_process_.release());
1717 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); 1740 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_);
1718 master_prefs_.reset(); 1741 master_prefs_.reset();
1719 process_singleton_.reset(); 1742 process_singleton_.reset();
1720 device_event_log::Shutdown(); 1743 device_event_log::Shutdown();
1721 1744
1722 // We need to do this check as late as possible, but due to modularity, this 1745 // 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 1746 // 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 1747 // 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 1748 // to bypass this code. Perhaps we need a *final* hook that is called on all
1726 // paths from content/browser/browser_main. 1749 // paths from content/browser/browser_main.
1727 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown()); 1750 CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown());
1728 1751
1729 #if defined(OS_CHROMEOS) 1752 #if defined(OS_CHROMEOS)
1730 chromeos::CrosSettings::Shutdown(); 1753 chromeos::CrosSettings::Shutdown();
1731 #endif 1754 #endif // defined(OS_CHROMEOS)
1732 #endif 1755 #endif // defined(OS_ANDROID)
1733 } 1756 }
1734 1757
1735 // Public members: 1758 // Public members:
1736 1759
1737 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1760 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1738 chrome_extra_parts_.push_back(parts); 1761 chrome_extra_parts_.push_back(parts);
1739 } 1762 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698