diff --git a/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts b/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts index 5a3449e312..daa9d637a8 100644 --- a/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts +++ b/modules/@angular/platform-browser/src/platform/dynamic/worker_app.ts @@ -1,7 +1,7 @@ import {WORKER_APP_STATIC_APPLICATION_PROVIDERS} from '../static/worker_app'; import {workerAppPlatform} from '../common/worker_app'; import {COMPILER_PROVIDERS, XHR} from '@angular/compiler'; -import {WebWorkerXHRImpl} from '../../web_workers/worker/xhr_impl'; +import {XHRImpl} from '../../xhr/xhr_impl'; import {isPresent} from '../../facade/lang'; import { @@ -14,8 +14,7 @@ import { export const WORKER_APP_APPLICATION_PROVIDERS: Array = [ WORKER_APP_STATIC_APPLICATION_PROVIDERS, COMPILER_PROVIDERS, - WebWorkerXHRImpl, - /* @ts2dart_Provider */ {provide: XHR, useExisting: WebWorkerXHRImpl} + /* @ts2dart_Provider */ {provide: XHR, useClass: XHRImpl}, ]; export function bootstrapApp( diff --git a/modules/@angular/platform-browser/src/platform/dynamic/worker_render.ts b/modules/@angular/platform-browser/src/platform/dynamic/worker_render.ts index 103fc9107c..bfddb97a93 100644 --- a/modules/@angular/platform-browser/src/platform/dynamic/worker_render.ts +++ b/modules/@angular/platform-browser/src/platform/dynamic/worker_render.ts @@ -1,17 +1,11 @@ -import {XHR} from "@angular/compiler"; -import {XHRImpl} from "../../xhr/xhr_impl"; -import {MessageBasedXHRImpl} from "../../web_workers/ui/xhr_impl"; import {WORKER_RENDER_STATIC_APPLICATION_PROVIDERS} from "../static/worker_render"; import {ApplicationRef, ReflectiveInjector} from "@angular/core"; -import {workerRenderPlatform, WORKER_SCRIPT, WORKER_RENDER_STARTABLE_MESSAGING_SERVICE} from "../common/worker_render"; +import {workerRenderPlatform, WORKER_SCRIPT} from "../common/worker_render"; import {isPresent} from "../../facade/lang"; import {PromiseWrapper} from "../../facade/async"; export const WORKER_RENDER_APPLICATION_PROVIDERS: Array = [ - WORKER_RENDER_STATIC_APPLICATION_PROVIDERS, - /* @ts2dart_Provider */ {provide: XHR, useClass: XHRImpl}, - MessageBasedXHRImpl, - /* @ts2dart_Provider */ {provide: WORKER_RENDER_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedXHRImpl, multi: true}, + WORKER_RENDER_STATIC_APPLICATION_PROVIDERS ]; export function bootstrapRender( diff --git a/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts b/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts index b99644955c..086288b405 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts @@ -5,4 +5,3 @@ export const RENDERER_CHANNEL = "ng-Renderer"; export const EVENT_CHANNEL = "ng-Events"; export const ROUTER_CHANNEL = "ng-Router"; -export const XHR_CHANNEL = "ng-XHR"; diff --git a/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts b/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts deleted file mode 100644 index 865132a67f..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {Injectable} from '@angular/core'; -import {PRIMITIVE} from '../shared/serializer'; -import {ServiceMessageBrokerFactory} from '../shared/service_message_broker'; -import {XHR_CHANNEL} from '../shared/messaging_api'; -import {XHR} from '@angular/compiler'; -import {FunctionWrapper} from '../../facade/lang'; - -/** - * XHR requests triggered on the worker side are executed on the UI side. - * - * This is only strictly required for Dart where the isolates do not have access to XHRs. - * - * @internal - */ -@Injectable() -export class MessageBasedXHRImpl { - constructor(private _brokerFactory: ServiceMessageBrokerFactory, private _xhr: XHR) {} - - start(): void { - var broker = this._brokerFactory.createMessageBroker(XHR_CHANNEL); - broker.registerMethod("get", [PRIMITIVE], FunctionWrapper.bind(this._xhr.get, this._xhr), - PRIMITIVE); - } -} diff --git a/modules/@angular/platform-browser/src/web_workers/worker/xhr_impl.ts b/modules/@angular/platform-browser/src/web_workers/worker/xhr_impl.ts deleted file mode 100644 index ac19a185cc..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/worker/xhr_impl.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {Injectable} from '@angular/core'; -import {XHR} from '@angular/compiler'; -import { - FnArg, - UiArguments, - ClientMessageBroker, - ClientMessageBrokerFactory -} from '../shared/client_message_broker'; -import {XHR_CHANNEL} from '../shared/messaging_api'; - -/** - * Implementation of compiler/xhr that relays XHR requests to the UI side where they are sent - * and the result is proxied back to the worker. - * - * This is only strictly required for Dart where isolates do not have access to the XHRs. - */ -@Injectable() -export class WebWorkerXHRImpl extends XHR { - private _messageBroker: ClientMessageBroker; - - constructor(messageBrokerFactory: ClientMessageBrokerFactory) { - super(); - this._messageBroker = messageBrokerFactory.createMessageBroker(XHR_CHANNEL); - } - - get(url: string): Promise { - var fnArgs: FnArg[] = [new FnArg(url, null)]; - var args: UiArguments = new UiArguments("get", fnArgs); - return this._messageBroker.runOnService(args, String); - } -} diff --git a/modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts b/modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts deleted file mode 100644 index 9313013b0e..0000000000 --- a/modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {inject, describe, it, expect} from '@angular/core/testing/testing_internal'; -import {AsyncTestCompleter} from '@angular/core/testing/testing_internal'; - -import {SpyMessageBroker} from '@angular/platform-browser/test/web_workers/worker/spies'; -import {WebWorkerXHRImpl} from '@angular/platform-browser/src/web_workers/worker/xhr_impl'; -import {PromiseWrapper} from '../../../src/facade/async'; -import { - MockMessageBrokerFactory, - expectBrokerCall -} from '@angular/platform-browser/test/web_workers/shared/web_worker_test_util'; - -export function main() { - describe("WebWorkerXHRImpl", () => { - it("should pass requests through the broker and return the response", - inject([AsyncTestCompleter], (async) => { - const URL = "http://www.example.com/test"; - const RESPONSE = "Example response text"; - - var messageBroker = new SpyMessageBroker(); - expectBrokerCall(messageBroker, "get", [URL], - (_) => { return PromiseWrapper.wrap(() => { return RESPONSE; }); }); - var xhrImpl = new WebWorkerXHRImpl(new MockMessageBrokerFactory(messageBroker)); - xhrImpl.get(URL).then((response) => { - expect(response).toEqual(RESPONSE); - async.done(); - }); - })); - }); -}