Commit c4a7df85 authored by joi@chromium.org's avatar joi@chromium.org

Fix a bad inversion of logic (see OnCanThrottleRequest) and a bug

related to how a flag was persisted.

BUG=141081,141643


Review URL: https://chromiumcodereview.appspot.com/10854069

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150928 0039d316-1c4b-4281-b951-d872f2087c98
parent 5c42eed8
...@@ -53,6 +53,10 @@ bool ChromeNetworkDelegate::g_allow_file_access_ = false; ...@@ -53,6 +53,10 @@ bool ChromeNetworkDelegate::g_allow_file_access_ = false;
bool ChromeNetworkDelegate::g_allow_file_access_ = true; bool ChromeNetworkDelegate::g_allow_file_access_ = true;
#endif #endif
// This remains false unless the --disable-extensions-http-throttling
// flag is passed to the browser.
bool ChromeNetworkDelegate::g_never_throttle_requests_ = false;
namespace { namespace {
// If the |request| failed due to problems with a proxy, forward the error to // If the |request| failed due to problems with a proxy, forward the error to
...@@ -134,7 +138,6 @@ ChromeNetworkDelegate::ChromeNetworkDelegate( ...@@ -134,7 +138,6 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
cookie_settings_(cookie_settings), cookie_settings_(cookie_settings),
extension_info_map_(extension_info_map), extension_info_map_(extension_info_map),
enable_referrers_(enable_referrers), enable_referrers_(enable_referrers),
never_throttle_requests_(false),
url_blacklist_manager_(url_blacklist_manager), url_blacklist_manager_(url_blacklist_manager),
cache_stats_(cache_stats) { cache_stats_(cache_stats) {
DCHECK(event_router); DCHECK(event_router);
...@@ -144,8 +147,9 @@ ChromeNetworkDelegate::ChromeNetworkDelegate( ...@@ -144,8 +147,9 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
ChromeNetworkDelegate::~ChromeNetworkDelegate() {} ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
// static
void ChromeNetworkDelegate::NeverThrottleRequests() { void ChromeNetworkDelegate::NeverThrottleRequests() {
never_throttle_requests_ = true; g_never_throttle_requests_ = true;
} }
// static // static
...@@ -368,11 +372,11 @@ bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, ...@@ -368,11 +372,11 @@ bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
bool ChromeNetworkDelegate::OnCanThrottleRequest( bool ChromeNetworkDelegate::OnCanThrottleRequest(
const net::URLRequest& request) const { const net::URLRequest& request) const {
if (never_throttle_requests_) { if (g_never_throttle_requests_) {
return false; return false;
} }
return request.first_party_for_cookies().scheme() != return request.first_party_for_cookies().scheme() ==
chrome::kExtensionScheme; chrome::kExtensionScheme;
} }
......
...@@ -49,8 +49,9 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { ...@@ -49,8 +49,9 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
chrome_browser_net::CacheStats* cache_stats); chrome_browser_net::CacheStats* cache_stats);
virtual ~ChromeNetworkDelegate(); virtual ~ChromeNetworkDelegate();
// Causes |OnCanThrottleRequest| to never return true. // Causes |OnCanThrottleRequest| to always return false, for all
void NeverThrottleRequests(); // instances of this object.
static void NeverThrottleRequests();
// Binds |enable_referrers| to |pref_service| and moves it to the IO thread. // Binds |enable_referrers| to |pref_service| and moves it to the IO thread.
// This method should be called on the UI thread. // This method should be called on the UI thread.
...@@ -115,15 +116,20 @@ class ChromeNetworkDelegate : public net::NetworkDelegate { ...@@ -115,15 +116,20 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
// Weak, owned by our owner. // Weak, owned by our owner.
BooleanPrefMember* enable_referrers_; BooleanPrefMember* enable_referrers_;
// True if OnCanThrottleRequest should always return false.
bool never_throttle_requests_;
// Weak, owned by our owner. // Weak, owned by our owner.
const policy::URLBlacklistManager* url_blacklist_manager_; const policy::URLBlacklistManager* url_blacklist_manager_;
// When true, allow access to all file:// URLs. // When true, allow access to all file:// URLs.
static bool g_allow_file_access_; static bool g_allow_file_access_;
// True if OnCanThrottleRequest should always return false.
//
// Note: This needs to be static as the instance of
// ChromeNetworkDelegate used may change over time, and we need to
// set this variable once at start-up time. It is effectively
// static anyway since it is based on a command-line flag.
static bool g_never_throttle_requests_;
// Pointer to IOThread global, should outlive ChromeNetworkDelegate. // Pointer to IOThread global, should outlive ChromeNetworkDelegate.
chrome_browser_net::CacheStats* cache_stats_; chrome_browser_net::CacheStats* cache_stats_;
......
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