Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: chrome/browser/gpu_util.cc

Issue 10541019: Adding a field trial for testing --force-compositing-mode on 50% of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gpu_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gpu_util.cc
===================================================================
--- chrome/browser/gpu_util.cc (revision 140632)
+++ chrome/browser/gpu_util.cc (working copy)
@@ -7,6 +7,7 @@
#include <vector>
#include "base/command_line.h"
+#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
@@ -15,10 +16,17 @@
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/gpu_blacklist.h"
+#include "chrome/common/chrome_version_info.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/gpu_info.h"
+#if defined(OS_WIN)
+#include "base/win/windows_version.h"
+#elif defined(OS_MAC)
+#include "base/mac/mac_util.h"
+#endif
+
using content::GpuDataManager;
using content::GpuFeatureType;
@@ -162,6 +170,53 @@
namespace gpu_util {
+const char kForceCompositingModeFieldTrialName[] = "ForceCompositingMode";
+const char kFieldTrialEnabledName[] = "enabled";
+
+void InitializeForceCompositingModeFieldTrial() {
+// Enable the field trial only on desktop OS's.
+#if !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
+ return;
+#endif
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+ // Only run the trial on the Canary channel.
+ if (channel != chrome::VersionInfo::CHANNEL_CANARY)
+ return;
+#if defined(OS_WIN)
+ // Don't run the trial on Windows XP.
+ if (base::win::GetVersion() < base::win::VERSION_VISTA)
+ return;
+#elif defined(OS_MACOSX)
+ // Accelerated compositing is only implemented on Mac OSX 10.6 or later.
+ if (base::mac::IsOSLeopardOrEarlier())
+ return;
+#endif
+
+ const base::FieldTrial::Probability kDivisor = 100;
+ scoped_refptr<base::FieldTrial> trial(
+ base::FieldTrialList::FactoryGetFieldTrial(
+ kForceCompositingModeFieldTrialName, kDivisor,
+ "disable", 2012, 12, 31, NULL));
+
+ // Produce the same result on every run of this client.
+ trial->UseOneTimeRandomization();
+ // 50% probability of being in the enabled group.
+ const base::FieldTrial::Probability kEnableProbability = 50;
+ int enable_group = trial->AppendGroup(
+ kFieldTrialEnabledName, kEnableProbability);
+
+ bool enabled = (trial->group() == enable_group);
+ UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", enabled);
+}
+
+bool InForceCompositingModeTrial() {
+ base::FieldTrial* trial =
+ base::FieldTrialList::Find(kForceCompositingModeFieldTrialName);
+ if (!trial)
+ return false;
+ return trial->group_name() == kFieldTrialEnabledName;
+}
+
GpuFeatureType StringToGpuFeatureType(const std::string& feature_string) {
if (feature_string == kGpuFeatureNameAccelerated2dCanvas)
return content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS;
@@ -314,8 +369,9 @@
(!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableThreadedCompositing));
if (kGpuFeatureInfo[i].name == "compositing" &&
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kForceCompositingMode))
+ (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kForceCompositingMode) ||
+ InForceCompositingModeTrial()))
jar (doing other things) 2012/06/08 00:03:25 nit: indent: It is hard to say how to fix this up.
status += "_force";
if (kGpuFeatureInfo[i].name == "compositing" &&
has_thread)
« no previous file with comments | « chrome/browser/gpu_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698