Commit bb8c4d8a authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Pass network traffic annotation to PAC fetcher.

Network traffic annotation is passed from pac_file_fetcher to
pac_file_fetcher_impl, and the local annotation is removed.

Bug: 656607
Change-Id: I7446281e7b8f6c15bc21d49cc31c1ebcaa9ecba9
Reviewed-on: https://chromium-review.googlesource.com/964283Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543646}
parent 7c4a8576
...@@ -45,7 +45,8 @@ DhcpPacFileFetcherChromeos::~DhcpPacFileFetcherChromeos() = default; ...@@ -45,7 +45,8 @@ DhcpPacFileFetcherChromeos::~DhcpPacFileFetcherChromeos() = default;
int DhcpPacFileFetcherChromeos::Fetch( int DhcpPacFileFetcherChromeos::Fetch(
base::string16* utf16_text, base::string16* utf16_text,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
const net::NetLogWithSource& net_log) { const net::NetLogWithSource& net_log,
const net::NetworkTrafficAnnotationTag traffic_annotation) {
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.is_null()); CHECK(!callback.is_null());
...@@ -53,7 +54,8 @@ int DhcpPacFileFetcherChromeos::Fetch( ...@@ -53,7 +54,8 @@ int DhcpPacFileFetcherChromeos::Fetch(
network_handler_task_runner_.get(), FROM_HERE, network_handler_task_runner_.get(), FROM_HERE,
base::Bind(&GetPacUrlFromDefaultNetwork), base::Bind(&GetPacUrlFromDefaultNetwork),
base::Bind(&DhcpPacFileFetcherChromeos::ContinueFetch, base::Bind(&DhcpPacFileFetcherChromeos::ContinueFetch,
weak_ptr_factory_.GetWeakPtr(), utf16_text, callback)); weak_ptr_factory_.GetWeakPtr(), utf16_text, callback,
traffic_annotation));
return net::ERR_IO_PENDING; return net::ERR_IO_PENDING;
} }
...@@ -75,16 +77,19 @@ std::string DhcpPacFileFetcherChromeos::GetFetcherName() const { ...@@ -75,16 +77,19 @@ std::string DhcpPacFileFetcherChromeos::GetFetcherName() const {
return "chromeos"; return "chromeos";
} }
void DhcpPacFileFetcherChromeos::ContinueFetch(base::string16* utf16_text, void DhcpPacFileFetcherChromeos::ContinueFetch(
net::CompletionCallback callback, base::string16* utf16_text,
std::string pac_url) { net::CompletionCallback callback,
const net::NetworkTrafficAnnotationTag traffic_annotation,
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()) {
callback.Run(net::ERR_PAC_NOT_IN_DHCP); callback.Run(net::ERR_PAC_NOT_IN_DHCP);
return; return;
} }
int res = pac_file_fetcher_->Fetch(pac_url_, utf16_text, callback); int res = pac_file_fetcher_->Fetch(pac_url_, utf16_text, callback,
traffic_annotation);
if (res != net::ERR_IO_PENDING) if (res != net::ERR_IO_PENDING)
callback.Run(res); callback.Run(res);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chromeos/chromeos_export.h" #include "chromeos/chromeos_export.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace base { namespace base {
...@@ -39,7 +40,8 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos ...@@ -39,7 +40,8 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos
// net::DhcpPacFileFetcher // net::DhcpPacFileFetcher
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const net::CompletionCallback& callback, const net::CompletionCallback& callback,
const net::NetLogWithSource& net_log) override; const net::NetLogWithSource& net_log,
const net::NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
void OnShutdown() override; void OnShutdown() override;
const GURL& GetPacURL() const override; const GURL& GetPacURL() const override;
...@@ -48,6 +50,7 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos ...@@ -48,6 +50,7 @@ class CHROMEOS_EXPORT DhcpPacFileFetcherChromeos
private: private:
void ContinueFetch(base::string16* utf16_text, void ContinueFetch(base::string16* utf16_text,
net::CompletionCallback callback, net::CompletionCallback callback,
const net::NetworkTrafficAnnotationTag traffic_annotation,
std::string pac_url); std::string pac_url);
std::unique_ptr<net::PacFileFetcher> pac_file_fetcher_; std::unique_ptr<net::PacFileFetcher> pac_file_fetcher_;
......
...@@ -47,8 +47,10 @@ DhcpPacFileAdapterFetcher::~DhcpPacFileAdapterFetcher() { ...@@ -47,8 +47,10 @@ DhcpPacFileAdapterFetcher::~DhcpPacFileAdapterFetcher() {
Cancel(); Cancel();
} }
void DhcpPacFileAdapterFetcher::Fetch(const std::string& adapter_name, void DhcpPacFileAdapterFetcher::Fetch(
const CompletionCallback& callback) { const std::string& adapter_name,
const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK_EQ(state_, STATE_START); DCHECK_EQ(state_, STATE_START);
result_ = ERR_IO_PENDING; result_ = ERR_IO_PENDING;
...@@ -64,7 +66,7 @@ void DhcpPacFileAdapterFetcher::Fetch(const std::string& adapter_name, ...@@ -64,7 +66,7 @@ void DhcpPacFileAdapterFetcher::Fetch(const std::string& adapter_name,
base::Bind(&DhcpPacFileAdapterFetcher::DhcpQuery::GetPacURLForAdapter, base::Bind(&DhcpPacFileAdapterFetcher::DhcpQuery::GetPacURLForAdapter,
dhcp_query.get(), adapter_name), dhcp_query.get(), adapter_name),
base::Bind(&DhcpPacFileAdapterFetcher::OnDhcpQueryDone, AsWeakPtr(), base::Bind(&DhcpPacFileAdapterFetcher::OnDhcpQueryDone, AsWeakPtr(),
dhcp_query)); dhcp_query, traffic_annotation));
} }
void DhcpPacFileAdapterFetcher::Cancel() { void DhcpPacFileAdapterFetcher::Cancel() {
...@@ -131,7 +133,8 @@ std::string DhcpPacFileAdapterFetcher::DhcpQuery::ImplGetPacURLFromDhcp( ...@@ -131,7 +133,8 @@ std::string DhcpPacFileAdapterFetcher::DhcpQuery::ImplGetPacURLFromDhcp(
DhcpPacFileAdapterFetcher::DhcpQuery::~DhcpQuery() {} DhcpPacFileAdapterFetcher::DhcpQuery::~DhcpQuery() {}
void DhcpPacFileAdapterFetcher::OnDhcpQueryDone( void DhcpPacFileAdapterFetcher::OnDhcpQueryDone(
scoped_refptr<DhcpQuery> dhcp_query) { scoped_refptr<DhcpQuery> dhcp_query,
const NetworkTrafficAnnotationTag traffic_annotation) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// Because we can't cancel the call to the Win32 API, we can expect // Because we can't cancel the call to the Win32 API, we can expect
// it to finish while we are in a few different states. The expected // it to finish while we are in a few different states. The expected
...@@ -153,7 +156,8 @@ void DhcpPacFileAdapterFetcher::OnDhcpQueryDone( ...@@ -153,7 +156,8 @@ void DhcpPacFileAdapterFetcher::OnDhcpQueryDone(
script_fetcher_.reset(ImplCreateScriptFetcher()); script_fetcher_.reset(ImplCreateScriptFetcher());
script_fetcher_->Fetch(pac_url_, &pac_script_, script_fetcher_->Fetch(pac_url_, &pac_script_,
base::Bind(&DhcpPacFileAdapterFetcher::OnFetcherDone, base::Bind(&DhcpPacFileAdapterFetcher::OnFetcherDone,
base::Unretained(this))); base::Unretained(this)),
traffic_annotation);
} }
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace base { namespace base {
...@@ -49,7 +50,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileAdapterFetcher ...@@ -49,7 +50,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileAdapterFetcher
// You may only call Fetch() once on a given instance of // You may only call Fetch() once on a given instance of
// DhcpPacFileAdapterFetcher. // DhcpPacFileAdapterFetcher.
virtual void Fetch(const std::string& adapter_name, virtual void Fetch(const std::string& adapter_name,
const CompletionCallback& callback); const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation);
// Cancels the fetch on this adapter. // Cancels the fetch on this adapter.
virtual void Cancel(); virtual void Cancel();
...@@ -152,7 +154,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileAdapterFetcher ...@@ -152,7 +154,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileAdapterFetcher
private: private:
// Event/state transition handlers // Event/state transition handlers
void OnDhcpQueryDone(scoped_refptr<DhcpQuery> dhcp_query); void OnDhcpQueryDone(scoped_refptr<DhcpQuery> dhcp_query,
const NetworkTrafficAnnotationTag traffic_annotation);
void OnTimeout(); void OnTimeout();
void OnFetcherDone(int result); void OnFetcherDone(int result);
void TransitionToFinish(); void TransitionToFinish();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "net/proxy_resolution/pac_file_fetcher_impl.h" #include "net/proxy_resolution/pac_file_fetcher_impl.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/gtest_util.h" #include "net/test/gtest_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -156,7 +157,8 @@ class FetcherClient { ...@@ -156,7 +157,8 @@ class FetcherClient {
} }
void RunTest() { void RunTest() {
fetcher_->Fetch("adapter name", callback_.callback()); fetcher_->Fetch("adapter name", callback_.callback(),
TRAFFIC_ANNOTATION_FOR_TESTS);
} }
void FinishTestAllowCleanup() { void FinishTestAllowCleanup() {
......
...@@ -20,9 +20,11 @@ DoNothingDhcpPacFileFetcher::DoNothingDhcpPacFileFetcher() = default; ...@@ -20,9 +20,11 @@ DoNothingDhcpPacFileFetcher::DoNothingDhcpPacFileFetcher() = default;
DoNothingDhcpPacFileFetcher::~DoNothingDhcpPacFileFetcher() = default; DoNothingDhcpPacFileFetcher::~DoNothingDhcpPacFileFetcher() = default;
int DoNothingDhcpPacFileFetcher::Fetch(base::string16* utf16_text, int DoNothingDhcpPacFileFetcher::Fetch(
const CompletionCallback& callback, base::string16* utf16_text,
const NetLogWithSource& net_log) { const CompletionCallback& callback,
const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) {
return ERR_NOT_IMPLEMENTED; return ERR_NOT_IMPLEMENTED;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/proxy_resolution/pac_file_fetcher.h" #include "net/proxy_resolution/pac_file_fetcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace net { namespace net {
...@@ -60,7 +61,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcher { ...@@ -60,7 +61,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcher {
// Only one fetch is allowed to be outstanding at a time. // Only one fetch is allowed to be outstanding at a time.
virtual int Fetch(base::string16* utf16_text, virtual int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) = 0; const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) = 0;
// Aborts the in-progress fetch (if any). // Aborts the in-progress fetch (if any).
virtual void Cancel() = 0; virtual void Cancel() = 0;
...@@ -95,7 +97,8 @@ class NET_EXPORT_PRIVATE DoNothingDhcpPacFileFetcher ...@@ -95,7 +97,8 @@ class NET_EXPORT_PRIVATE DoNothingDhcpPacFileFetcher
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) override; const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
void OnShutdown() override; void OnShutdown() override;
const GURL& GetPacURL() const override; const GURL& GetPacURL() const override;
......
...@@ -287,9 +287,11 @@ DhcpPacFileFetcherWin::~DhcpPacFileFetcherWin() { ...@@ -287,9 +287,11 @@ DhcpPacFileFetcherWin::~DhcpPacFileFetcherWin() {
Cancel(); Cancel();
} }
int DhcpPacFileFetcherWin::Fetch(base::string16* utf16_text, int DhcpPacFileFetcherWin::Fetch(
const CompletionCallback& callback, base::string16* utf16_text,
const NetLogWithSource& net_log) { const CompletionCallback& callback,
const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (state_ != STATE_START && state_ != STATE_DONE) { if (state_ != STATE_START && state_ != STATE_DONE) {
NOTREACHED(); NOTREACHED();
...@@ -319,7 +321,7 @@ int DhcpPacFileFetcherWin::Fetch(base::string16* utf16_text, ...@@ -319,7 +321,7 @@ int DhcpPacFileFetcherWin::Fetch(base::string16* utf16_text,
base::Bind(&DhcpPacFileFetcherWin::AdapterQuery::GetCandidateAdapterNames, base::Bind(&DhcpPacFileFetcherWin::AdapterQuery::GetCandidateAdapterNames,
last_query_.get()), last_query_.get()),
base::Bind(&DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone, base::Bind(&DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone,
AsWeakPtr(), last_query_)); AsWeakPtr(), last_query_, traffic_annotation));
return ERR_IO_PENDING; return ERR_IO_PENDING;
} }
...@@ -366,7 +368,8 @@ void DhcpPacFileFetcherWin::CancelImpl() { ...@@ -366,7 +368,8 @@ void DhcpPacFileFetcherWin::CancelImpl() {
} }
void DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone( void DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone(
scoped_refptr<AdapterQuery> query) { scoped_refptr<AdapterQuery> query,
const NetworkTrafficAnnotationTag traffic_annotation) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// This can happen if this object is reused for multiple queries, // This can happen if this object is reused for multiple queries,
...@@ -405,7 +408,8 @@ void DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone( ...@@ -405,7 +408,8 @@ void DhcpPacFileFetcherWin::OnGetCandidateAdapterNamesDone(
size_t fetcher_index = fetchers_.size(); size_t fetcher_index = fetchers_.size();
fetcher->Fetch(adapter_name, fetcher->Fetch(adapter_name,
base::Bind(&DhcpPacFileFetcherWin::OnFetcherDone, base::Bind(&DhcpPacFileFetcherWin::OnFetcherDone,
base::Unretained(this), fetcher_index)); base::Unretained(this), fetcher_index),
traffic_annotation);
fetchers_.push_back(std::move(fetcher)); fetchers_.push_back(std::move(fetcher));
} }
num_pending_fetchers_ = fetchers_.size(); num_pending_fetchers_ = fetchers_.size();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/log/net_log_with_source.h" #include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
namespace base { namespace base {
class TaskRunner; class TaskRunner;
...@@ -43,7 +44,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcherWin ...@@ -43,7 +44,8 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcherWin
// DhcpPacFileFetcher implementation. // DhcpPacFileFetcher implementation.
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) override; const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
void OnShutdown() override; void OnShutdown() override;
const GURL& GetPacURL() const override; const GURL& GetPacURL() const override;
...@@ -108,7 +110,9 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcherWin ...@@ -108,7 +110,9 @@ class NET_EXPORT_PRIVATE DhcpPacFileFetcherWin
private: private:
// Event/state transition handlers // Event/state transition handlers
void CancelImpl(); void CancelImpl();
void OnGetCandidateAdapterNamesDone(scoped_refptr<AdapterQuery> query); void OnGetCandidateAdapterNamesDone(
scoped_refptr<AdapterQuery> query,
const NetworkTrafficAnnotationTag traffic_annotation);
void OnFetcherDone(size_t fetcher_i, int result); void OnFetcherDone(size_t fetcher_i, int result);
void OnWaitTimer(); void OnWaitTimer();
void TransitionToDone(); void TransitionToDone();
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.h" #include "net/proxy_resolution/dhcp_pac_file_adapter_fetcher_win.h"
#include "net/test/gtest_util.h" #include "net/test/gtest_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -59,7 +60,7 @@ class RealFetchTester { ...@@ -59,7 +60,7 @@ class RealFetchTester {
int result = fetcher_->Fetch( int result = fetcher_->Fetch(
&pac_text_, &pac_text_,
base::Bind(&RealFetchTester::OnCompletion, base::Unretained(this)), base::Bind(&RealFetchTester::OnCompletion, base::Unretained(this)),
NetLogWithSource()); NetLogWithSource(), TRAFFIC_ANNOTATION_FOR_TESTS);
if (result != ERR_IO_PENDING) if (result != ERR_IO_PENDING)
finished_ = true; finished_ = true;
} }
...@@ -213,7 +214,8 @@ class DummyDhcpPacFileAdapterFetcher : public DhcpPacFileAdapterFetcher { ...@@ -213,7 +214,8 @@ class DummyDhcpPacFileAdapterFetcher : public DhcpPacFileAdapterFetcher {
fetch_delay_ms_(1) {} fetch_delay_ms_(1) {}
void Fetch(const std::string& adapter_name, void Fetch(const std::string& adapter_name,
const CompletionCallback& callback) override { const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) override {
callback_ = callback; callback_ = callback;
timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_), timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_),
this, &DummyDhcpPacFileAdapterFetcher::OnTimer); this, &DummyDhcpPacFileAdapterFetcher::OnTimer);
...@@ -380,7 +382,7 @@ class FetcherClient { ...@@ -380,7 +382,7 @@ class FetcherClient {
int result = fetcher_.Fetch( int result = fetcher_.Fetch(
&pac_text_, &pac_text_,
base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)), base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)),
NetLogWithSource()); NetLogWithSource(), TRAFFIC_ANNOTATION_FOR_TESTS);
ASSERT_THAT(result, IsError(ERR_IO_PENDING)); ASSERT_THAT(result, IsError(ERR_IO_PENDING));
} }
...@@ -388,7 +390,7 @@ class FetcherClient { ...@@ -388,7 +390,7 @@ class FetcherClient {
int result = fetcher_.Fetch( int result = fetcher_.Fetch(
&pac_text_, &pac_text_,
base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)), base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)),
NetLogWithSource()); NetLogWithSource(), TRAFFIC_ANNOTATION_FOR_TESTS);
if (result != ERR_IO_PENDING) if (result != ERR_IO_PENDING)
result_ = result; result_ = result;
return result; return result;
......
...@@ -21,9 +21,11 @@ MockPacFileFetcher::MockPacFileFetcher() ...@@ -21,9 +21,11 @@ MockPacFileFetcher::MockPacFileFetcher()
MockPacFileFetcher::~MockPacFileFetcher() = default; MockPacFileFetcher::~MockPacFileFetcher() = default;
// PacFileFetcher implementation. // PacFileFetcher implementation.
int MockPacFileFetcher::Fetch(const GURL& url, int MockPacFileFetcher::Fetch(
base::string16* text, const GURL& url,
const CompletionCallback& callback) { base::string16* text,
const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) {
DCHECK(!has_pending_request()); DCHECK(!has_pending_request());
if (waiting_for_fetch_) if (waiting_for_fetch_)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "net/proxy_resolution/pac_file_fetcher.h" #include "net/proxy_resolution/pac_file_fetcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "url/gurl.h" #include "url/gurl.h"
#include <string> #include <string>
...@@ -25,7 +26,8 @@ class MockPacFileFetcher : public PacFileFetcher { ...@@ -25,7 +26,8 @@ class MockPacFileFetcher : public PacFileFetcher {
// PacFileFetcher implementation. // PacFileFetcher implementation.
int Fetch(const GURL& url, int Fetch(const GURL& url,
base::string16* text, base::string16* text,
const CompletionCallback& callback) override; const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
void OnShutdown() override; void OnShutdown() override;
URLRequestContext* GetRequestContext() const override; URLRequestContext* GetRequestContext() const override;
......
...@@ -328,7 +328,7 @@ int PacFileDecider::DoFetchPacScript() { ...@@ -328,7 +328,7 @@ int PacFileDecider::DoFetchPacScript() {
return dhcp_pac_file_fetcher_->Fetch( return dhcp_pac_file_fetcher_->Fetch(
&pac_script_, &pac_script_,
base::Bind(&PacFileDecider::OnIOCompletion, base::Unretained(this)), base::Bind(&PacFileDecider::OnIOCompletion, base::Unretained(this)),
net_log_); net_log_, NetworkTrafficAnnotationTag(traffic_annotation_));
} }
if (!pac_file_fetcher_) { if (!pac_file_fetcher_) {
...@@ -338,7 +338,8 @@ int PacFileDecider::DoFetchPacScript() { ...@@ -338,7 +338,8 @@ int PacFileDecider::DoFetchPacScript() {
return pac_file_fetcher_->Fetch( return pac_file_fetcher_->Fetch(
effective_pac_url, &pac_script_, effective_pac_url, &pac_script_,
base::Bind(&PacFileDecider::OnIOCompletion, base::Unretained(this))); base::Bind(&PacFileDecider::OnIOCompletion, base::Unretained(this)),
NetworkTrafficAnnotationTag(traffic_annotation_));
} }
int PacFileDecider::DoFetchPacScriptComplete(int result) { int PacFileDecider::DoFetchPacScriptComplete(int result) {
......
...@@ -117,7 +117,8 @@ class RuleBasedPacFileFetcher : public PacFileFetcher { ...@@ -117,7 +117,8 @@ class RuleBasedPacFileFetcher : public PacFileFetcher {
// PacFileFetcher implementation. // PacFileFetcher implementation.
int Fetch(const GURL& url, int Fetch(const GURL& url,
base::string16* text, base::string16* text,
const CompletionCallback& callback) override { const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) override {
const Rules::Rule& rule = rules_->GetRuleByUrl(url); const Rules::Rule& rule = rules_->GetRuleByUrl(url);
int rv = rule.fetch_error; int rv = rule.fetch_error;
EXPECT_NE(ERR_UNEXPECTED, rv); EXPECT_NE(ERR_UNEXPECTED, rv);
...@@ -147,7 +148,8 @@ class MockDhcpPacFileFetcher : public DhcpPacFileFetcher { ...@@ -147,7 +148,8 @@ class MockDhcpPacFileFetcher : public DhcpPacFileFetcher {
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) override; const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
void OnShutdown() override; void OnShutdown() override;
const GURL& GetPacURL() const override; const GURL& GetPacURL() const override;
...@@ -167,9 +169,11 @@ MockDhcpPacFileFetcher::MockDhcpPacFileFetcher() = default; ...@@ -167,9 +169,11 @@ MockDhcpPacFileFetcher::MockDhcpPacFileFetcher() = default;
MockDhcpPacFileFetcher::~MockDhcpPacFileFetcher() = default; MockDhcpPacFileFetcher::~MockDhcpPacFileFetcher() = default;
int MockDhcpPacFileFetcher::Fetch(base::string16* utf16_text, int MockDhcpPacFileFetcher::Fetch(
const CompletionCallback& callback, base::string16* utf16_text,
const NetLogWithSource& net_log) { const CompletionCallback& callback,
const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) {
utf16_text_ = utf16_text; utf16_text_ = utf16_text;
callback_ = callback; callback_ = callback;
return ERR_IO_PENDING; return ERR_IO_PENDING;
...@@ -694,7 +698,8 @@ class SynchronousSuccessDhcpFetcher : public DhcpPacFileFetcher { ...@@ -694,7 +698,8 @@ class SynchronousSuccessDhcpFetcher : public DhcpPacFileFetcher {
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) override { const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) override {
*utf16_text = expected_text_; *utf16_text = expected_text_;
return OK; return OK;
} }
...@@ -777,7 +782,8 @@ class AsyncFailDhcpFetcher ...@@ -777,7 +782,8 @@ class AsyncFailDhcpFetcher
int Fetch(base::string16* utf16_text, int Fetch(base::string16* utf16_text,
const CompletionCallback& callback, const CompletionCallback& callback,
const NetLogWithSource& net_log) override { const NetLogWithSource& net_log,
const NetworkTrafficAnnotationTag traffic_annotation) override {
callback_ = callback; callback_ = callback;
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
class GURL; class GURL;
...@@ -46,7 +47,8 @@ class NET_EXPORT_PRIVATE PacFileFetcher { ...@@ -46,7 +47,8 @@ class NET_EXPORT_PRIVATE PacFileFetcher {
// Only one fetch is allowed to be outstanding at a time. // Only one fetch is allowed to be outstanding at a time.
virtual int Fetch(const GURL& url, virtual int Fetch(const GURL& url,
base::string16* utf16_text, base::string16* utf16_text,
const CompletionCallback& callback) = 0; const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) = 0;
// Aborts the in-progress fetch (if any). // Aborts the in-progress fetch (if any).
virtual void Cancel() = 0; virtual void Cancel() = 0;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/cert/cert_status_flags.h" #include "net/cert/cert_status_flags.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
// TODO(eroman): // TODO(eroman):
...@@ -125,9 +124,11 @@ void PacFileFetcherImpl::OnResponseCompleted(URLRequest* request, ...@@ -125,9 +124,11 @@ void PacFileFetcherImpl::OnResponseCompleted(URLRequest* request,
FetchCompleted(); FetchCompleted();
} }
int PacFileFetcherImpl::Fetch(const GURL& url, int PacFileFetcherImpl::Fetch(
base::string16* text, const GURL& url,
const CompletionCallback& callback) { base::string16* text,
const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) {
// It is invalid to call Fetch() while a request is already in progress. // It is invalid to call Fetch() while a request is already in progress.
DCHECK(!cur_request_.get()); DCHECK(!cur_request_.get());
DCHECK(!callback.is_null()); DCHECK(!callback.is_null());
...@@ -151,35 +152,6 @@ int PacFileFetcherImpl::Fetch(const GURL& url, ...@@ -151,35 +152,6 @@ int PacFileFetcherImpl::Fetch(const GURL& url,
DCHECK(fetch_start_time_.is_null()); DCHECK(fetch_start_time_.is_null());
fetch_start_time_ = base::TimeTicks::Now(); fetch_start_time_ = base::TimeTicks::Now();
net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("proxy_script_fetcher", R"(
semantics {
sender: "Proxy Service"
description:
"Fetches candidate URLs for proxy auto-config (PAC) scripts. This "
"may be carried out as part of the web proxy auto-discovery "
"protocol, or because an explicit PAC script is specified by the "
"proxy settings. The source of these URLs may be user-specified "
"(when part of proxy settings), or may be provided by the network "
"(DNS or DHCP based discovery). Note that a user may not be using "
"a proxy, but determining that (i.e. auto-detect) may cause these "
"fetches."
trigger:
"PAC URLs may be fetched on initial start, every time the network "
"changes, whenever the proxy settings change, or periodically on a "
"timer to check for changes."
data: "None."
destination: OTHER
}
policy {
cookies_allowed: YES
cookies_store: "user"
setting:
"This feature cannot be disabled by settings. This request is only "
"made if the effective proxy settings include either auto-detect, "
"or specify a PAC script."
policy_exception_justification: "Not implemented."
})");
// Use highest priority, so if socket pools are being used for other types of // Use highest priority, so if socket pools are being used for other types of
// requests, PAC requests are aren't blocked on them. // requests, PAC requests are aren't blocked on them.
cur_request_ = url_request_context_->CreateRequest(url, MAXIMUM_PRIORITY, cur_request_ = url_request_context_->CreateRequest(url, MAXIMUM_PRIORITY,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/proxy_resolution/pac_file_fetcher.h" #include "net/proxy_resolution/pac_file_fetcher.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
class GURL; class GURL;
...@@ -50,7 +51,8 @@ class NET_EXPORT PacFileFetcherImpl : public PacFileFetcher, ...@@ -50,7 +51,8 @@ class NET_EXPORT PacFileFetcherImpl : public PacFileFetcher,
// PacFileFetcher methods: // PacFileFetcher methods:
int Fetch(const GURL& url, int Fetch(const GURL& url,
base::string16* text, base::string16* text,
const CompletionCallback& callback) override; const CompletionCallback& callback,
const NetworkTrafficAnnotationTag traffic_annotation) override;
void Cancel() override; void Cancel() override;
URLRequestContext* GetRequestContext() const override; URLRequestContext* GetRequestContext() const override;
void OnShutdown() override; void OnShutdown() override;
......
...@@ -181,7 +181,7 @@ Refer to README.md for content description and update process. ...@@ -181,7 +181,7 @@ Refer to README.md for content description and update process.
<item id="proxy_config_direct" hash_code="119015679" type="0" content_hash_code="119931568" os_list="linux,windows" file_path="net/proxy_resolution/proxy_config_with_annotation.cc"/> <item id="proxy_config_direct" hash_code="119015679" type="0" content_hash_code="119931568" os_list="linux,windows" file_path="net/proxy_resolution/proxy_config_with_annotation.cc"/>
<item id="proxy_config_headless" hash_code="133221587" type="0" content_hash_code="77459277" os_list="linux,windows" file_path="headless/lib/browser/headless_url_request_context_getter.cc"/> <item id="proxy_config_headless" hash_code="133221587" type="0" content_hash_code="77459277" os_list="linux,windows" file_path="headless/lib/browser/headless_url_request_context_getter.cc"/>
<item id="proxy_config_settings" hash_code="136468456" type="0" content_hash_code="19527377" os_list="linux,windows" file_path="components/proxy_config/pref_proxy_config_tracker_impl.cc"/> <item id="proxy_config_settings" hash_code="136468456" type="0" content_hash_code="19527377" os_list="linux,windows" file_path="components/proxy_config/pref_proxy_config_tracker_impl.cc"/>
<item id="proxy_script_fetcher" hash_code="37531401" type="0" content_hash_code="31866133" os_list="linux,windows" file_path="net/proxy_resolution/pac_file_fetcher_impl.cc"/> <item id="proxy_script_fetcher" hash_code="37531401" type="0" deprecated="2018-03-15" content_hash_code="31866133" file_path=""/>
<item id="puch_client_channel" hash_code="34459548" type="0" content_hash_code="92475475" os_list="linux,windows" file_path="components/invalidation/impl/push_client_channel.cc"/> <item id="puch_client_channel" hash_code="34459548" type="0" content_hash_code="92475475" os_list="linux,windows" file_path="components/invalidation/impl/push_client_channel.cc"/>
<item id="quic_chromium_incoming_session" hash_code="87635401" type="0" content_hash_code="78573093" os_list="linux,windows" file_path="net/quic/chromium/quic_chromium_client_session.cc"/> <item id="quic_chromium_incoming_session" hash_code="87635401" type="0" content_hash_code="78573093" os_list="linux,windows" file_path="net/quic/chromium/quic_chromium_client_session.cc"/>
<item id="quic_chromium_packet_writer" hash_code="20153177" type="0" content_hash_code="29657765" os_list="linux,windows" file_path="net/quic/chromium/quic_chromium_packet_writer.cc"/> <item id="quic_chromium_packet_writer" hash_code="20153177" type="0" content_hash_code="29657765" os_list="linux,windows" file_path="net/quic/chromium/quic_chromium_packet_writer.cc"/>
......
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