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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 | 674 |
689 bool is_first_run = first_run::IsChromeFirstRun(); | 675 bool is_first_run = first_run::IsChromeFirstRun(); |
690 | 676 |
691 // CurrentProcessInfo::CreationTime() is currently only implemented on some | 677 // CurrentProcessInfo::CreationTime() is currently only implemented on some |
692 // platforms. | 678 // platforms. |
693 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 679 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
694 const base::Time process_creation_time = | 680 const base::Time process_creation_time = |
695 base::CurrentProcessInfo::CreationTime(); | 681 base::CurrentProcessInfo::CreationTime(); |
696 | 682 |
697 if (!is_first_run && !process_creation_time.is_null()) { | 683 if (!is_first_run && !process_creation_time.is_null()) { |
698 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", | 684 base::TimeDelta delay = base::Time::Now() - process_creation_time; |
699 base::Time::Now() - process_creation_time); | 685 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserMessageLoopStartTime", delay); |
700 } | 686 } |
701 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 687 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
702 | 688 |
703 // Record collected startup metrics. | 689 // Record collected startup metrics. |
704 startup_metric_utils::OnBrowserStartupComplete(is_first_run); | 690 startup_metric_utils::OnBrowserStartupComplete(is_first_run); |
705 | 691 |
706 // Deletes self. | 692 // Deletes self. |
707 new LoadCompleteListener(); | 693 new LoadCompleteListener(); |
708 } | 694 } |
709 | 695 |
710 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
711 void ChromeBrowserMainParts::RecordPreReadExperimentTime(const char* name, | |
712 base::TimeDelta time) { | |
713 DCHECK(name != NULL); | |
714 | |
715 // This gets called with different histogram names, so we don't want to use | |
716 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
717 // first call wins. | |
718 AddPreReadHistogramTime(name, time); | |
719 | |
720 #if defined(OS_WIN) | |
721 #if defined(GOOGLE_CHROME_BUILD) | |
722 // The pre-read experiment is Windows and Google Chrome specific. | |
723 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
724 | |
725 // Only record the sub-histogram result if the experiment is running | |
726 // (environment variable is set, and valid). | |
727 std::string pre_read_percentage; | |
728 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { | |
729 std::string uma_name(name); | |
730 | |
731 // We want XP to record a separate histogram, as the loader on XP | |
732 // is very different from the Vista and Win7 loaders. | |
733 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
734 uma_name += "_XP"; | |
735 | |
736 uma_name += "_PreRead_"; | |
737 uma_name += pre_read_percentage; | |
738 AddPreReadHistogramTime(uma_name.c_str(), time); | |
739 } | |
740 #endif | |
741 #endif | |
742 } | |
743 | |
744 // ----------------------------------------------------------------------------- | 696 // ----------------------------------------------------------------------------- |
745 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 697 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
746 | 698 |
747 #if defined(OS_WIN) | 699 #if defined(OS_WIN) |
748 #define DLLEXPORT __declspec(dllexport) | 700 #define DLLEXPORT __declspec(dllexport) |
749 | 701 |
750 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 702 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
751 extern "C" { | 703 extern "C" { |
752 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 704 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
753 } | 705 } |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 // Record now as the last successful chrome start. | 1498 // Record now as the last successful chrome start. |
1547 GoogleUpdateSettings::SetLastRunTime(); | 1499 GoogleUpdateSettings::SetLastRunTime(); |
1548 | 1500 |
1549 #if defined(OS_MACOSX) | 1501 #if defined(OS_MACOSX) |
1550 // Call Recycle() here as late as possible, before going into the loop | 1502 // Call Recycle() here as late as possible, before going into the loop |
1551 // because Start() will add things to it while creating the main window. | 1503 // because Start() will add things to it while creating the main window. |
1552 if (parameters().autorelease_pool) | 1504 if (parameters().autorelease_pool) |
1553 parameters().autorelease_pool->Recycle(); | 1505 parameters().autorelease_pool->Recycle(); |
1554 #endif | 1506 #endif |
1555 | 1507 |
1556 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", | 1508 base::TimeTicks browser_open_end = base::TimeTicks::Now(); |
1557 base::TimeTicks::Now() - browser_open_start); | 1509 base::TimeDelta browser_open_delta = browser_open_end - browser_open_start; |
Alexei Svitkine (slow)
2013/09/03 18:48:45
Nit: Inline base::TimeTicks::Now(), e.g.:
bas
Roger McFarlane (Chromium)
2013/09/03 19:32:10
Done.
| |
1510 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", browser_open_delta); | |
1558 | 1511 |
1559 // If we're running tests (ui_task is non-null), then we don't want to | 1512 // If we're running tests (ui_task is non-null), then we don't want to |
1560 // call FetchLanguageListFromTranslateServer or | 1513 // call FetchLanguageListFromTranslateServer or |
1561 // StartRepeatedVariationsSeedFetch. | 1514 // StartRepeatedVariationsSeedFetch. |
1562 if (parameters().ui_task == NULL) { | 1515 if (parameters().ui_task == NULL) { |
1563 // Request new variations seed information from server. | 1516 // Request new variations seed information from server. |
1564 chrome_variations::VariationsService* variations_service = | 1517 chrome_variations::VariationsService* variations_service = |
1565 browser_process_->variations_service(); | 1518 browser_process_->variations_service(); |
1566 if (variations_service) { | 1519 if (variations_service) { |
1567 variations_service->StartRepeatedVariationsSeedFetch(); | 1520 variations_service->StartRepeatedVariationsSeedFetch(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 chromeos::CrosSettings::Shutdown(); | 1653 chromeos::CrosSettings::Shutdown(); |
1701 #endif | 1654 #endif |
1702 #endif | 1655 #endif |
1703 } | 1656 } |
1704 | 1657 |
1705 // Public members: | 1658 // Public members: |
1706 | 1659 |
1707 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1660 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1708 chrome_extra_parts_.push_back(parts); | 1661 chrome_extra_parts_.push_back(parts); |
1709 } | 1662 } |
OLD | NEW |