Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: components/variations/variations_http_header_provider.h

Issue 1530133005: Refactor VariationsHttpHeaderProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include to srt_fetcher_win.cc. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/variations/synthetic_trials.cc ('k') | components/variations/variations_http_header_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_http_header_provider.h
diff --git a/components/variations/net/variations_http_header_provider.h b/components/variations/variations_http_header_provider.h
similarity index 70%
rename from components/variations/net/variations_http_header_provider.h
rename to components/variations/variations_http_header_provider.h
index 21f8659ea98e1ff3830bdd5ccee8754822c63150..18ff19d305efeff2841dc23818c6b140bed2409a 100644
--- a/components/variations/net/variations_http_header_provider.h
+++ b/components/variations/variations_http_header_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_
-#define COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_
+#ifndef COMPONENTS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_
+#define COMPONENTS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_
#include <set>
#include <string>
@@ -13,21 +13,12 @@
#include "base/gtest_prod_util.h"
#include "base/metrics/field_trial.h"
#include "base/synchronization/lock.h"
-#include "components/metrics/metrics_service.h"
+#include "components/variations/synthetic_trials.h"
#include "components/variations/variations_associated_data.h"
-namespace content {
-class ResourceContext;
-}
-
-namespace net {
-class HttpRequestHeaders;
-}
-
-class GURL;
-
namespace base {
-template <typename T> struct DefaultSingletonTraits;
+template <typename T>
+struct DefaultSingletonTraits;
}
namespace variations {
@@ -36,18 +27,13 @@ namespace variations {
// transmitted in custom HTTP request headers.
// This class is a thread-safe singleton.
class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
- public metrics::SyntheticTrialObserver {
+ public SyntheticTrialObserver {
public:
static VariationsHttpHeaderProvider* GetInstance();
- // Adds Chrome experiment and metrics state as custom headers to |headers|.
- // Some headers may not be set given the |incognito| mode or whether
- // the user has |uma_enabled|. Also, we never transmit headers to non-Google
- // sites, which is checked based on the destination |url|.
- void AppendHeaders(const GURL& url,
- bool incognito,
- bool uma_enabled,
- net::HttpRequestHeaders* headers);
+ // Returns the value of the client data header, computing and caching it if
+ // necessary.
+ std::string GetClientDataHeader();
// Sets *additional* variation ids and trigger variation ids to be encoded in
// the X-Client-Data request header. This is intended for development use to
@@ -56,9 +42,6 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
// with "t" it will be treated as a trigger experiment id.
bool SetDefaultVariationIds(const std::string& variation_ids);
- // Returns the HTTP header names which are added in this class.
- std::set<std::string> GetVariationHeaderNames() const;
-
// Resets any cached state for tests.
void ResetForTesting();
@@ -66,8 +49,6 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
friend struct base::DefaultSingletonTraits<VariationsHttpHeaderProvider>;
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
- ShouldAppendHeaders);
- FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
SetDefaultVariationIds_Valid);
FRIEND_TEST_ALL_PREFIXES(VariationsHttpHeaderProviderTest,
SetDefaultVariationIds_Invalid);
@@ -85,7 +66,7 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
// metrics::SyntheticTrialObserver:
void OnSyntheticTrialsChanged(
- const std::vector<metrics::SyntheticTrialGroup>& groups) override;
+ const std::vector<SyntheticTrialGroup>& groups) override;
// Prepares the variation IDs cache with initial values if not already done.
// This method also registers the caller with the FieldTrialList to receive
@@ -97,10 +78,6 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
// held.
void UpdateVariationIDsHeaderValue();
- // Checks whether variation headers should be appended to requests to the
- // specified |url|. Returns true for google.<TLD> and youtube.<TLD> URLs.
- static bool ShouldAppendHeaders(const GURL& url);
-
// Guards |variation_ids_cache_initialized_|, |variation_ids_set_| and
// |variation_ids_header_|.
base::Lock lock_;
@@ -127,4 +104,4 @@ class VariationsHttpHeaderProvider : public base::FieldTrialList::Observer,
} // namespace variations
-#endif // COMPONENTS_VARIATIONS_NET_VARIATIONS_HTTP_HEADER_PROVIDER_H_
+#endif // COMPONENTS_VARIATIONS_VARIATIONS_HTTP_HEADER_PROVIDER_H_
« no previous file with comments | « components/variations/synthetic_trials.cc ('k') | components/variations/variations_http_header_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698