Demo/bin/Debug/front_end/components/ExecutionContextSelector.js
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @constructor
* @implements {WebInspector.TargetManager.Observer}
* @param {!WebInspector.TargetManager} targetManager
* @param {!WebInspector.Context} context
*/
WebInspector.ExecutionContextSelector = function(targetManager, context)
{
targetManager.observeTargets(this);
context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChanged, this);
context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, this);
targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
this._targetManager = targetManager;
this._context = context;
}
WebInspector.ExecutionContextSelector.prototype = {
/**
* @override
* @param {!WebInspector.Target} target
*/
targetAdded: function(target)
{
if (!target.hasJSContext())
return;
// Defer selecting default target since we need all clients to get their
// targetAdded notifications first.
setImmediate(deferred.bind(this));
/**
* @this {WebInspector.ExecutionContextSelector}
*/
function deferred()
{
// We always want the second context for the service worker targets.
if (!this._context.flavor(WebInspector.Target))
this._context.setFlavor(WebInspector.Target, target);
}
},
/**
* @override
* @param {!WebInspector.Target} target
*/
targetRemoved: function(target)
{
if (!target.hasJSContext())
return;
var currentExecutionContext = this._context.flavor(WebInspector.ExecutionContext);
if (currentExecutionContext && currentExecutionContext.target() === target)
this._currentExecutionContextGone();
var targets = this._targetManager.targetsWithJSContext();
后面还有 114 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。