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 "base/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 // Use shared memory to communicate field trial (experiment) state. Set to false | 37 // Use shared memory to communicate field trial (experiment) state. Set to false |
38 // for now while the implementation is fleshed out (e.g. data format, single | 38 // for now while the implementation is fleshed out (e.g. data format, single |
39 // shared memory segment). See https://codereview.chromium.org/2365273004/ and | 39 // shared memory segment). See https://codereview.chromium.org/2365273004/ and |
40 // crbug.com/653874 | 40 // crbug.com/653874 |
41 const bool kUseSharedMemoryForFieldTrials = false; | 41 const bool kUseSharedMemoryForFieldTrials = false; |
42 | 42 |
43 // Constants for the field trial allocator. | 43 // Constants for the field trial allocator. |
44 const char kAllocatorName[] = "FieldTrialAllocator"; | 44 const char kAllocatorName[] = "FieldTrialAllocator"; |
45 const uint32_t kFieldTrialType = 0xABA17E13 + 1; // SHA1(FieldTrialEntry) v1 | 45 const uint32_t kFieldTrialType = 0xABA17E13 + 1; // SHA1(FieldTrialEntry) v1 |
46 #if !defined(OS_NACL) | 46 const size_t kFieldTrialAllocationSize = 4 << 14; // 64 KiB should be enough |
Alexei Svitkine (slow)
2016/11/08 18:15:23
The "should be enough" comment is not useful.
I
| |
47 const size_t kFieldTrialAllocationSize = 4 << 10; // 4 KiB = one page | |
48 #endif | |
49 | 47 |
50 // We create one FieldTrialEntry per field trial in shared memory, via | 48 // We create one FieldTrialEntry per field trial in shared memory, via |
51 // AddToAllocatorWhileLocked. The FieldTrialEntry is followed by a base::Pickle | 49 // AddToAllocatorWhileLocked. The FieldTrialEntry is followed by a base::Pickle |
52 // object that we unpickle and read from. | 50 // object that we unpickle and read from. |
53 struct FieldTrialEntry { | 51 struct FieldTrialEntry { |
54 bool activated; | 52 bool activated; |
55 | 53 |
56 // Size of the pickled structure, NOT the total size of this entry. | 54 // Size of the pickled structure, NOT the total size of this entry. |
57 uint32_t size; | 55 uint32_t size; |
58 | 56 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 // command-line flag. The child process will do the reverse conversions to | 719 // command-line flag. The child process will do the reverse conversions to |
722 // retrieve the handle. See http://stackoverflow.com/a/153077 | 720 // retrieve the handle. See http://stackoverflow.com/a/153077 |
723 auto uintptr_handle = | 721 auto uintptr_handle = |
724 reinterpret_cast<uintptr_t>(global_->readonly_allocator_handle_); | 722 reinterpret_cast<uintptr_t>(global_->readonly_allocator_handle_); |
725 size_t field_trial_length = | 723 size_t field_trial_length = |
726 global_->field_trial_allocator_->shared_memory()->mapped_size(); | 724 global_->field_trial_allocator_->shared_memory()->mapped_size(); |
727 std::string field_trial_handle = std::to_string(uintptr_handle) + "," + | 725 std::string field_trial_handle = std::to_string(uintptr_handle) + "," + |
728 std::to_string(field_trial_length); | 726 std::to_string(field_trial_length); |
729 | 727 |
730 cmd_line->AppendSwitchASCII(field_trial_handle_switch, field_trial_handle); | 728 cmd_line->AppendSwitchASCII(field_trial_handle_switch, field_trial_handle); |
731 UMA_HISTOGRAM_COUNTS_10000("UMA.FieldTrialAllocator.Size", | 729 UMA_HISTOGRAM_COUNTS_100000("UMA.FieldTrialAllocator.Size", |
Alexei Svitkine (slow)
2016/11/08 18:15:23
Changing the macro without changing histogram name
Alexei Svitkine (slow)
2016/11/08 18:18:38
For the rename, you can use "2" suffix to the name
| |
732 field_trial_length); | 730 global_->field_trial_allocator_->used()); |
733 return; | 731 return; |
734 } | 732 } |
735 #endif | 733 #endif |
736 | 734 |
737 AddForceFieldTrialsFlag(cmd_line); | 735 AddForceFieldTrialsFlag(cmd_line); |
738 } | 736 } |
739 | 737 |
740 // static | 738 // static |
741 FieldTrial* FieldTrialList::CreateFieldTrial( | 739 FieldTrial* FieldTrialList::CreateFieldTrial( |
742 const std::string& name, | 740 const std::string& name, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 return; | 970 return; |
973 } | 971 } |
974 AutoLock auto_lock(global_->lock_); | 972 AutoLock auto_lock(global_->lock_); |
975 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); | 973 CHECK(!global_->PreLockedFind(trial->trial_name())) << trial->trial_name(); |
976 trial->AddRef(); | 974 trial->AddRef(); |
977 trial->SetTrialRegistered(); | 975 trial->SetTrialRegistered(); |
978 global_->registered_[trial->trial_name()] = trial; | 976 global_->registered_[trial->trial_name()] = trial; |
979 } | 977 } |
980 | 978 |
981 } // namespace base | 979 } // namespace base |
OLD | NEW |