Commit a71d8004 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Revert "Store callback in DhcpPacFileFetcherChromeos."

This reverts commit 130902aa,
reviewed at https://crrev.com/c/1073192, and also adds
a comment that the expectation of DhcpPacFileFetcher::Fetch is violated.

Bug: 882996
Change-Id: I127d582dd0fa4a68942c2a005bd543ad8efbd161
Reviewed-on: https://chromium-review.googlesource.com/1230442
Commit-Queue: Bence Béky <bnc@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592057}
parent 5118e7d3
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chromeos/network/dhcp_pac_file_fetcher_chromeos.h" #include "chromeos/network/dhcp_pac_file_fetcher_chromeos.h"
#include "base/callback_helpers.h"
#include "base/location.h" #include "base/location.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "chromeos/network/network_event_log.h" #include "chromeos/network/network_event_log.h"
...@@ -50,15 +51,12 @@ int DhcpPacFileFetcherChromeos::Fetch( ...@@ -50,15 +51,12 @@ int DhcpPacFileFetcherChromeos::Fetch(
if (!network_handler_task_runner_.get()) if (!network_handler_task_runner_.get())
return net::ERR_PAC_NOT_IN_DHCP; return net::ERR_PAC_NOT_IN_DHCP;
CHECK(callback); CHECK(callback);
// DhcpPacFileFetcher only allows one Fetch in progress at a time.
CHECK(!callback_);
callback_ = std::move(callback);
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
network_handler_task_runner_.get(), FROM_HERE, network_handler_task_runner_.get(), FROM_HERE,
base::BindOnce(&GetPacUrlFromDefaultNetwork), base::BindOnce(&GetPacUrlFromDefaultNetwork),
base::BindOnce(&DhcpPacFileFetcherChromeos::ContinueFetch, base::BindOnce(&DhcpPacFileFetcherChromeos::ContinueFetch,
weak_ptr_factory_.GetWeakPtr(), utf16_text, weak_ptr_factory_.GetWeakPtr(), utf16_text,
traffic_annotation)); std::move(callback), traffic_annotation));
return net::ERR_IO_PENDING; return net::ERR_IO_PENDING;
} }
...@@ -82,26 +80,22 @@ std::string DhcpPacFileFetcherChromeos::GetFetcherName() const { ...@@ -82,26 +80,22 @@ std::string DhcpPacFileFetcherChromeos::GetFetcherName() const {
void DhcpPacFileFetcherChromeos::ContinueFetch( void DhcpPacFileFetcherChromeos::ContinueFetch(
base::string16* utf16_text, base::string16* utf16_text,
net::CompletionOnceCallback callback,
const net::NetworkTrafficAnnotationTag traffic_annotation, const net::NetworkTrafficAnnotationTag traffic_annotation,
std::string pac_url) { std::string pac_url) {
NET_LOG_EVENT("DhcpPacFileFetcher", pac_url); NET_LOG_EVENT("DhcpPacFileFetcher", pac_url);
pac_url_ = GURL(pac_url); pac_url_ = GURL(pac_url);
if (pac_url_.is_empty()) { if (pac_url_.is_empty()) {
std::move(callback_).Run(net::ERR_PAC_NOT_IN_DHCP); std::move(callback).Run(net::ERR_PAC_NOT_IN_DHCP);
return; return;
} }
int result = pac_file_fetcher_->Fetch( auto repeating_callback =
pac_url_, utf16_text, base::AdaptCallbackForRepeating(std::move(callback));
base::BindOnce(&DhcpPacFileFetcherChromeos::OnFetchCompleted, int res = pac_file_fetcher_->Fetch(pac_url_, utf16_text, repeating_callback,
weak_ptr_factory_.GetWeakPtr()), traffic_annotation);
traffic_annotation); if (res != net::ERR_IO_PENDING)
if (result != net::ERR_IO_PENDING) repeating_callback.Run(res);
std::move(callback_).Run(result);
}
void DhcpPacFileFetcherChromeos::OnFetchCompleted(int result) {
std::move(callback_).Run(result);
} }
} // namespace chromeos } // namespace chromeos
...@@ -38,7 +38,11 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos ...@@ -38,7 +38,11 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos
net::URLRequestContext* url_request_context); net::URLRequestContext* url_request_context);
~DhcpPacFileFetcherChromeos() override; ~DhcpPacFileFetcherChromeos() override;
// net::DhcpPacFileFetcher // net::DhcpPacFileFetcher implementation
// TODO(https://crbug.com/882996) Even though it is documented at
// DhcpPacFileFetcher::Fetch() that only one fetch is allowed to be
// outstanding at any given time, crashes show that this is not obeyed.
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
net::CompletionOnceCallback callback, net::CompletionOnceCallback callback,
const net::NetLogWithSource& net_log, const net::NetLogWithSource& net_log,
...@@ -50,12 +54,10 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos ...@@ -50,12 +54,10 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos
private: private:
void ContinueFetch(base::string16* utf16_text, void ContinueFetch(base::string16* utf16_text,
net::CompletionOnceCallback callback,
const net::NetworkTrafficAnnotationTag traffic_annotation, const net::NetworkTrafficAnnotationTag traffic_annotation,
std::string pac_url); std::string pac_url);
void OnFetchCompleted(int result);
net::CompletionOnceCallback callback_;
std::unique_ptr<net::PacFileFetcher> pac_file_fetcher_; std::unique_ptr<net::PacFileFetcher> pac_file_fetcher_;
scoped_refptr<base::SingleThreadTaskRunner> network_handler_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> network_handler_task_runner_;
......
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