src/vs/platform/extensionManagement/node/extensionManagementService.ts/ExtensionManagementService/createInstallFromGalleryExtensionTask
class ExtensionManagementService:	private createInstallFromGalleryExtensionTask(extension: IGalleryExtension, options: InstallOptions): InstallExtensionTask {
		const key = new ExtensionIdentifierWithVersion(extension.identifier, extension.version).key();
		this._onInstallExtension.fire({ identifier: extension.identifier, gallery: extension });
		this.logService.info('Installing extension:', extension.identifier.id);

		let cancellablePromise: CancelablePromise<InstallResult> | undefined;
		const barrier = new Barrier();
		const installExtensionTask: InstallExtensionTask = {
			extension,
			get resultPromise() { return barrier.wait().then(() => cancellablePromise!); },
			run: async (): Promise<InstallResult> => {
				if (!cancellablePromise) {
					cancellablePromise = createCancelablePromise(async token => {
						try {
							const result = await this.installGalleryExtension(extension, options, token);
							this.logService.info(`Extensions installed successfully:`, extension.identifier.id);
							this._onDidInstallExtension.fire({ identifier: extension.identifier, gallery: result.gallery, local: result.local, operation: result.operation });
							return result;
						} catch (error) {
							const errorCode = error && (<ExtensionManagementError>error).code ? (<ExtensionManagementError>error).code : ERROR_UNKNOWN;
							this.logService.error(`Failed to install extension:`, extension.identifier.id, error ? error.message : errorCode);
							this._onDidInstallExtension.fire({ identifier: extension.identifier, gallery: extension, operation: InstallOperation.Install, error: errorCode });
							if (error instanceof Error) {
								error.name = errorCode;
							}
							throw error;
						}
					});
				}
				barrier.open();
				cancellablePromise.finally(() => this.installingExtensions.delete(key));
				return cancellablePromise;
			},
			cancel: (): void => {
				if (cancellablePromise) {
					cancellablePromise.cancel();
				} else {
					this._onDidInstallExtension.fire({ identifier: extension.identifier, gallery: extension, operation: InstallOperation.Install, error: INSTALL_ERROR_CANCELLED });
				}
			}
		};
		this.installingExtensions.set(key, installExtensionTask);
		return installExtensionTask;
	}