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_field_trials.h" | 5 #include "chrome/browser/chrome_browser_field_trials.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/feature_list.h" | |
10 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram_base.h" | |
13 #include "base/metrics/histogram_persistence.h" | |
11 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
12 #include "base/time/time.h" | 15 #include "base/time/time.h" |
13 #include "build/build_config.h" | 16 #include "build/build_config.h" |
14 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
15 #include "components/metrics/metrics_pref_names.h" | 18 #include "components/metrics/metrics_pref_names.h" |
16 #include "components/omnibox/browser/omnibox_field_trial.h" | 19 #include "components/omnibox/browser/omnibox_field_trial.h" |
17 | 20 |
18 #if defined(OS_ANDROID) || defined(OS_IOS) | 21 #if defined(OS_ANDROID) || defined(OS_IOS) |
19 #include "chrome/browser/chrome_browser_field_trials_mobile.h" | 22 #include "chrome/browser/chrome_browser_field_trials_mobile.h" |
20 #else | 23 #else |
(...skipping 13 matching lines...) Expand all Loading... | |
34 InstantiateDynamicTrials(); | 37 InstantiateDynamicTrials(); |
35 | 38 |
36 #if defined(OS_ANDROID) || defined(OS_IOS) | 39 #if defined(OS_ANDROID) || defined(OS_IOS) |
37 chrome::SetupMobileFieldTrials(parsed_command_line_); | 40 chrome::SetupMobileFieldTrials(parsed_command_line_); |
38 #else | 41 #else |
39 chrome::SetupDesktopFieldTrials(parsed_command_line_); | 42 chrome::SetupDesktopFieldTrials(parsed_command_line_); |
40 #endif | 43 #endif |
41 } | 44 } |
42 | 45 |
43 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { | 46 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { |
47 // Persistent histograms must be enabled as soon as possible. | |
48 if (base::FeatureList::IsEnabled(base::kPersistentHistogramsFeature)) { | |
Alexei Svitkine (slow)
2016/01/14 16:43:14
You define the feature in base/ but only query it
bcwhite
2016/01/14 19:20:26
I want the same parameter to control all. I just
Alexei Svitkine (slow)
2016/01/14 21:53:41
I thought we weren't certain if we wanted the brow
bcwhite
2016/01/15 15:24:38
There's no persistence on the Browser side but mov
| |
49 const std::string allocator_name("BrowserMetricsAllocator"); | |
50 // Create persistent/shared memory and allow histograms to be stored in it. | |
51 // TODO(bcwhite): Update this with correct allocator and memory size. | |
52 base::SetPersistentHistogramMemoryAllocator( | |
53 new base::LocalPersistentMemoryAllocator(1 << 20, // 1 MiB | |
54 0x4D5B9953, // SHA1(B..M..A..) | |
55 allocator_name)); | |
56 base::GetPersistentHistogramMemoryAllocator()->CreateHistograms( | |
57 allocator_name); | |
58 } | |
Alexei Svitkine (slow)
2016/01/14 16:43:14
Can you move this new code to a helper function?
bcwhite
2016/01/14 19:20:26
I looked at that and it would have to be a helper
Alexei Svitkine (slow)
2016/01/18 19:25:35
Okay, please at least make it an anon function at
bcwhite
2016/01/20 15:26:14
Done.
| |
44 // The following trials are used from renderer process. | 59 // The following trials are used from renderer process. |
45 // Mark here so they will be sync-ed. | 60 // Mark here so they will be sync-ed. |
46 base::FieldTrialList::FindValue("DisplayList2dCanvas"); | 61 base::FieldTrialList::FindValue("DisplayList2dCanvas"); |
47 // Activate the autocomplete dynamic field trials. | 62 // Activate the autocomplete dynamic field trials. |
48 OmniboxFieldTrial::ActivateDynamicTrials(); | 63 OmniboxFieldTrial::ActivateDynamicTrials(); |
49 } | 64 } |
OLD | NEW |