summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/gzipped_protobufs_field_trial.cc
blob: e12290d9009f916dd8a1b3fb24c9068878b8204f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"

namespace {

// Name of field trial for that sends gzipped UMA protobufs.
const char kTrialName[] = "GZippedProtobufs";

// Divisor for the gzipped protobufs trial.
const int kTrialDivisor = 100;

// Quotient for the gzipped protobufs trial.
const int kTrialQuotient = 50;

// Name of the group with gzipped protobufs.
const char kGroupName[] = "GzippedProtobufsEnabled";

// Name of the group with non-gzipped protobufs.
const char kControlGroupName[] = "GzippedProtobufsDisabled";

// This is set to true if we land in the Finch group that will be sending
// protobufs after compressing them.
bool should_gzip_protobufs = false;

}  // namespace

namespace metrics {

void CreateGzippedProtobufsFieldTrial() {
  scoped_refptr<base::FieldTrial> gzipped_protobufs_trial =
      base::FieldTrialList::FactoryGetFieldTrial(
          kTrialName,
          kTrialDivisor,
          kControlGroupName,
          2013,
          9,
          1,
          NULL);
  gzipped_protobufs_trial->UseOneTimeRandomization();
  int gzipped_protobufs_group = gzipped_protobufs_trial->AppendGroup(
      kGroupName,
      kTrialQuotient);
  should_gzip_protobufs =
      gzipped_protobufs_trial->group() == gzipped_protobufs_group;
}

bool ShouldGzipProtobufsBeforeUploading() {
  return should_gzip_protobufs;
}

}  // namespace metrics