| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 #if defined(OS_WIN) | 582 #if defined(OS_WIN) |
| 583 if (parsed_command_line_.HasSwitch(switches::kChromeFrame)) | 583 if (parsed_command_line_.HasSwitch(switches::kChromeFrame)) |
| 584 MetricsLog::set_version_extension("-F"); | 584 MetricsLog::set_version_extension("-F"); |
| 585 #elif defined(ARCH_CPU_64_BITS) | 585 #elif defined(ARCH_CPU_64_BITS) |
| 586 MetricsLog::set_version_extension("-64"); | 586 MetricsLog::set_version_extension("-64"); |
| 587 #endif // defined(OS_WIN) | 587 #endif // defined(OS_WIN) |
| 588 | 588 |
| 589 // Initialize FieldTrialList to support FieldTrials that use one-time | 589 // Initialize FieldTrialList to support FieldTrials that use one-time |
| 590 // randomization. | 590 // randomization. |
| 591 MetricsService* metrics = browser_process_->metrics_service(); | 591 MetricsService* metrics = browser_process_->metrics_service(); |
| 592 bool metrics_reporting_enabled = IsMetricsReportingEnabled(); | 592 MetricsService::ReportingState reporting_state = |
| 593 if (metrics_reporting_enabled) | 593 IsMetricsReportingEnabled() ? MetricsService::REPORTING_ENABLED : |
| 594 MetricsService::REPORTING_DISABLED; |
| 595 if (reporting_state == MetricsService::REPORTING_ENABLED) |
| 594 metrics->ForceClientIdCreation(); // Needed below. | 596 metrics->ForceClientIdCreation(); // Needed below. |
| 595 field_trial_list_.reset( | 597 field_trial_list_.reset( |
| 596 new base::FieldTrialList( | 598 new base::FieldTrialList( |
| 597 metrics->CreateEntropyProvider(metrics_reporting_enabled).release())); | 599 metrics->CreateEntropyProvider(reporting_state).release())); |
| 598 | 600 |
| 599 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 601 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 600 if (command_line->HasSwitch(switches::kEnableBenchmarking)) | 602 if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| 601 base::FieldTrial::EnableBenchmarking(); | 603 base::FieldTrial::EnableBenchmarking(); |
| 602 | 604 |
| 603 // Ensure any field trials specified on the command line are initialized. | 605 // Ensure any field trials specified on the command line are initialized. |
| 604 // Also stop the metrics service so that we don't pollute UMA. | 606 // Also stop the metrics service so that we don't pollute UMA. |
| 605 if (command_line->HasSwitch(switches::kForceFieldTrials)) { | 607 if (command_line->HasSwitch(switches::kForceFieldTrials)) { |
| 606 // Create field trials without activating them, so that this behaves in a | 608 // Create field trials without activating them, so that this behaves in a |
| 607 // consistent manner with field trials created from the server. | 609 // consistent manner with field trials created from the server. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 627 variations_service->CreateTrialsFromSeed(); | 629 variations_service->CreateTrialsFromSeed(); |
| 628 | 630 |
| 629 // This must be called after the local state is initialized. | 631 // This must be called after the local state is initialized. |
| 630 browser_field_trials_.SetupFieldTrials(local_state_); | 632 browser_field_trials_.SetupFieldTrials(local_state_); |
| 631 | 633 |
| 632 // Initialize FieldTrialSynchronizer system. This is a singleton and is used | 634 // Initialize FieldTrialSynchronizer system. This is a singleton and is used |
| 633 // for posting tasks via base::Bind. Its deleted when it goes out of scope. | 635 // for posting tasks via base::Bind. Its deleted when it goes out of scope. |
| 634 // Even though base::Bind does AddRef and Release, the object will not be | 636 // Even though base::Bind does AddRef and Release, the object will not be |
| 635 // deleted after the Task is executed. | 637 // deleted after the Task is executed. |
| 636 field_trial_synchronizer_ = new FieldTrialSynchronizer(); | 638 field_trial_synchronizer_ = new FieldTrialSynchronizer(); |
| 639 |
| 640 // Now that field trials have been created, initializes metrics recording. |
| 641 metrics->InitializeMetricsRecordingState(reporting_state); |
| 637 } | 642 } |
| 638 | 643 |
| 639 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- | 644 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- |
| 640 | 645 |
| 641 void ChromeBrowserMainParts::StartMetricsRecording() { | 646 void ChromeBrowserMainParts::StartMetricsRecording() { |
| 642 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); | 647 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); |
| 643 MetricsService* metrics = g_browser_process->metrics_service(); | 648 MetricsService* metrics = g_browser_process->metrics_service(); |
| 644 | 649 |
| 645 const bool only_do_metrics_recording = | 650 const bool only_do_metrics_recording = |
| 646 parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) || | 651 parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) || |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 chromeos::CrosSettings::Shutdown(); | 1712 chromeos::CrosSettings::Shutdown(); |
| 1708 #endif | 1713 #endif |
| 1709 #endif | 1714 #endif |
| 1710 } | 1715 } |
| 1711 | 1716 |
| 1712 // Public members: | 1717 // Public members: |
| 1713 | 1718 |
| 1714 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1719 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 1715 chrome_extra_parts_.push_back(parts); | 1720 chrome_extra_parts_.push_back(parts); |
| 1716 } | 1721 } |
| OLD | NEW |