提交 a97e98b1 编写于 作者: B Benjamin Pasero

💄

上级 f6f37aa3
......@@ -213,7 +213,7 @@ class SQLiteStorageLogger {
private logError: boolean;
constructor(private options?: ISQLiteStorageLoggingOptions) {
this.logInfo = this.verbose && !!options.infoLogger;
this.logInfo = this.verbose && options && !!options.infoLogger;
this.logError = options && !!options.errorLogger;
}
......
......@@ -16,7 +16,7 @@ export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleSe
* resolves to a boolean. Returning a promise is useful in cases of long running operations
* on shutdown.
*
* Note: It is absolutely important to avoid long running promises on this call. Please try hard
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
*/
export interface WillShutdownEvent {
......@@ -38,7 +38,7 @@ export interface WillShutdownEvent {
* by providing a promise from the join method. Returning a promise is useful in cases of long
* running operations on shutdown.
*
* Note: It is absolutely important to avoid long running promises on this call. Please try hard
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
*/
export interface ShutdownEvent {
......@@ -141,11 +141,11 @@ export interface ILifecycleService {
export const NullLifecycleService: ILifecycleService = {
_serviceBrand: null,
onWillShutdown: Event.None,
onShutdown: Event.None,
phase: LifecyclePhase.Running,
when() { return Promise.resolve(); },
startupKind: StartupKind.NewWindow,
onWillShutdown: Event.None,
onShutdown: Event.None
when() { return Promise.resolve(); }
};
// Shared veto handling across main and renderer
......
......@@ -35,7 +35,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
private _phase: LifecyclePhase = LifecyclePhase.Starting;
get phase(): LifecyclePhase { return this._phase; }
private _phaseWhen = new Map<LifecyclePhase, Barrier>();
private phaseWhen = new Map<LifecyclePhase, Barrier>();
constructor(
@INotificationService private notificationService: INotificationService,
......@@ -150,9 +150,9 @@ export class LifecycleService extends Disposable implements ILifecycleService {
this._phase = value;
mark(`LifecyclePhase/${LifecyclePhaseToString(value)}`);
if (this._phaseWhen.has(this._phase)) {
this._phaseWhen.get(this._phase).open();
this._phaseWhen.delete(this._phase);
if (this.phaseWhen.has(this._phase)) {
this.phaseWhen.get(this._phase).open();
this.phaseWhen.delete(this._phase);
}
}
......@@ -161,10 +161,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
return Promise.resolve();
}
let barrier = this._phaseWhen.get(phase);
let barrier = this.phaseWhen.get(phase);
if (!barrier) {
barrier = new Barrier();
this._phaseWhen.set(phase, barrier);
this.phaseWhen.set(phase, barrier);
}
return barrier.wait();
......
......@@ -69,16 +69,28 @@ export interface ILifecycleService {
*/
onBeforeWindowUnload: Event<IWindowUnloadEvent>;
ready(): void;
registerWindow(window: ICodeWindow): void;
/**
* Close a window for the provided reason. Shutdown handlers are triggered.
*/
unload(window: ICodeWindow, reason: UnloadReason): TPromise<boolean /* veto */>;
/**
* Restart the application with optional arguments (CLI). Shutdown handlers are triggered.
*/
relaunch(options?: { addArgs?: string[], removeArgs?: string[] }): void;
/**
* Shutdown the application normally. Shutdown handlers are triggered.
*/
quit(fromUpdate?: boolean): TPromise<boolean /* veto */>;
/**
* Forcefully shutdown the application. No shutdown handlers are triggered.
*/
kill(code?: number): void;
ready(): void;
registerWindow(window: ICodeWindow): void;
}
export class LifecycleService extends Disposable implements ILifecycleService {
......
......@@ -62,47 +62,47 @@ export interface INextWorkspaceStorageService {
* Retrieve an element stored with the given key from storage. Use
* the provided defaultValue if the element is null or undefined.
*
* The optional scope argument allows to define the scope of the storage
* The scope argument allows to define the scope of the storage
* operation to either the current workspace only or all workspaces.
*/
get(key: string, scope?: StorageScope, fallbackValue?: string): string;
get(key: string, scope: StorageScope, fallbackValue?: string): string;
/**
* Retrieve an element stored with the given key from storage. Use
* the provided defaultValue if the element is null or undefined. The element
* will be converted to a boolean.
*
* The optional scope argument allows to define the scope of the storage
* The scope argument allows to define the scope of the storage
* operation to either the current workspace only or all workspaces.
*/
getBoolean(key: string, scope?: StorageScope, fallbackValue?: boolean): boolean;
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean;
/**
* Retrieve an element stored with the given key from storage. Use
* the provided defaultValue if the element is null or undefined. The element
* will be converted to a number using parseInt with a base of 10.
*
* The optional scope argument allows to define the scope of the storage
* The scope argument allows to define the scope of the storage
* operation to either the current workspace only or all workspaces.
*/
getInteger(key: string, scope?: StorageScope, fallbackValue?: number): number;
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number;
/**
* Store a string value under the given key to storage. The value will
* be converted to a string.
*
* The optional scope argument allows to define the scope of the storage
* The scope argument allows to define the scope of the storage
* operation to either the current workspace only or all workspaces.
*/
set(key: string, value: any, scope?: StorageScope): Promise<void>;
set(key: string, value: any, scope: StorageScope): Promise<void>;
/**
* Delete an element stored under the provided key from storage.
*
* The optional scope argument allows to define the scope of the storage
* The scope argument allows to define the scope of the storage
* operation to either the current workspace only or all workspaces.
*/
delete(key: string, scope?: StorageScope): Promise<void>;
delete(key: string, scope: StorageScope): Promise<void>;
}
export const enum StorageScope {
......
......@@ -18,7 +18,7 @@ enum StorageState {
Closed
}
export class NextStorageServiceImpl extends Disposable implements INextStorageService {
export class NextStorageService extends Disposable implements INextStorageService {
_serviceBrand: any;
private static readonly FLUSH_DELAY = 10;
......@@ -52,7 +52,7 @@ export class NextStorageServiceImpl extends Disposable implements INextStorageSe
}
});
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), NextStorageServiceImpl.FLUSH_DELAY);
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), NextStorageService.FLUSH_DELAY);
}
init(): Promise<void> {
......
......@@ -8,16 +8,16 @@ import { Event, Emitter } from 'vs/base/common/event';
import { ILogService } from 'vs/platform/log/common/log';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INextStorageService, IWorkspaceStorageChangeEvent, INextWorkspaceStorageService, StorageScope } from 'vs/platform/storage2/common/storage2';
import { NextStorageServiceImpl } from 'vs/platform/storage2/node/nextStorageServiceImpl';
import { NextStorageService } from 'vs/platform/storage2/node/nextStorageService';
export class NextWorkspaceStorageServiceImpl extends Disposable implements INextWorkspaceStorageService {
export class NextWorkspaceStorageService extends Disposable implements INextWorkspaceStorageService {
_serviceBrand: any;
private _onDidChangeStorage: Emitter<IWorkspaceStorageChangeEvent> = this._register(new Emitter<IWorkspaceStorageChangeEvent>());
get onDidChangeStorage(): Event<IWorkspaceStorageChangeEvent> { return this._onDidChangeStorage.event; }
private globalStorage: NextStorageServiceImpl;
private workspaceStorage: NextStorageServiceImpl;
private globalStorage: NextStorageService;
private workspaceStorage: NextStorageService;
constructor(
workspaceDBPath: string,
......@@ -26,8 +26,8 @@ export class NextWorkspaceStorageServiceImpl extends Disposable implements INext
) {
super();
this.globalStorage = new NextStorageServiceImpl(':memory:', logService, environmentService); // TODO proxy from main side!
this.workspaceStorage = new NextStorageServiceImpl(workspaceDBPath, logService, environmentService);
this.globalStorage = new NextStorageService(':memory:', logService, environmentService);
this.workspaceStorage = new NextStorageService(workspaceDBPath, logService, environmentService);
this.registerListeners();
}
......@@ -45,28 +45,31 @@ export class NextWorkspaceStorageServiceImpl extends Disposable implements INext
return Promise.all([this.globalStorage.init(), this.workspaceStorage.init()]).then(() => void 0);
}
get(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: any): string {
get(key: string, scope: StorageScope, fallbackValue?: any): string {
return this.getStorage(scope).get(key, fallbackValue);
}
getBoolean(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: boolean): boolean {
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean {
return this.getStorage(scope).getBoolean(key, fallbackValue);
}
getInteger(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: number): number {
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number {
return this.getStorage(scope).getInteger(key, fallbackValue);
}
set(key: string, value: any, scope: StorageScope = StorageScope.GLOBAL): Promise<void> {
set(key: string, value: any, scope: StorageScope): Promise<void> {
return this.getStorage(scope).set(key, value);
}
delete(key: string, scope: StorageScope = StorageScope.GLOBAL): Promise<void> {
delete(key: string, scope: StorageScope): Promise<void> {
return this.getStorage(scope).delete(key);
}
close(): Promise<void> {
return this.workspaceStorage.close();
return Promise.all([
this.globalStorage.close(),
this.workspaceStorage.close()
]).then(() => void 0);
}
private getStorage(scope: StorageScope): INextStorageService {
......
......@@ -5,7 +5,7 @@
import { NullLogService } from 'vs/platform/log/common/log';
import { TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { NextStorageServiceImpl } from 'vs/platform/storage2/node/nextStorageServiceImpl';
import { NextStorageService } from 'vs/platform/storage2/node/nextStorageService';
import { generateUuid } from 'vs/base/common/uuid';
import { join } from 'path';
import { tmpdir } from 'os';
......@@ -33,7 +33,7 @@ suite('Workbench NextStorageService', () => {
const storageDir = uniqueStorageDir();
await mkdirp(storageDir);
const storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
const storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
......@@ -90,7 +90,7 @@ suite('Workbench NextStorageService', () => {
const storageDir = uniqueStorageDir();
await mkdirp(storageDir);
let storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
let storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
const set1Promise = storageService.set('foo', 'bar');
......@@ -106,7 +106,7 @@ suite('Workbench NextStorageService', () => {
equal(setPromiseResolved, true);
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
equal(storageService.get('foo'), 'bar');
......@@ -114,7 +114,7 @@ suite('Workbench NextStorageService', () => {
await storageService.close();
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
const delete1Promise = storageService.delete('foo');
......@@ -130,7 +130,7 @@ suite('Workbench NextStorageService', () => {
equal(deletePromiseResolved, true);
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
ok(!storageService.get('foo'));
......@@ -144,7 +144,7 @@ suite('Workbench NextStorageService', () => {
const storageDir = uniqueStorageDir();
await mkdirp(storageDir);
let storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
let storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
await storageService.init();
const set1Promise = storageService.set('foo', 'bar1');
......
......@@ -36,7 +36,7 @@ import { IWorkspacesService, ISingleFolderWorkspaceIdentifier } from 'vs/platfor
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import * as fs from 'fs';
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
import { NextWorkspaceStorageServiceImpl } from 'vs/platform/storage2/node/nextWorkspaceStorageServiceImpl';
import { NextWorkspaceStorageService } from 'vs/platform/storage2/node/nextWorkspaceStorageService';
import { IssueChannelClient } from 'vs/platform/issue/node/issueIpc';
import { IIssueService } from 'vs/platform/issue/common/issue';
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/node/logIpc';
......@@ -166,8 +166,8 @@ function validateFolderUri(folderUri: ISingleFolderWorkspaceIdentifier, verbose:
});
}
function createNextWorkspaceStorageService(environmentService: IEnvironmentService, logService: ILogService): Promise<NextWorkspaceStorageServiceImpl> {
const nextStorageService = new NextWorkspaceStorageServiceImpl(':memory:', logService, environmentService);
function createNextWorkspaceStorageService(environmentService: IEnvironmentService, logService: ILogService): Promise<NextWorkspaceStorageService> {
const nextStorageService = new NextWorkspaceStorageService(':memory:', logService, environmentService);
return nextStorageService.init().then(() => nextStorageService);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册