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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Issue 2703603003: [Devtools] Changed protocol to use setBlockedURLs instead of add/remove (Closed)
Patch Set: changes Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/core/inspector/browser_protocol.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 daa1d5388ceaa1437f6bf2f279a4a644fe545e8e..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,13 +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._blockedSetting.set([]);
- this._updateBlockedURLs();
-
this._userAgentOverride = '';
this._isRequestBlockingEnabled = false;
/** @type {!Set<!Protocol.NetworkAgent>} */
@@ -699,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([]);
pfeldman 2017/03/06 18:23:10 Don't add it here?
+ this._updateBlockedURLs();
+
SDK.targetManager.observeTargets(this, SDK.Target.Capability.Network);
}
@@ -725,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);
@@ -837,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;
- for (var agent of this._agents)
- agent.addBlockedURL(url);
- }
-
- /**
- * @param {string} url
- */
- _removeBlockedURL(url) {
- this._blockedURLs.delete(url);
- if (!this._isRequestBlockingEnabled)
- return;
+ var urls = /** @type {!Array<string>} */ ([]);
+ if (this._isRequestBlockingEnabled)
+ urls = this._blockedSetting.get();
for (var agent of this._agents)
- agent.removeBlockedURL(url);
+ agent.setBlockedURLs(urls);
pfeldman 2017/03/06 18:23:10 It'be nice to not issue these calls unless necessa
}
/**
@@ -877,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();
pfeldman 2017/03/06 18:23:10 It can be easily achieved via clearing the blocked
this.emit(new SDK.MultitargetNetworkManager.RequestBlockingEnabledChangedEvent());
}
« no previous file with comments | « third_party/WebKit/Source/core/inspector/browser_protocol.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698