| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 return NULL; | 358 return NULL; |
| 359 } | 359 } |
| 360 | 360 |
| 361 #if defined(OS_MACOSX) | 361 #if defined(OS_MACOSX) |
| 362 OSStatus KeychainCallback(SecKeychainEvent keychain_event, | 362 OSStatus KeychainCallback(SecKeychainEvent keychain_event, |
| 363 SecKeychainCallbackInfo* info, void* context) { | 363 SecKeychainCallbackInfo* info, void* context) { |
| 364 return noErr; | 364 return noErr; |
| 365 } | 365 } |
| 366 #endif | 366 #endif |
| 367 | 367 |
| 368 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 369 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { | |
| 370 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); | |
| 371 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); | |
| 372 static const size_t kBuckets(100); | |
| 373 | |
| 374 // FactoryTimeGet will always return a pointer to the same histogram object, | |
| 375 // keyed on its name. There's no need for us to store it explicitly anywhere. | |
| 376 base::HistogramBase* counter = base::Histogram::FactoryTimeGet( | |
| 377 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); | |
| 378 | |
| 379 counter->AddTime(time); | |
| 380 } | |
| 381 | |
| 382 void RegisterComponentsForUpdate(const CommandLine& command_line) { | 368 void RegisterComponentsForUpdate(const CommandLine& command_line) { |
| 383 ComponentUpdateService* cus = g_browser_process->component_updater(); | 369 ComponentUpdateService* cus = g_browser_process->component_updater(); |
| 384 | 370 |
| 385 // Registration can be before or after cus->Start() so it is ok to post | 371 // Registration can be before or after cus->Start() so it is ok to post |
| 386 // a task to the UI thread to do registration once you done the necessary | 372 // a task to the UI thread to do registration once you done the necessary |
| 387 // file IO to know you existing component version. | 373 // file IO to know you existing component version. |
| 388 #if !defined(OS_CHROMEOS) | 374 #if !defined(OS_CHROMEOS) |
| 389 RegisterRecoveryComponent(cus, g_browser_process->local_state()); | 375 RegisterRecoveryComponent(cus, g_browser_process->local_state()); |
| 390 RegisterPepperFlashComponent(cus); | 376 RegisterPepperFlashComponent(cus); |
| 391 RegisterSwiftShaderComponent(cus); | 377 RegisterSwiftShaderComponent(cus); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 bool is_first_run = first_run::IsChromeFirstRun(); | 681 bool is_first_run = first_run::IsChromeFirstRun(); |
| 696 #endif | 682 #endif |
| 697 | 683 |
| 698 // CurrentProcessInfo::CreationTime() is currently only implemented on some | 684 // CurrentProcessInfo::CreationTime() is currently only implemented on some |
| 699 // platforms. | 685 // platforms. |
| 700 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 686 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| 701 const base::Time process_creation_time = | 687 const base::Time process_creation_time = |
| 702 base::CurrentProcessInfo::CreationTime(); | 688 base::CurrentProcessInfo::CreationTime(); |
| 703 | 689 |
| 704 if (!is_first_run && !process_creation_time.is_null()) { | 690 if (!is_first_run && !process_creation_time.is_null()) { |
| 705 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", | 691 base::TimeDelta delay = base::Time::Now() - process_creation_time; |
| 706 base::Time::Now() - process_creation_time); | 692 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserMessageLoopStartTime", delay); |
| 707 } | 693 } |
| 708 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 694 #endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| 709 | 695 |
| 710 // Record collected startup metrics. | 696 // Record collected startup metrics. |
| 711 startup_metric_utils::OnBrowserStartupComplete(is_first_run); | 697 startup_metric_utils::OnBrowserStartupComplete(is_first_run); |
| 712 | 698 |
| 713 // Deletes self. | 699 // Deletes self. |
| 714 new LoadCompleteListener(); | 700 new LoadCompleteListener(); |
| 715 } | 701 } |
| 716 | 702 |
| 717 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 718 void ChromeBrowserMainParts::RecordPreReadExperimentTime(const char* name, | |
| 719 base::TimeDelta time) { | |
| 720 DCHECK(name != NULL); | |
| 721 | |
| 722 // This gets called with different histogram names, so we don't want to use | |
| 723 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
| 724 // first call wins. | |
| 725 AddPreReadHistogramTime(name, time); | |
| 726 | |
| 727 #if defined(OS_WIN) | |
| 728 #if defined(GOOGLE_CHROME_BUILD) | |
| 729 // The pre-read experiment is Windows and Google Chrome specific. | |
| 730 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 731 | |
| 732 // Only record the sub-histogram result if the experiment is running | |
| 733 // (environment variable is set, and valid). | |
| 734 std::string pre_read_percentage; | |
| 735 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { | |
| 736 std::string uma_name(name); | |
| 737 | |
| 738 // We want XP to record a separate histogram, as the loader on XP | |
| 739 // is very different from the Vista and Win7 loaders. | |
| 740 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
| 741 uma_name += "_XP"; | |
| 742 | |
| 743 uma_name += "_PreRead_"; | |
| 744 uma_name += pre_read_percentage; | |
| 745 AddPreReadHistogramTime(uma_name.c_str(), time); | |
| 746 } | |
| 747 #endif | |
| 748 #endif | |
| 749 } | |
| 750 | |
| 751 // ----------------------------------------------------------------------------- | 703 // ----------------------------------------------------------------------------- |
| 752 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. | 704 // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. |
| 753 | 705 |
| 754 #if defined(OS_WIN) | 706 #if defined(OS_WIN) |
| 755 #define DLLEXPORT __declspec(dllexport) | 707 #define DLLEXPORT __declspec(dllexport) |
| 756 | 708 |
| 757 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 709 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
| 758 extern "C" { | 710 extern "C" { |
| 759 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 711 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 760 } | 712 } |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 // Record now as the last successful chrome start. | 1485 // Record now as the last successful chrome start. |
| 1534 GoogleUpdateSettings::SetLastRunTime(); | 1486 GoogleUpdateSettings::SetLastRunTime(); |
| 1535 | 1487 |
| 1536 #if defined(OS_MACOSX) | 1488 #if defined(OS_MACOSX) |
| 1537 // Call Recycle() here as late as possible, before going into the loop | 1489 // Call Recycle() here as late as possible, before going into the loop |
| 1538 // because Start() will add things to it while creating the main window. | 1490 // because Start() will add things to it while creating the main window. |
| 1539 if (parameters().autorelease_pool) | 1491 if (parameters().autorelease_pool) |
| 1540 parameters().autorelease_pool->Recycle(); | 1492 parameters().autorelease_pool->Recycle(); |
| 1541 #endif | 1493 #endif |
| 1542 | 1494 |
| 1543 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", | 1495 base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start; |
| 1544 base::TimeTicks::Now() - browser_open_start); | 1496 UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay); |
| 1545 | 1497 |
| 1546 // If we're running tests (ui_task is non-null), then we don't want to | 1498 // If we're running tests (ui_task is non-null), then we don't want to |
| 1547 // call FetchLanguageListFromTranslateServer or | 1499 // call FetchLanguageListFromTranslateServer or |
| 1548 // StartRepeatedVariationsSeedFetch. | 1500 // StartRepeatedVariationsSeedFetch. |
| 1549 if (parameters().ui_task == NULL) { | 1501 if (parameters().ui_task == NULL) { |
| 1550 // Request new variations seed information from server. | 1502 // Request new variations seed information from server. |
| 1551 chrome_variations::VariationsService* variations_service = | 1503 chrome_variations::VariationsService* variations_service = |
| 1552 browser_process_->variations_service(); | 1504 browser_process_->variations_service(); |
| 1553 if (variations_service) { | 1505 if (variations_service) { |
| 1554 variations_service->StartRepeatedVariationsSeedFetch(); | 1506 variations_service->StartRepeatedVariationsSeedFetch(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 chromeos::CrosSettings::Shutdown(); | 1646 chromeos::CrosSettings::Shutdown(); |
| 1695 #endif | 1647 #endif |
| 1696 #endif | 1648 #endif |
| 1697 } | 1649 } |
| 1698 | 1650 |
| 1699 // Public members: | 1651 // Public members: |
| 1700 | 1652 |
| 1701 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1653 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1702 chrome_extra_parts_.push_back(parts); | 1654 chrome_extra_parts_.push_back(parts); |
| 1703 } | 1655 } |
| OLD | NEW |