Demo/bin/Debug/front_end/common/Throttler.js

(开头部分) 3KB

这里只显示每个文件的开头 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
 * @param {number} timeout
 */
WebInspector.Throttler = function(timeout)
{
    this._timeout = timeout;
    this._isRunningProcess = false;
    this._asSoonAsPossible = false;
    /** @type {?function(!WebInspector.Throttler.FinishCallback)} */
    this._process = null;
}

WebInspector.Throttler.prototype = {
    /**
     * @param {!Error=} error
     */
    _processCompleted: function(error)
    {
        if (error) {
            console.error(error);
            alert("WebInspector.Throttler.prototype._processCompleted:"  + error);
        }
        this._isRunningProcess = false;
        if (this._process)
            this._innerSchedule(false);
        this._processCompletedForTests();
    },

    _processCompletedForTests: function()
    {
        // For sniffing in tests.
    },

    _onTimeout: function()
    {
        delete this._processTimeout;
        this._asSoonAsPossible = false;
        this._isRunningProcess = true;

        // Process might issue synchronous calls to this throttler.
        var process = this._process;
        this._process = null;
        try {
            process(this._processCompleted.bind(this));
        } catch (e) {
            // Process might have called completed() and threw exception later.
            if (this._isRunningProcess)
                this._processCompleted(e);
        }
    },

    /**
     * @param {function(!WebInspector.Throttler.FinishCallback)} process
     * @param {boolean=} asSoonAsPossible
     */
后面还有 52 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。