Index: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js |
index c3dac02ffc315b81cd8f51c6cb6603240d987f58..4fc818cdf2562f18218b66cb1650c4a5f21a5186 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js |
@@ -685,12 +685,6 @@ SDK.MultitargetNetworkManager = class extends Common.Object { |
constructor() { |
super(); |
- /** @type {!Set<string>} */ |
- this._blockedURLs = new Set(); |
- this._blockedSetting = Common.moduleSetting('networkBlockedURLs'); |
- this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); |
- this._updateBlockedURLs(); |
- |
this._userAgentOverride = ''; |
this._isRequestBlockingEnabled = false; |
/** @type {!Set<!Protocol.NetworkAgent>} */ |
@@ -698,6 +692,11 @@ SDK.MultitargetNetworkManager = class extends Common.Object { |
/** @type {!SDK.NetworkManager.Conditions} */ |
this._networkConditions = SDK.NetworkManager.NoThrottlingConditions; |
+ this._blockedSetting = Common.moduleSetting('networkBlockedURLs'); |
+ this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); |
+ this._blockedSetting.set([]); |
+ this._updateBlockedURLs(); |
+ |
SDK.targetManager.observeTargets(this, SDK.Target.Capability.Network); |
} |
@@ -724,8 +723,8 @@ SDK.MultitargetNetworkManager = class extends Common.Object { |
networkAgent.setExtraHTTPHeaders(this._extraHeaders); |
if (this._currentUserAgent()) |
networkAgent.setUserAgentOverride(this._currentUserAgent()); |
- for (var url of this._blockedURLs) |
- networkAgent.addBlockedURL(url); |
+ if (this._isRequestBlockingEnabled) |
+ networkAgent.setBlockedURLs(this._blockedSetting.get()); |
this._agents.add(networkAgent); |
if (this.isThrottling()) |
this._updateNetworkConditions(networkAgent); |
@@ -836,37 +835,11 @@ SDK.MultitargetNetworkManager = class extends Common.Object { |
} |
_updateBlockedURLs() { |
- var blocked = this._blockedSetting.get(); |
- for (var url of blocked) { |
- if (!this._blockedURLs.has(url)) |
- this._addBlockedURL(url); |
- } |
- for (var url of this._blockedURLs) { |
- if (blocked.indexOf(url) === -1) |
- this._removeBlockedURL(url); |
- } |
- } |
- |
- /** |
- * @param {string} url |
- */ |
- _addBlockedURL(url) { |
- this._blockedURLs.add(url); |
- if (!this._isRequestBlockingEnabled) |
- return; |
+ var urls = /** @type {!Array<string>} */ ([]); |
+ if (this._isRequestBlockingEnabled) |
+ urls = this._blockedSetting.get(); |
for (var agent of this._agents) |
- agent.addBlockedURL(url); |
- } |
- |
- /** |
- * @param {string} url |
- */ |
- _removeBlockedURL(url) { |
- this._blockedURLs.delete(url); |
- if (!this._isRequestBlockingEnabled) |
- return; |
- for (var agent of this._agents) |
- agent.removeBlockedURL(url); |
+ agent.setBlockedURLs(urls); |
} |
/** |
@@ -876,13 +849,7 @@ SDK.MultitargetNetworkManager = class extends Common.Object { |
if (this._isRequestBlockingEnabled === enabled) |
return; |
this._isRequestBlockingEnabled = enabled; |
- if (enabled) { |
- for (var agent of this._agents) |
- this._blockedURLs.forEach(url => agent.addBlockedURL(url)); |
- } else { |
- for (var agent of this._agents) |
- this._blockedURLs.forEach(url => agent.removeBlockedURL(url)); |
- } |
+ this._updateBlockedURLs(); |
this.emit(new SDK.MultitargetNetworkManager.RequestBlockingEnabledChangedEvent()); |
} |