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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2137 | 2137 |
2138 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 2138 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
2139 CommandLine* command_line, | 2139 CommandLine* command_line, |
2140 SentinelsMode sentinels) { | 2140 SentinelsMode sentinels) { |
2141 FlagsState::GetInstance()->ConvertFlagsToSwitches(flags_storage, | 2141 FlagsState::GetInstance()->ConvertFlagsToSwitches(flags_storage, |
2142 command_line, | 2142 command_line, |
2143 sentinels); | 2143 sentinels); |
2144 } | 2144 } |
2145 | 2145 |
2146 bool AreSwitchesIdenticalToCurrentCommandLine( | 2146 bool AreSwitchesIdenticalToCurrentCommandLine( |
2147 const CommandLine& new_cmdline, const CommandLine& active_cmdline) { | 2147 const CommandLine& new_cmdline, |
2148 const CommandLine& active_cmdline, | |
2149 std::set<CommandLine::StringType>* out_difference) { | |
2148 std::set<CommandLine::StringType> new_flags = | 2150 std::set<CommandLine::StringType> new_flags = |
2149 ExtractFlagsFromCommandLine(new_cmdline); | 2151 ExtractFlagsFromCommandLine(new_cmdline); |
2150 std::set<CommandLine::StringType> active_flags = | 2152 std::set<CommandLine::StringType> active_flags = |
2151 ExtractFlagsFromCommandLine(active_cmdline); | 2153 ExtractFlagsFromCommandLine(active_cmdline); |
2152 | 2154 |
2155 bool result = true; | |
2153 // Needed because std::equal doesn't check if the 2nd set is empty. | 2156 // Needed because std::equal doesn't check if the 2nd set is empty. |
2154 if (new_flags.size() != active_flags.size()) | 2157 if (new_flags.size() != active_flags.size()) { |
2155 return false; | 2158 result = false; |
2159 } else { | |
2160 std::equal(new_flags.begin(), new_flags.end(), active_flags.begin()); | |
Nikita (slow)
2014/06/19 17:08:07
result =
Alexander Alekseev
2014/06/19 18:17:47
Done.
| |
2161 } | |
2156 | 2162 |
2157 return std::equal(new_flags.begin(), new_flags.end(), active_flags.begin()); | 2163 if (out_difference && !result) { |
2164 std::set_symmetric_difference( | |
2165 new_flags.begin(), | |
2166 new_flags.end(), | |
2167 active_flags.begin(), | |
2168 active_flags.end(), | |
2169 std::inserter(*out_difference, out_difference->begin())); | |
2170 } | |
2171 | |
2172 return result; | |
2158 } | 2173 } |
2159 | 2174 |
2160 void GetFlagsExperimentsData(FlagsStorage* flags_storage, | 2175 void GetFlagsExperimentsData(FlagsStorage* flags_storage, |
2161 FlagAccess access, | 2176 FlagAccess access, |
2162 base::ListValue* supported_experiments, | 2177 base::ListValue* supported_experiments, |
2163 base::ListValue* unsupported_experiments) { | 2178 base::ListValue* unsupported_experiments) { |
2164 std::set<std::string> enabled_experiments; | 2179 std::set<std::string> enabled_experiments; |
2165 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); | 2180 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); |
2166 | 2181 |
2167 int current_platform = GetCurrentPlatform(); | 2182 int current_platform = GetCurrentPlatform(); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2454 } | 2469 } |
2455 | 2470 |
2456 const Experiment* GetExperiments(size_t* count) { | 2471 const Experiment* GetExperiments(size_t* count) { |
2457 *count = num_experiments; | 2472 *count = num_experiments; |
2458 return experiments; | 2473 return experiments; |
2459 } | 2474 } |
2460 | 2475 |
2461 } // namespace testing | 2476 } // namespace testing |
2462 | 2477 |
2463 } // namespace about_flags | 2478 } // namespace about_flags |
OLD | NEW |