2014-02-15 02:15:54 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
( function () {
|
2014-02-19 02:27:30 +00:00
|
|
|
/**
|
2014-11-21 10:07:40 +00:00
|
|
|
* Runs performance analysis on requests via mw.mmv.logging.PerformanceLogger
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-09-04 23:00:55 +00:00
|
|
|
* @class mw.mmv.logging.Api
|
2014-02-19 02:27:30 +00:00
|
|
|
* @extends mw.Api
|
|
|
|
* @constructor
|
|
|
|
* @param {string} type The type of the requests to be made through this API.
|
|
|
|
* @param {Object} options See mw.Api#defaultOptions
|
|
|
|
*/
|
2014-02-15 02:15:54 +00:00
|
|
|
function Api( type, options ) {
|
|
|
|
mw.Api.call( this, options );
|
|
|
|
|
2014-11-21 10:07:40 +00:00
|
|
|
/** @property {mw.mmv.logging.PerformanceLogger} performance Used to record performance data. */
|
|
|
|
this.performance = new mw.mmv.logging.PerformanceLogger();
|
2014-02-19 02:27:30 +00:00
|
|
|
|
|
|
|
/** @property {string} type Type of requests being sent via this API. */
|
2014-02-15 02:15:54 +00:00
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
OO.inheritClass( Api, mw.Api );
|
2014-02-15 02:15:54 +00:00
|
|
|
|
2014-02-19 02:27:30 +00:00
|
|
|
/**
|
|
|
|
* Runs an AJAX call to the server.
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-02-19 02:27:30 +00:00
|
|
|
* @override
|
|
|
|
* @param {Object} parameters
|
|
|
|
* @param {Object} [ajaxOptions]
|
2016-07-18 13:49:27 +00:00
|
|
|
* @return {jQuery.Promise.<Object, jqXHR>} Done: API response data. Fail: Error code.
|
2014-02-19 02:27:30 +00:00
|
|
|
*/
|
2014-02-15 02:15:54 +00:00
|
|
|
Api.prototype.ajax = function ( parameters, ajaxOptions ) {
|
|
|
|
var start = $.now(),
|
|
|
|
api = this;
|
|
|
|
|
|
|
|
return mw.Api.prototype.ajax.call( this, parameters, ajaxOptions ).done( function ( result, jqxhr ) {
|
|
|
|
api.performance.recordJQueryEntryDelayed( api.type, $.now() - start, jqxhr );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2014-09-04 23:00:55 +00:00
|
|
|
mw.mmv.logging.Api = Api;
|
2018-11-12 16:33:24 +00:00
|
|
|
}() );
|