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/about_flags.h" | 5 #include "chrome/browser/about_flags.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 {"enable-ppapi-win32k-lockdown", | 2119 {"enable-ppapi-win32k-lockdown", |
2120 IDS_FLAGS_PPAPI_WIN32K_LOCKDOWN_NAME, | 2120 IDS_FLAGS_PPAPI_WIN32K_LOCKDOWN_NAME, |
2121 IDS_FLAGS_PPAPI_WIN32K_LOCKDOWN_DESCRIPTION, kOsWin, | 2121 IDS_FLAGS_PPAPI_WIN32K_LOCKDOWN_DESCRIPTION, kOsWin, |
2122 MULTI_VALUE_TYPE(kPpapiWin32kLockdown)}, | 2122 MULTI_VALUE_TYPE(kPpapiWin32kLockdown)}, |
2123 #endif // defined(OS_WIN) | 2123 #endif // defined(OS_WIN) |
2124 // NOTE: Adding new command-line switches requires adding corresponding | 2124 // NOTE: Adding new command-line switches requires adding corresponding |
2125 // entries to enum "LoginCustomFlags" in histograms.xml. See note in | 2125 // entries to enum "LoginCustomFlags" in histograms.xml. See note in |
2126 // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test. | 2126 // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test. |
2127 }; | 2127 }; |
2128 | 2128 |
2129 const FeatureEntry* g_entries = kFeatureEntries; | |
2130 size_t g_num_entries = arraysize(kFeatureEntries); | |
2131 | |
2132 // Stores and encapsulates the little state that about:flags has. | 2129 // Stores and encapsulates the little state that about:flags has. |
2133 class FlagsState { | 2130 class FlagsState { |
2134 public: | 2131 public: |
2135 FlagsState() : needs_restart_(false) {} | 2132 FlagsState() |
| 2133 : feature_entries(kFeatureEntries), |
| 2134 num_feature_entries(arraysize(kFeatureEntries)), |
| 2135 needs_restart_(false) {} |
2136 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, | 2136 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, |
2137 base::CommandLine* command_line, | 2137 base::CommandLine* command_line, |
2138 SentinelsMode sentinels); | 2138 SentinelsMode sentinels); |
2139 bool IsRestartNeededToCommitChanges(); | 2139 bool IsRestartNeededToCommitChanges(); |
2140 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, | 2140 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, |
2141 const std::string& internal_name, | 2141 const std::string& internal_name, |
2142 bool enable); | 2142 bool enable); |
2143 void RemoveFlagsSwitches( | 2143 void RemoveFlagsSwitches( |
2144 std::map<std::string, base::CommandLine::StringType>* switch_list); | 2144 std::map<std::string, base::CommandLine::StringType>* switch_list); |
2145 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage); | 2145 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage); |
2146 void reset(); | 2146 void Reset(); |
| 2147 |
| 2148 // Gets the list of feature entries. Entries that are available for the |
| 2149 // current platform are appended to |supported_entries|; all other entries are |
| 2150 // appended to |unsupported_entries|. |
| 2151 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, |
| 2152 FlagAccess access, |
| 2153 base::ListValue* supported_entries, |
| 2154 base::ListValue* unsupported_entries); |
| 2155 |
| 2156 void SetFeatureEntries(const FeatureEntry* entries, size_t count); |
| 2157 const FeatureEntry* GetFeatureEntries(size_t* count); |
2147 | 2158 |
2148 // Returns the singleton instance of this class | 2159 // Returns the singleton instance of this class |
2149 static FlagsState* GetInstance() { | 2160 static FlagsState* GetInstance() { |
2150 return base::Singleton<FlagsState>::get(); | 2161 return base::Singleton<FlagsState>::get(); |
2151 } | 2162 } |
2152 | 2163 |
2153 private: | 2164 private: |
| 2165 // Removes all entries from prefs::kEnabledLabsExperiments that are unknown, |
| 2166 // to prevent this list to become very long as entries are added and removed. |
| 2167 void SanitizeList(flags_ui::FlagsStorage* flags_storage); |
| 2168 |
| 2169 void GetSanitizedEnabledFlags(flags_ui::FlagsStorage* flags_storage, |
| 2170 std::set<std::string>* result); |
| 2171 |
| 2172 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't |
| 2173 // enabled on the current platform. |
| 2174 void GetSanitizedEnabledFlagsForCurrentPlatform( |
| 2175 flags_ui::FlagsStorage* flags_storage, |
| 2176 std::set<std::string>* result); |
| 2177 |
| 2178 const FeatureEntry* feature_entries; |
| 2179 size_t num_feature_entries; |
| 2180 |
2154 bool needs_restart_; | 2181 bool needs_restart_; |
2155 std::map<std::string, std::string> flags_switches_; | 2182 std::map<std::string, std::string> flags_switches_; |
2156 | 2183 |
2157 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 2184 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
2158 }; | 2185 }; |
2159 | 2186 |
2160 // Adds the internal names for the specified entry to |names|. | 2187 // Adds the internal names for the specified entry to |names|. |
2161 void AddInternalName(const FeatureEntry& e, std::set<std::string>* names) { | 2188 void AddInternalName(const FeatureEntry& e, std::set<std::string>* names) { |
2162 if (e.type == FeatureEntry::SINGLE_VALUE || | 2189 if (e.type == FeatureEntry::SINGLE_VALUE || |
2163 e.type == FeatureEntry::SINGLE_DISABLE_VALUE) { | 2190 e.type == FeatureEntry::SINGLE_DISABLE_VALUE) { |
(...skipping 28 matching lines...) Expand all Loading... |
2192 DCHECK(e.command_line_value); | 2219 DCHECK(e.command_line_value); |
2193 DCHECK(e.disable_command_line_switch); | 2220 DCHECK(e.disable_command_line_switch); |
2194 DCHECK(e.disable_command_line_value); | 2221 DCHECK(e.disable_command_line_value); |
2195 break; | 2222 break; |
2196 default: | 2223 default: |
2197 NOTREACHED(); | 2224 NOTREACHED(); |
2198 } | 2225 } |
2199 return true; | 2226 return true; |
2200 } | 2227 } |
2201 | 2228 |
2202 // Removes all entries from prefs::kEnabledLabsExperiments that are | 2229 void FlagsState::SanitizeList(flags_ui::FlagsStorage* flags_storage) { |
2203 // unknown, to prevent this list to become very long as entries are added | |
2204 // and removed. | |
2205 void SanitizeList(flags_ui::FlagsStorage* flags_storage) { | |
2206 std::set<std::string> known_entries; | 2230 std::set<std::string> known_entries; |
2207 for (size_t i = 0; i < g_num_entries; ++i) { | 2231 for (size_t i = 0; i < num_feature_entries; ++i) { |
2208 DCHECK(ValidateFeatureEntry(g_entries[i])); | 2232 DCHECK(ValidateFeatureEntry(feature_entries[i])); |
2209 AddInternalName(g_entries[i], &known_entries); | 2233 AddInternalName(feature_entries[i], &known_entries); |
2210 } | 2234 } |
2211 | 2235 |
2212 std::set<std::string> enabled_entries = flags_storage->GetFlags(); | 2236 std::set<std::string> enabled_entries = flags_storage->GetFlags(); |
2213 | 2237 |
2214 std::set<std::string> new_enabled_entries = | 2238 std::set<std::string> new_enabled_entries = |
2215 base::STLSetIntersection<std::set<std::string> >( | 2239 base::STLSetIntersection<std::set<std::string> >( |
2216 known_entries, enabled_entries); | 2240 known_entries, enabled_entries); |
2217 | 2241 |
2218 if (new_enabled_entries != enabled_entries) | 2242 if (new_enabled_entries != enabled_entries) |
2219 flags_storage->SetFlags(new_enabled_entries); | 2243 flags_storage->SetFlags(new_enabled_entries); |
2220 } | 2244 } |
2221 | 2245 |
2222 void GetSanitizedEnabledFlags(flags_ui::FlagsStorage* flags_storage, | 2246 void FlagsState::GetSanitizedEnabledFlags(flags_ui::FlagsStorage* flags_storage, |
2223 std::set<std::string>* result) { | 2247 std::set<std::string>* result) { |
2224 SanitizeList(flags_storage); | 2248 SanitizeList(flags_storage); |
2225 *result = flags_storage->GetFlags(); | 2249 *result = flags_storage->GetFlags(); |
2226 } | 2250 } |
2227 | 2251 |
2228 bool SkipConditionalFeatureEntry(const FeatureEntry& entry) { | 2252 bool SkipConditionalFeatureEntry(const FeatureEntry& entry) { |
2229 version_info::Channel channel = chrome::GetChannel(); | 2253 version_info::Channel channel = chrome::GetChannel(); |
2230 | 2254 |
2231 #if defined(OS_ANDROID) | 2255 #if defined(OS_ANDROID) |
2232 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. | 2256 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. |
2233 if (!strcmp("enable-data-reduction-proxy-dev", entry.internal_name) && | 2257 if (!strcmp("enable-data-reduction-proxy-dev", entry.internal_name) && |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 channel != version_info::Channel::UNKNOWN && | 2303 channel != version_info::Channel::UNKNOWN && |
2280 channel != version_info::Channel::CANARY && | 2304 channel != version_info::Channel::CANARY && |
2281 channel != version_info::Channel::DEV) { | 2305 channel != version_info::Channel::DEV) { |
2282 return true; | 2306 return true; |
2283 } | 2307 } |
2284 #endif | 2308 #endif |
2285 | 2309 |
2286 return false; | 2310 return false; |
2287 } | 2311 } |
2288 | 2312 |
2289 | 2313 void FlagsState::GetSanitizedEnabledFlagsForCurrentPlatform( |
2290 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't | |
2291 // enabled on the current platform. | |
2292 void GetSanitizedEnabledFlagsForCurrentPlatform( | |
2293 flags_ui::FlagsStorage* flags_storage, | 2314 flags_ui::FlagsStorage* flags_storage, |
2294 std::set<std::string>* result) { | 2315 std::set<std::string>* result) { |
2295 GetSanitizedEnabledFlags(flags_storage, result); | 2316 GetSanitizedEnabledFlags(flags_storage, result); |
2296 | 2317 |
2297 // Filter out any entries that aren't enabled on the current platform. We | 2318 // Filter out any entries that aren't enabled on the current platform. We |
2298 // don't remove these from prefs else syncing to a platform with a different | 2319 // don't remove these from prefs else syncing to a platform with a different |
2299 // set of entries would be lossy. | 2320 // set of entries would be lossy. |
2300 std::set<std::string> platform_entries; | 2321 std::set<std::string> platform_entries; |
2301 int current_platform = GetCurrentPlatform(); | 2322 int current_platform = GetCurrentPlatform(); |
2302 for (size_t i = 0; i < g_num_entries; ++i) { | 2323 for (size_t i = 0; i < num_feature_entries; ++i) { |
2303 const FeatureEntry& entry = g_entries[i]; | 2324 const FeatureEntry& entry = feature_entries[i]; |
2304 if (entry.supported_platforms & current_platform) | 2325 if (entry.supported_platforms & current_platform) |
2305 AddInternalName(entry, &platform_entries); | 2326 AddInternalName(entry, &platform_entries); |
2306 #if defined(OS_CHROMEOS) | 2327 #if defined(OS_CHROMEOS) |
2307 if (g_entries[i].supported_platforms & kOsCrOSOwnerOnly) | 2328 if (feature_entries[i].supported_platforms & kOsCrOSOwnerOnly) |
2308 AddInternalName(entry, &platform_entries); | 2329 AddInternalName(entry, &platform_entries); |
2309 #endif | 2330 #endif |
2310 } | 2331 } |
2311 | 2332 |
2312 std::set<std::string> new_enabled_entries = | 2333 std::set<std::string> new_enabled_entries = |
2313 base::STLSetIntersection<std::set<std::string> >( | 2334 base::STLSetIntersection<std::set<std::string> >( |
2314 platform_entries, *result); | 2335 platform_entries, *result); |
2315 | 2336 |
2316 result->swap(new_enabled_entries); | 2337 result->swap(new_enabled_entries); |
2317 } | 2338 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2412 new_flags.begin(), | 2433 new_flags.begin(), |
2413 new_flags.end(), | 2434 new_flags.end(), |
2414 active_flags.begin(), | 2435 active_flags.begin(), |
2415 active_flags.end(), | 2436 active_flags.end(), |
2416 std::inserter(*out_difference, out_difference->begin())); | 2437 std::inserter(*out_difference, out_difference->begin())); |
2417 } | 2438 } |
2418 | 2439 |
2419 return result; | 2440 return result; |
2420 } | 2441 } |
2421 | 2442 |
2422 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, | 2443 void FlagsState::GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, |
2423 FlagAccess access, | 2444 FlagAccess access, |
2424 base::ListValue* supported_entries, | 2445 base::ListValue* supported_entries, |
2425 base::ListValue* unsupported_entries) { | 2446 base::ListValue* unsupported_entries) { |
2426 std::set<std::string> enabled_entries; | 2447 std::set<std::string> enabled_entries; |
2427 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); | 2448 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); |
2428 | 2449 |
2429 int current_platform = GetCurrentPlatform(); | 2450 int current_platform = GetCurrentPlatform(); |
2430 | 2451 |
2431 for (size_t i = 0; i < g_num_entries; ++i) { | 2452 for (size_t i = 0; i < num_feature_entries; ++i) { |
2432 const FeatureEntry& entry = g_entries[i]; | 2453 const FeatureEntry& entry = feature_entries[i]; |
2433 if (SkipConditionalFeatureEntry(entry)) | 2454 if (SkipConditionalFeatureEntry(entry)) |
2434 continue; | 2455 continue; |
2435 | 2456 |
2436 base::DictionaryValue* data = new base::DictionaryValue(); | 2457 base::DictionaryValue* data = new base::DictionaryValue(); |
2437 data->SetString("internal_name", entry.internal_name); | 2458 data->SetString("internal_name", entry.internal_name); |
2438 data->SetString("name", | 2459 data->SetString("name", |
2439 l10n_util::GetStringUTF16(entry.visible_name_id)); | 2460 l10n_util::GetStringUTF16(entry.visible_name_id)); |
2440 data->SetString("description", | 2461 data->SetString("description", |
2441 l10n_util::GetStringUTF16( | 2462 l10n_util::GetStringUTF16( |
2442 entry.visible_description_id)); | 2463 entry.visible_description_id)); |
(...skipping 30 matching lines...) Expand all Loading... |
2473 supported = true; | 2494 supported = true; |
2474 } | 2495 } |
2475 #endif | 2496 #endif |
2476 if (supported) | 2497 if (supported) |
2477 supported_entries->Append(data); | 2498 supported_entries->Append(data); |
2478 else | 2499 else |
2479 unsupported_entries->Append(data); | 2500 unsupported_entries->Append(data); |
2480 } | 2501 } |
2481 } | 2502 } |
2482 | 2503 |
| 2504 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage, |
| 2505 FlagAccess access, |
| 2506 base::ListValue* supported_entries, |
| 2507 base::ListValue* unsupported_entries) { |
| 2508 FlagsState::GetInstance()->GetFlagFeatureEntries(flags_storage, access, |
| 2509 supported_entries, |
| 2510 unsupported_entries); |
| 2511 } |
| 2512 |
2483 bool IsRestartNeededToCommitChanges() { | 2513 bool IsRestartNeededToCommitChanges() { |
2484 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges(); | 2514 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges(); |
2485 } | 2515 } |
2486 | 2516 |
2487 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, | 2517 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage, |
2488 const std::string& internal_name, | 2518 const std::string& internal_name, |
2489 bool enable) { | 2519 bool enable) { |
2490 FlagsState::GetInstance()->SetFeatureEntryEnabled(flags_storage, | 2520 FlagsState::GetInstance()->SetFeatureEntryEnabled(flags_storage, |
2491 internal_name, enable); | 2521 internal_name, enable); |
2492 } | 2522 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2583 SentinelsMode sentinels) { | 2613 SentinelsMode sentinels) { |
2584 if (command_line->HasSwitch(switches::kNoExperiments)) | 2614 if (command_line->HasSwitch(switches::kNoExperiments)) |
2585 return; | 2615 return; |
2586 | 2616 |
2587 std::set<std::string> enabled_entries; | 2617 std::set<std::string> enabled_entries; |
2588 | 2618 |
2589 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage, | 2619 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage, |
2590 &enabled_entries); | 2620 &enabled_entries); |
2591 | 2621 |
2592 NameToSwitchAndValueMap name_to_switch_map; | 2622 NameToSwitchAndValueMap name_to_switch_map; |
2593 for (size_t i = 0; i < g_num_entries; ++i) { | 2623 for (size_t i = 0; i < num_feature_entries; ++i) { |
2594 const FeatureEntry& e = g_entries[i]; | 2624 const FeatureEntry& e = feature_entries[i]; |
2595 if (e.type == FeatureEntry::SINGLE_VALUE || | 2625 if (e.type == FeatureEntry::SINGLE_VALUE || |
2596 e.type == FeatureEntry::SINGLE_DISABLE_VALUE) { | 2626 e.type == FeatureEntry::SINGLE_DISABLE_VALUE) { |
2597 SetFlagToSwitchMapping(e.internal_name, e.command_line_switch, | 2627 SetFlagToSwitchMapping(e.internal_name, e.command_line_switch, |
2598 e.command_line_value, &name_to_switch_map); | 2628 e.command_line_value, &name_to_switch_map); |
2599 } else if (e.type == FeatureEntry::MULTI_VALUE) { | 2629 } else if (e.type == FeatureEntry::MULTI_VALUE) { |
2600 for (int j = 0; j < e.num_choices; ++j) { | 2630 for (int j = 0; j < e.num_choices; ++j) { |
2601 SetFlagToSwitchMapping(e.NameForChoice(j), | 2631 SetFlagToSwitchMapping(e.NameForChoice(j), |
2602 e.choices[j].command_line_switch, | 2632 e.choices[j].command_line_switch, |
2603 e.choices[j].command_line_value, | 2633 e.choices[j].command_line_value, |
2604 &name_to_switch_map); | 2634 &name_to_switch_map); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 needs_restart_ |= enabled_entries.insert(internal_name).second; | 2697 needs_restart_ |= enabled_entries.insert(internal_name).second; |
2668 flags_storage->SetFlags(enabled_entries); | 2698 flags_storage->SetFlags(enabled_entries); |
2669 } | 2699 } |
2670 return; | 2700 return; |
2671 } | 2701 } |
2672 | 2702 |
2673 std::set<std::string> enabled_entries; | 2703 std::set<std::string> enabled_entries; |
2674 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); | 2704 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); |
2675 | 2705 |
2676 const FeatureEntry* e = NULL; | 2706 const FeatureEntry* e = NULL; |
2677 for (size_t i = 0; i < g_num_entries; ++i) { | 2707 for (size_t i = 0; i < num_feature_entries; ++i) { |
2678 if (g_entries[i].internal_name == internal_name) { | 2708 if (feature_entries[i].internal_name == internal_name) { |
2679 e = g_entries + i; | 2709 e = feature_entries + i; |
2680 break; | 2710 break; |
2681 } | 2711 } |
2682 } | 2712 } |
2683 DCHECK(e); | 2713 DCHECK(e); |
2684 | 2714 |
2685 if (e->type == FeatureEntry::SINGLE_VALUE) { | 2715 if (e->type == FeatureEntry::SINGLE_VALUE) { |
2686 if (enable) | 2716 if (enable) |
2687 needs_restart_ |= enabled_entries.insert(internal_name).second; | 2717 needs_restart_ |= enabled_entries.insert(internal_name).second; |
2688 else | 2718 else |
2689 needs_restart_ |= (enabled_entries.erase(internal_name) > 0); | 2719 needs_restart_ |= (enabled_entries.erase(internal_name) > 0); |
(...skipping 30 matching lines...) Expand all Loading... |
2720 switch_list->erase(entry.first); | 2750 switch_list->erase(entry.first); |
2721 } | 2751 } |
2722 | 2752 |
2723 void FlagsState::ResetAllFlags(flags_ui::FlagsStorage* flags_storage) { | 2753 void FlagsState::ResetAllFlags(flags_ui::FlagsStorage* flags_storage) { |
2724 needs_restart_ = true; | 2754 needs_restart_ = true; |
2725 | 2755 |
2726 std::set<std::string> no_entries; | 2756 std::set<std::string> no_entries; |
2727 flags_storage->SetFlags(no_entries); | 2757 flags_storage->SetFlags(no_entries); |
2728 } | 2758 } |
2729 | 2759 |
2730 void FlagsState::reset() { | 2760 void FlagsState::Reset() { |
2731 needs_restart_ = false; | 2761 needs_restart_ = false; |
2732 flags_switches_.clear(); | 2762 flags_switches_.clear(); |
2733 } | 2763 } |
2734 | 2764 |
| 2765 void FlagsState::SetFeatureEntries(const FeatureEntry* entries, size_t count) { |
| 2766 feature_entries = entries; |
| 2767 num_feature_entries = count; |
| 2768 } |
| 2769 |
| 2770 const FeatureEntry* FlagsState::GetFeatureEntries(size_t* count) { |
| 2771 *count = num_feature_entries; |
| 2772 return feature_entries; |
| 2773 } |
| 2774 |
2735 } // namespace | 2775 } // namespace |
2736 | 2776 |
2737 namespace testing { | 2777 namespace testing { |
2738 | 2778 |
2739 // WARNING: '@' is also used in the html file. If you update this constant you | 2779 // WARNING: '@' is also used in the html file. If you update this constant you |
2740 // also need to update the html file. | 2780 // also need to update the html file. |
2741 const char kMultiSeparator[] = "@"; | 2781 const char kMultiSeparator[] = "@"; |
2742 | 2782 |
2743 const base::HistogramBase::Sample kBadSwitchFormatHistogramId = 0; | 2783 const base::HistogramBase::Sample kBadSwitchFormatHistogramId = 0; |
2744 | 2784 |
2745 void ClearState() { | 2785 void ClearState() { |
2746 FlagsState::GetInstance()->reset(); | 2786 FlagsState::GetInstance()->Reset(); |
2747 } | 2787 } |
2748 | 2788 |
2749 void SetFeatureEntries(const FeatureEntry* entries, size_t count) { | 2789 void SetFeatureEntries(const FeatureEntry* entries, size_t count) { |
2750 if (!entries) { | 2790 if (!entries) { |
2751 g_entries = kFeatureEntries; | 2791 entries = kFeatureEntries; |
2752 g_num_entries = arraysize(kFeatureEntries); | 2792 count = arraysize(kFeatureEntries); |
2753 } else { | |
2754 g_entries = entries; | |
2755 g_num_entries = count; | |
2756 } | 2793 } |
| 2794 FlagsState::GetInstance()->SetFeatureEntries(entries, count); |
2757 } | 2795 } |
2758 | 2796 |
2759 const FeatureEntry* GetFeatureEntries(size_t* count) { | 2797 const FeatureEntry* GetFeatureEntries(size_t* count) { |
2760 *count = g_num_entries; | 2798 return FlagsState::GetInstance()->GetFeatureEntries(count); |
2761 return g_entries; | |
2762 } | 2799 } |
2763 | 2800 |
2764 } // namespace testing | 2801 } // namespace testing |
2765 | 2802 |
2766 } // namespace about_flags | 2803 } // namespace about_flags |
OLD | NEW |