Home | History | Annotate | Download | only in metrics
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "base/memory/scoped_ptr.h"
      6 #include "base/metrics/field_trial.h"
      7 
      8 namespace {
      9 
     10 // Name of field trial for that sends gzipped UMA protobufs.
     11 const char kTrialName[] = "GZippedProtobufs";
     12 
     13 // Divisor for the gzipped protobufs trial.
     14 const int kTrialDivisor = 100;
     15 
     16 // Quotient for the gzipped protobufs trial.
     17 const int kTrialQuotient = 50;
     18 
     19 // Name of the group with gzipped protobufs.
     20 const char kGroupName[] = "GzippedProtobufsEnabled";
     21 
     22 // Name of the group with non-gzipped protobufs.
     23 const char kControlGroupName[] = "GzippedProtobufsDisabled";
     24 
     25 // This is set to true if we land in the Finch group that will be sending
     26 // protobufs after compressing them.
     27 bool should_gzip_protobufs = false;
     28 
     29 }  // namespace
     30 
     31 namespace metrics {
     32 
     33 void CreateGzippedProtobufsFieldTrial() {
     34   scoped_refptr<base::FieldTrial> gzipped_protobufs_trial =
     35       base::FieldTrialList::FactoryGetFieldTrial(
     36           kTrialName,
     37           kTrialDivisor,
     38           kControlGroupName,
     39           2013,
     40           10,
     41           1,
     42           base::FieldTrial::ONE_TIME_RANDOMIZED,
     43           NULL);
     44   int gzipped_protobufs_group = gzipped_protobufs_trial->AppendGroup(
     45       kGroupName,
     46       kTrialQuotient);
     47   should_gzip_protobufs =
     48       gzipped_protobufs_trial->group() == gzipped_protobufs_group;
     49 }
     50 
     51 bool ShouldGzipProtobufsBeforeUploading() {
     52   return should_gzip_protobufs;
     53 }
     54 
     55 }  // namespace metrics
     56