OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return NULL; | 359 return NULL; |
360 } | 360 } |
361 | 361 |
362 #if defined(OS_MACOSX) | 362 #if defined(OS_MACOSX) |
363 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 363 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
364 SecKeychainCallbackInfo* info, void* context) { | 364 SecKeychainCallbackInfo* info, void* context) { |
365 return noErr; | 365 return noErr; |
366 } | 366 } |
367 #endif | 367 #endif |
368 | 368 |
369 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
370 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { | |
371 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); | |
372 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); | |
373 static const size_t kBuckets(100); | |
374 | |
375 // FactoryTimeGet will always return a pointer to the same histogram object, | |
376 // keyed on its name. There's no need for us to store it explicitly anywhere. | |
377 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( | |
378 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); | |
379 | |
380 counter->AddTime(time); | |
381 } | |
382 | |
383 void RegisterComponentsForUpdate(const CommandLine& command_line) { | 369 void RegisterComponentsForUpdate(const CommandLine& command_line) { |
384 ComponentUpdateService* cus = g_browser_process->component_updater(); | 370 ComponentUpdateService* cus = g_browser_process->component_updater(); |
385 | 371 |
386 // Registration can be before or after cus->Start() so it is ok to post | 372 // Registration can be before or after cus->Start() so it is ok to post |
387 // a task to the UI thread to do registration once you done the necessary | 373 // a task to the UI thread to do registration once you done the necessary |
388 // file IO to know you existing component version. | 374 // file IO to know you existing component version. |
389 #if !defined(OS_CHROMEOS) | 375 #if !defined(OS_CHROMEOS) |
390 RegisterRecoveryComponent(cus, g_browser_process->local_state()); | 376 RegisterRecoveryComponent(cus, g_browser_process->local_state()); |
391 RegisterPepperFlashComponent(cus); | 377 RegisterPepperFlashComponent(cus); |
392 RegisterSwiftShaderComponent(cus); | 378 RegisterSwiftShaderComponent(cus); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 bool is_first_run = first_run::IsChromeFirstRun(); | 682 bool is_first_run = first_run::IsChromeFirstRun(); |
697 #endif | 683 #endif |
698 | 684 |
699 // CurrentProcessInfo::CreationTime() is currently only implemented on some | 685 // CurrentProcessInfo::CreationTime() is currently only implemented on some |
700 // platforms. | 686 // platforms. |
701 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 687 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
702 const base::Time process_creation_time = | 688 const base::Time process_creation_time = |
703 base::CurrentProcessInfo::CreationTime(); | 689 base::CurrentProcessInfo::CreationTime(); |
704 | 690 |
705 if (!is_first_run && !process_creation_time.is_null()) { | 691 if (!is_first_run && !process_creation_time.is_null()) { |
706 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", | 692 base::TimeDelta delay = base::Time::Now() - process_creation_time; |
707 base::Time::Now() - process_creation_time); | 693 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserMessageLoopStartTime", delay); |
708 } | 694 } |
709 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 695 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
710 | 696 |
711 // Record collected startup metrics. | 697 // Record collected startup metrics. |
712 startup_metric_utils::OnBrowserStartupComplete(is_first_run); | 698 startup_metric_utils::OnBrowserStartupComplete(is_first_run); |
713 | 699 |
714 // Deletes self. | 700 // Deletes self. |
715 new LoadCompleteListener(); | 701 new LoadCompleteListener(); |
716 } | 702 } |
717 | 703 |
718 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
719 void ChromeBrowserMainParts::RecordPreReadExperimentTime(const char* name, | |
720 base::TimeDelta time) { | |
721 DCHECK(name != NULL); | |
722 | |
723 // This gets called with different histogram names, so we don't want to use | |
724 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
725 // first call wins. | |
726 AddPreReadHistogramTime(name, time); | |
727 | |
728 #if defined(OS_WIN) | |
729 #if defined(GOOGLE_CHROME_BUILD) | |
730 // The pre-read experiment is Windows and Google Chrome specific. | |
731 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
732 | |
733 // Only record the sub-histogram result if the experiment is running | |
734 // (environment variable is set, and valid). | |
735 std::string pre_read_percentage; | |
736 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { | |
737 std::string uma_name(name); | |
738 | |
739 // We want XP to record a separate histogram, as the loader on XP | |
740 // is very different from the Vista and Win7 loaders. | |
741 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
742 uma_name += "_XP"; | |
743 | |
744 uma_name += "_PreRead_"; | |
745 uma_name += pre_read_percentage; | |
746 AddPreReadHistogramTime(uma_name.c_str(), time); | |
747 } | |
748 #endif | |
749 #endif | |
750 } | |
751 | |
752 // ----------------------------------------------------------------------------- | 704 // ----------------------------------------------------------------------------- |
753 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 705 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
754 | 706 |
755 #if defined(OS_WIN) | 707 #if defined(OS_WIN) |
756 #define DLLEXPORT __declspec(dllexport) | 708 #define DLLEXPORT __declspec(dllexport) |
757 | 709 |
758 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 710 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
759 extern "C" { | 711 extern "C" { |
760 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 712 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
761 } | 713 } |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 // Record now as the last successful chrome start. | 1506 // Record now as the last successful chrome start. |
1555 GoogleUpdateSettings::SetLastRunTime(); | 1507 GoogleUpdateSettings::SetLastRunTime(); |
1556 | 1508 |
1557 #if defined(OS_MACOSX) | 1509 #if defined(OS_MACOSX) |
1558 // Call Recycle() here as late as possible, before going into the loop | 1510 // Call Recycle() here as late as possible, before going into the loop |
1559 // because Start() will add things to it while creating the main window. | 1511 // because Start() will add things to it while creating the main window. |
1560 if (parameters().autorelease_pool) | 1512 if (parameters().autorelease_pool) |
1561 parameters().autorelease_pool->Recycle(); | 1513 parameters().autorelease_pool->Recycle(); |
1562 #endif | 1514 #endif |
1563 | 1515 |
1564 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", | 1516 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; |
1565 base::TimeTicks::Now() - browser_open_start); | 1517 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); |
1566 | 1518 |
1567 // If we're running tests (ui_task is non-null), then we don't want to | 1519 // If we're running tests (ui_task is non-null), then we don't want to |
1568 // call FetchLanguageListFromTranslateServer or | 1520 // call FetchLanguageListFromTranslateServer or |
1569 // StartRepeatedVariationsSeedFetch. | 1521 // StartRepeatedVariationsSeedFetch. |
1570 if (parameters().ui_task == NULL) { | 1522 if (parameters().ui_task == NULL) { |
1571 // Request new variations seed information from server. | 1523 // Request new variations seed information from server. |
1572 chrome_variations::VariationsService* variations_service = | 1524 chrome_variations::VariationsService* variations_service = |
1573 browser_process_->variations_service(); | 1525 browser_process_->variations_service(); |
1574 if (variations_service) { | 1526 if (variations_service) { |
1575 variations_service->StartRepeatedVariationsSeedFetch(); | 1527 variations_service->StartRepeatedVariationsSeedFetch(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 chromeos::CrosSettings::Shutdown(); | 1667 chromeos::CrosSettings::Shutdown(); |
1716 #endif | 1668 #endif |
1717 #endif | 1669 #endif |
1718 } | 1670 } |
1719 | 1671 |
1720 // Public members: | 1672 // Public members: |
1721 | 1673 |
1722 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1674 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1723 chrome_extra_parts_.push_back(parts); | 1675 chrome_extra_parts_.push_back(parts); |
1724 } | 1676 } |
OLD | NEW |