Commit f79fb2cf authored by David Benjamin's avatar David Benjamin Committed by Commit Bot

Remove some more remnants of pre-net-svc code.

As of https://chromium-review.googlesource.com/c/chromium/src/+/1657387,
the VariationsHeaderHelper no longer needs code to support URLRequest.

Bug: 773295
Change-Id: Ide7d426f5b27701f1ac3063d2ee674a4879016ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1853105
Auto-Submit: David Benjamin <davidben@chromium.org>
Commit-Queue: Jesse Doherty <jwd@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706675}
parent 304c356f
......@@ -16,10 +16,8 @@
#include "base/strings/string_util.h"
#include "components/google/core/common/google_util.h"
#include "components/variations/variations_http_header_provider.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_response.h"
#include "services/network/public/cpp/simple_url_loader.h"
......@@ -75,26 +73,19 @@ bool ShouldAppendVariationsHeader(const GURL& url) {
return true;
}
constexpr network::ResourceRequest* null_resource_request = nullptr;
constexpr net::URLRequest* null_url_request = nullptr;
class VariationsHeaderHelper {
public:
// Note: It's OK to pass SignedIn::kNo if it's unknown, as it does not affect
// transmission of experiments coming from the variations server.
VariationsHeaderHelper(network::ResourceRequest* request,
SignedIn signed_in = SignedIn::kNo)
: VariationsHeaderHelper(request,
null_url_request,
CreateVariationsHeader(signed_in)) {}
VariationsHeaderHelper(net::URLRequest* request,
SignedIn signed_in = SignedIn::kNo)
: VariationsHeaderHelper(null_resource_request,
request,
CreateVariationsHeader(signed_in)) {}
VariationsHeaderHelper(network::ResourceRequest* request,
const std::string& variations_header)
: VariationsHeaderHelper(request, null_url_request, variations_header) {}
: VariationsHeaderHelper(request, CreateVariationsHeader(signed_in)) {}
VariationsHeaderHelper(network::ResourceRequest* resource_request,
std::string variations_header)
: resource_request_(resource_request) {
DCHECK(resource_request_);
variations_header_ = std::move(variations_header);
}
bool AppendHeaderIfNeeded(const GURL& url, InIncognito incognito) {
// Note the criteria for attaching client experiment headers:
......@@ -112,18 +103,10 @@ class VariationsHeaderHelper {
if (variations_header_.empty())
return false;
if (resource_request_) {
// Set the variations header to cors_exempt_headers rather than headers
// to be exempted from CORS checks.
resource_request_->cors_exempt_headers.SetHeaderIfMissing(
kClientDataHeader, variations_header_);
} else if (url_request_) {
url_request_->SetExtraRequestHeaderByName(kClientDataHeader,
variations_header_, false);
} else {
NOTREACHED();
return false;
}
// Set the variations header to cors_exempt_headers rather than headers
// to be exempted from CORS checks.
resource_request_->cors_exempt_headers.SetHeaderIfMissing(
kClientDataHeader, variations_header_);
return true;
}
......@@ -133,16 +116,7 @@ class VariationsHeaderHelper {
signed_in == SignedIn::kYes);
}
VariationsHeaderHelper(network::ResourceRequest* resource_request,
net::URLRequest* url_request,
std::string variations_header)
: resource_request_(resource_request), url_request_(url_request) {
DCHECK(resource_request_ || url_request_);
variations_header_ = std::move(variations_header);
}
network::ResourceRequest* resource_request_;
net::URLRequest* url_request_;
std::string variations_header_;
DISALLOW_COPY_AND_ASSIGN(VariationsHeaderHelper);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment