/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
"use strict";var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);n.prototype=t.prototype,e.prototype=new n};define("vs/workbench/services/request/common/requestService",["require","exports","vs/base/common/winjs.base","vs/base/common/timer","vs/base/common/async","vs/base/common/strings","vs/nls!vs/workbench/services/request/common/requestService","vs/platform/request/common/baseRequestService"],function(e,t,n,r,i,o,a,s){var c=function(e){function t(t){e.call(this,t),this._threadService=t.threadService,t.threadService.registerInstance(this)}return __extends(t,e),t.prototype.getId=function(){return"NativeRequestService"},t.prototype.makeRequest=function(t){var r=t.url;if(!r)throw new Error("IRequestService.makeRequest: Url is required");return o.startsWith(r,"file://")?n.xhr(t).then(null,function(e){return 0===e.status&&e.responseText?e:n.Promise.wrapError(new Error(a.localize("vs_workbench_services_request_common_requestService",0)))}):e.prototype.makeRequest.call(this,t)},t.prototype.makeCrossOriginRequest=function(e){if(this._nodeJSXHRFunctionPromise){var t=r.nullEvent;return this._telemetryService&&(t=this._telemetryService.start("WorkerXHR",{url:e.url},!1)),this._nodeJSXHRFunctionPromise.then(function(n){return i.always(n(e),function(e){t.data&&(t.data.status=e.status),t.stop()})})}return this._threadService.MainThread(this,"makeCrossOriginRequest",null,[e])},t}(s.BaseRequestService);t.WorkerRequestService=c});