| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/variations/variations_http_header_provider.h" | 5 #include "components/variations/variations_http_header_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 base::AutoLock scoped_lock(lock_); | 50 base::AutoLock scoped_lock(lock_); |
| 51 for (VariationID id : GetAllVariationIds()) { | 51 for (VariationID id : GetAllVariationIds()) { |
| 52 ids_string.append(base::IntToString(id)); | 52 ids_string.append(base::IntToString(id)); |
| 53 ids_string.push_back(' '); | 53 ids_string.push_back(' '); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 return ids_string; | 56 return ids_string; |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool VariationsHttpHeaderProvider::SetDefaultVariationIds( | 59 bool VariationsHttpHeaderProvider::SetDefaultVariationIds( |
| 60 const std::string& variation_ids) { | 60 const std::vector<std::string>& variation_ids) { |
| 61 default_variation_ids_set_.clear(); | 61 default_variation_ids_set_.clear(); |
| 62 default_trigger_id_set_.clear(); | 62 default_trigger_id_set_.clear(); |
| 63 for (const base::StringPiece& entry : base::SplitStringPiece( | 63 for (const std::string& entry : variation_ids) { |
| 64 variation_ids, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
| 65 if (entry.empty()) { | 64 if (entry.empty()) { |
| 66 default_variation_ids_set_.clear(); | 65 default_variation_ids_set_.clear(); |
| 67 default_trigger_id_set_.clear(); | 66 default_trigger_id_set_.clear(); |
| 68 return false; | 67 return false; |
| 69 } | 68 } |
| 70 bool trigger_id = | 69 bool trigger_id = |
| 71 base::StartsWith(entry, "t", base::CompareCase::SENSITIVE); | 70 base::StartsWith(entry, "t", base::CompareCase::SENSITIVE); |
| 72 // Remove the "t" prefix if it's there. | 71 // Remove the "t" prefix if it's there. |
| 73 base::StringPiece trimmed_entry = trigger_id ? entry.substr(1) : entry; | 72 base::StringPiece trimmed_entry = trigger_id ? entry.substr(1) : entry; |
| 74 | 73 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 223 |
| 225 std::set<VariationID> all_variation_ids_set = default_variation_ids_set_; | 224 std::set<VariationID> all_variation_ids_set = default_variation_ids_set_; |
| 226 for (VariationID id : variation_ids_set_) | 225 for (VariationID id : variation_ids_set_) |
| 227 all_variation_ids_set.insert(id); | 226 all_variation_ids_set.insert(id); |
| 228 for (VariationID id : synthetic_variation_ids_set_) | 227 for (VariationID id : synthetic_variation_ids_set_) |
| 229 all_variation_ids_set.insert(id); | 228 all_variation_ids_set.insert(id); |
| 230 return all_variation_ids_set; | 229 return all_variation_ids_set; |
| 231 } | 230 } |
| 232 | 231 |
| 233 } // namespace variations | 232 } // namespace variations |
| OLD | NEW |