| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 #if defined(OS_WIN) | 533 #if defined(OS_WIN) |
| 534 if (parsed_command_line_.HasSwitch(switches::kChromeFrame)) | 534 if (parsed_command_line_.HasSwitch(switches::kChromeFrame)) |
| 535 MetricsLog::set_version_extension("-F"); | 535 MetricsLog::set_version_extension("-F"); |
| 536 #elif defined(ARCH_CPU_64_BITS) | 536 #elif defined(ARCH_CPU_64_BITS) |
| 537 MetricsLog::set_version_extension("-64"); | 537 MetricsLog::set_version_extension("-64"); |
| 538 #endif // defined(OS_WIN) | 538 #endif // defined(OS_WIN) |
| 539 | 539 |
| 540 // Initialize FieldTrialList to support FieldTrials that use one-time | 540 // Initialize FieldTrialList to support FieldTrials that use one-time |
| 541 // randomization. | 541 // randomization. |
| 542 MetricsService* metrics = browser_process_->metrics_service(); | 542 MetricsService* metrics = browser_process_->metrics_service(); |
| 543 if (IsMetricsReportingEnabled()) | 543 bool metrics_reporting_enabled = IsMetricsReportingEnabled(); |
| 544 if (metrics_reporting_enabled) |
| 544 metrics->ForceClientIdCreation(); // Needed below. | 545 metrics->ForceClientIdCreation(); // Needed below. |
| 545 field_trial_list_.reset( | 546 field_trial_list_.reset( |
| 546 new base::FieldTrialList(metrics->GetEntropySource())); | 547 new base::FieldTrialList( |
| 548 metrics->GetEntropySource(metrics_reporting_enabled))); |
| 547 | 549 |
| 548 // Ensure any field trials specified on the command line are initialized. | 550 // Ensure any field trials specified on the command line are initialized. |
| 549 // Also stop the metrics service so that we don't pollute UMA. | 551 // Also stop the metrics service so that we don't pollute UMA. |
| 550 #ifndef NDEBUG | 552 #ifndef NDEBUG |
| 551 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 553 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 552 if (command_line->HasSwitch(switches::kForceFieldTrials)) { | 554 if (command_line->HasSwitch(switches::kForceFieldTrials)) { |
| 553 std::string persistent = command_line->GetSwitchValueASCII( | 555 std::string persistent = command_line->GetSwitchValueASCII( |
| 554 switches::kForceFieldTrials); | 556 switches::kForceFieldTrials); |
| 555 bool ret = base::FieldTrialList::CreateTrialsFromString(persistent); | 557 bool ret = base::FieldTrialList::CreateTrialsFromString(persistent); |
| 556 CHECK(ret) << "Invalid --" << switches::kForceFieldTrials << | 558 CHECK(ret) << "Invalid --" << switches::kForceFieldTrials << |
| (...skipping 29 matching lines...) Expand all Loading... |
| 586 return; | 588 return; |
| 587 } | 589 } |
| 588 | 590 |
| 589 if (IsMetricsReportingEnabled()) | 591 if (IsMetricsReportingEnabled()) |
| 590 metrics->Start(); | 592 metrics->Start(); |
| 591 } | 593 } |
| 592 | 594 |
| 593 bool ChromeBrowserMainParts::IsMetricsReportingEnabled() { | 595 bool ChromeBrowserMainParts::IsMetricsReportingEnabled() { |
| 594 // If the user permits metrics reporting with the checkbox in the | 596 // If the user permits metrics reporting with the checkbox in the |
| 595 // prefs, we turn on recording. We disable metrics completely for | 597 // prefs, we turn on recording. We disable metrics completely for |
| 596 // non-official builds. | 598 // non-official builds. This can be forced with a flag. |
| 599 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 600 if (command_line->HasSwitch(switches::kEnableMetricsReportingForTesting)) |
| 601 return true; |
| 602 |
| 597 bool enabled = false; | 603 bool enabled = false; |
| 598 #ifndef NDEBUG | 604 #ifndef NDEBUG |
| 599 // The debug build doesn't send UMA logs when FieldTrials are forced. | 605 // The debug build doesn't send UMA logs when FieldTrials are forced. |
| 600 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 601 if (command_line->HasSwitch(switches::kForceFieldTrials)) | 606 if (command_line->HasSwitch(switches::kForceFieldTrials)) |
| 602 return false; | 607 return false; |
| 603 #endif // #ifndef NDEBUG | 608 #endif // #ifndef NDEBUG |
| 604 | 609 |
| 605 #if defined(GOOGLE_CHROME_BUILD) | 610 #if defined(GOOGLE_CHROME_BUILD) |
| 606 #if defined(OS_CHROMEOS) | 611 #if defined(OS_CHROMEOS) |
| 607 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 612 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
| 608 &enabled); | 613 &enabled); |
| 609 #else | 614 #else |
| 610 enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled); | 615 enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled); |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1529 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1525 uma_name += "_XP"; | 1530 uma_name += "_XP"; |
| 1526 | 1531 |
| 1527 uma_name += "_PreRead_"; | 1532 uma_name += "_PreRead_"; |
| 1528 uma_name += pre_read_percentage; | 1533 uma_name += pre_read_percentage; |
| 1529 AddPreReadHistogramTime(uma_name.c_str(), time); | 1534 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1530 } | 1535 } |
| 1531 #endif | 1536 #endif |
| 1532 #endif | 1537 #endif |
| 1533 } | 1538 } |
| OLD | NEW |