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

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

Issue 2137773002: [DevTools] Replace the target type with capabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
Index: third_party/WebKit/Source/devtools/front_end/sdk/Target.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
index ebaf360642910fa249815ba62469fdc3f72b917c..0ba8715d4e40072b22722e5d43d75ca7baa8238c 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Target.js
@@ -9,16 +9,16 @@
* @extends {Protocol.Agents}
* @param {!WebInspector.TargetManager} targetManager
* @param {string} name
- * @param {number} type
+ * @param {number} capabilitiesMask
* @param {!InspectorBackendClass.Connection} connection
* @param {?WebInspector.Target} parentTarget
*/
-WebInspector.Target = function(targetManager, name, type, connection, parentTarget)
+WebInspector.Target = function(targetManager, name, capabilitiesMask, connection, parentTarget)
{
Protocol.Agents.call(this, connection.agentsMap());
this._targetManager = targetManager;
this._name = name;
- this._type = type;
+ this._capabilitiesMask = capabilitiesMask;
this._connection = connection;
this._parentTarget = parentTarget;
connection.addEventListener(InspectorBackendClass.Connection.Events.Disconnected, this._onDisconnect, this);
@@ -31,11 +31,11 @@ WebInspector.Target = function(targetManager, name, type, connection, parentTarg
/**
* @enum {number}
*/
-WebInspector.Target.Type = {
- Page: 1,
- DedicatedWorker: 2,
- ServiceWorker: 4,
- JSInspector: 8
+WebInspector.Target.Capability = {
+ Browser: 1,
+ JS: 2,
+ Network: 4,
+ Worker: 8,
}
WebInspector.Target._nextId = 1;
@@ -58,21 +58,20 @@ WebInspector.Target.prototype = {
},
/**
- *
- * @return {number}
+ * @return {!WebInspector.TargetManager}
*/
- type: function()
+ targetManager: function()
{
- return this._type;
+ return this._targetManager;
},
/**
- *
- * @return {!WebInspector.TargetManager}
+ * @param {number} capabilitiesMask
+ * @return {boolean}
*/
- targetManager: function()
+ hasAllCapabilities: function(capabilitiesMask)
{
- return this._targetManager;
+ return (this._capabilitiesMask & capabilitiesMask) === capabilitiesMask;
},
/**
@@ -81,7 +80,7 @@ WebInspector.Target.prototype = {
*/
decorateLabel: function(label)
{
- return this.isWorker() ? "\u2699 " + label : label;
+ return !this.hasBrowserCapability() ? "\u2699 " + label : label;
},
/**
@@ -97,57 +96,33 @@ WebInspector.Target.prototype = {
/**
* @return {boolean}
*/
- isPage: function()
- {
- return this._type === WebInspector.Target.Type.Page;
- },
-
- /**
- * @return {boolean}
- */
- isWorker: function()
- {
- return this.isDedicatedWorker() || this.isServiceWorker() || this.isJSInspector();
- },
-
- /**
- * @return {boolean}
- */
- isDedicatedWorker: function()
- {
- return this._type === WebInspector.Target.Type.DedicatedWorker;
- },
-
- /**
- * @return {boolean}
- */
- isServiceWorker: function()
+ hasBrowserCapability: function()
{
- return this._type === WebInspector.Target.Type.ServiceWorker;
+ return this.hasAllCapabilities(WebInspector.Target.Capability.Browser);
},
/**
* @return {boolean}
*/
- isJSInspector: function()
+ hasJSCapability: function()
{
- return this._type === WebInspector.Target.Type.JSInspector;
+ return this.hasAllCapabilities(WebInspector.Target.Capability.JS);
},
/**
* @return {boolean}
*/
- hasJSContext: function()
+ hasNetworkCapability: function()
{
- return !this.isServiceWorker();
+ return this.hasAllCapabilities(WebInspector.Target.Capability.Network);
},
/**
* @return {boolean}
*/
- supportsWorkers: function()
+ hasWorkerCapability: function()
{
- return this.isPage() || this.isServiceWorker();
+ return this.hasAllCapabilities(WebInspector.Target.Capability.Worker);
},
/**

Powered by Google App Engine
This is Rietveld 408576698