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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc

Issue 1083683003: Speculative revert by sheriff (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed an unrelated commit that had accidentally slipped in. Created 5 years, 8 months 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc
index 1b90a14d04568dacabe3396f4bc6885852c63de5..3c17aa24d85fe4824aaec0992992db4db354ba34 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc
@@ -11,6 +11,9 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service_observer.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
+#include "net/base/load_flags.h"
+#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_request_status.h"
namespace data_reduction_proxy {
@@ -106,4 +109,47 @@ DataReductionProxyService::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
+void DataReductionProxyService::OnURLFetchComplete(
+ const net::URLFetcher* source) {
+ DCHECK(source == fetcher_.get());
+ net::URLRequestStatus status = source->GetStatus();
+
+ std::string response;
+ source->GetResponseAsString(&response);
+
+ fetcher_callback_.Run(response, status);
+}
+
+net::URLFetcher* DataReductionProxyService::GetURLFetcherForSecureProxyCheck(
+ const GURL& secure_proxy_check_url) {
+ net::URLFetcher* fetcher = net::URLFetcher::Create(
+ secure_proxy_check_url, net::URLFetcher::GET, this);
+ fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | net::LOAD_BYPASS_PROXY);
+ DCHECK(url_request_context_getter_);
+ fetcher->SetRequestContext(url_request_context_getter_);
+ // Configure max retries to be at most kMaxRetries times for 5xx errors.
+ static const int kMaxRetries = 5;
+ fetcher->SetMaxRetriesOn5xx(kMaxRetries);
+ fetcher->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries);
+ // The secure proxy check should not be redirected. Since the secure proxy
+ // check will inevitably fail if it gets redirected somewhere else (e.g. by a
+ // captive portal), short circuit that by giving up on the secure proxy check
+ // if it gets redirected.
+ fetcher->SetStopOnRedirect(true);
+ return fetcher;
+}
+
+void DataReductionProxyService::SecureProxyCheck(
+ const GURL& secure_proxy_check_url,
+ FetcherResponseCallback fetcher_callback) {
+ DCHECK(CalledOnValidThread());
+ net::URLFetcher* fetcher =
+ GetURLFetcherForSecureProxyCheck(secure_proxy_check_url);
+ if (!fetcher)
+ return;
+ fetcher_.reset(fetcher);
+ fetcher_callback_ = fetcher_callback;
+ fetcher_->Start();
+}
+
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698