base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / mojo / services / public / js / application.js
blob5eefea4c35fea2d107a108010af7f94db68e2bab
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 define("mojo/services/public/js/application", [
6 "services/js/app_bridge",
7 "mojo/services/public/js/service_provider",
8 "mojo/services/public/js/shell",
9 ], function(appBridge, serviceProvider, shell) {
11 const ServiceProvider = serviceProvider.ServiceProvider;
12 const Shell = shell.Shell;
14 class Application {
15 constructor(shellHandle, url) {
16 this.url = url;
17 this.serviceProviders = [];
18 this.shellHandle_ = shellHandle;
19 this.shell = new Shell(shellHandle, {
20 initialize: this.initialize.bind(this),
21 acceptConnection: this.doAcceptConnection.bind(this),
22 });
25 initialize(args) {
28 doAcceptConnection(url, serviceProviderProxy) {
29 var serviceProvider = new ServiceProvider(serviceProviderProxy);
30 this.serviceProviders.push(serviceProvider);
31 this.acceptConnection(url, serviceProvider);
34 acceptConnection(url, serviceProvider) {
37 quit() {
38 this.serviceProviders.forEach(function(sp) {
39 sp.close();
40 });
41 this.shell.close();
42 appBridge.quit();
46 var exports = {};
47 exports.Application = Application;
48 return exports;
49 });