Index: components/variations/variations_http_header_provider.h |
diff --git a/components/variations/variations_http_header_provider.h b/components/variations/variations_http_header_provider.h |
index 349fea9951cda61c69562b3cca81db02e030925d..184766d63520a875bcbacd128cdddab2d6db46c2 100644 |
--- a/components/variations/variations_http_header_provider.h |
+++ b/components/variations/variations_http_header_provider.h |
@@ -7,6 +7,7 @@ |
#include <set> |
#include <string> |
+#include <utility> |
#include <vector> |
#include "base/gtest_prod_util.h" |
@@ -32,12 +33,15 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer, |
static VariationsHttpHeaderProvider* GetInstance(); |
// Returns the value of the client data header, computing and caching it if |
- // necessary. |
- std::string GetClientDataHeader(); |
+ // necessary. If |is_signed_in| is false, variation ids that should only be |
+ // sent for signed in users (i.e. GOOGLE_WEB_PROPERTIES_SIGNED_IN entries) |
+ // will not be included. |
+ std::string GetClientDataHeader(bool is_signed_in); |
// Returns a space-separated string containing the list of current active |
// variations (as would be reported in the |variation_id| repeated field of |
- // the ClientVariations proto). The returned string is guaranteed to have a |
+ // the ClientVariations proto). Does not include variation ids that should be |
+ // sent for signed-in users only. The returned string is guaranteed to have a |
// a leading and trailing space, e.g. " 123 234 345 ". |
std::string GetVariationsString(); |
@@ -61,6 +65,8 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer, |
private: |
friend struct base::DefaultSingletonTraits<VariationsHttpHeaderProvider>; |
+ typedef std::pair<VariationID, IDCollectionKey> VariationIDEntry; |
+ |
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
SetDefaultVariationIds_Valid); |
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest, |
@@ -88,35 +94,43 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer, |
// new variation IDs. |
void InitVariationIDsCacheIfNeeded(); |
+ // Looks up the associated id for the given trial/group and adds an entry for |
+ // it to |variation_ids_set_| if found. |
+ void CacheVariationsId(const std::string& trial_name, |
+ const std::string& group_name, |
+ IDCollectionKey key); |
+ |
// Takes whatever is currently in |variation_ids_set_| and recreates |
// |variation_ids_header_| with it. Assumes the the |lock_| is currently |
// held. |
void UpdateVariationIDsHeaderValue(); |
+ // Generates a base64-encoded proto to be used as a header value for the given |
+ // |is_signed_in| state. |
+ std::string GenerateBase64EncodedProto(bool is_signed_in); |
+ |
// Returns the currently active set of variation ids, which includes any |
// default values, synthetic variations and actual field trial variations. |
- std::set<VariationID> GetAllVariationIds(); |
+ std::set<VariationIDEntry> GetAllVariationIds(); |
- // Guards |variation_ids_cache_initialized_|, |variation_ids_set_| and |
- // |variation_ids_header_|. |
+ // Guards access to variables below. |
base::Lock lock_; |
- // Whether or not we've initialized the cache. |
+ // Whether or not we've initialized the caches. |
bool variation_ids_cache_initialized_; |
// Keep a cache of variation IDs that are transmitted in headers to Google. |
// This consists of a list of valid IDs, and the actual transmitted header. |
- std::set<VariationID> variation_ids_set_; |
- std::set<VariationID> variation_trigger_ids_set_; |
+ std::set<VariationIDEntry> variation_ids_set_; |
// Provides the google experiment ids forced from command line. |
- std::set<VariationID> default_variation_ids_set_; |
- std::set<VariationID> default_trigger_id_set_; |
+ std::set<VariationIDEntry> default_variation_ids_set_; |
// Variations ids from synthetic field trials. |
- std::set<VariationID> synthetic_variation_ids_set_; |
+ std::set<VariationIDEntry> synthetic_variation_ids_set_; |
- std::string variation_ids_header_; |
+ std::string cached_variation_ids_header_; |
+ std::string cached_variation_ids_header_signed_in_; |
DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeaderProvider); |
}; |