| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* jshint evil: true */ | 7 /* jshint evil: true */ |
| 8 /* globals PipeServer */ | 8 /* globals PipeServer */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return !process.parent; | 479 return !process.parent; |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * Broadcast message from javascript to all the processes. | 483 * Broadcast message from javascript to all the processes. |
| 484 * @message the message to be broadcasted | 484 * @message the message to be broadcasted |
| 485 * @callback callback to be stashed away and called when | 485 * @callback callback to be stashed away and called when |
| 486 * a process responds with a mount status update | 486 * a process responds with a mount status update |
| 487 */ | 487 */ |
| 488 NaClProcessManager.prototype.broadcastMessage = function (message, callback) { | 488 NaClProcessManager.prototype.broadcastMessage = function (message, callback) { |
| 489 this.mountUpdateCallback = callback; | 489 var self = this; |
| 490 Object.keys(this.processes).forEach(function (key) { | 490 self.mountUpdateCallback = callback; |
| 491 this.processes[key].domElement.postMessage(message); | 491 Object.keys(self.processes).forEach(function (key) { |
| 492 self.processes[key].domElement.postMessage(message); |
| 492 }); | 493 }); |
| 493 }; | 494 }; |
| 494 | 495 |
| 495 NaClProcessManager.prototype.log = function (msg) { | 496 NaClProcessManager.prototype.log = function (msg) { |
| 496 if (this.debug) { | 497 if (this.debug) { |
| 497 console.log(msg); | 498 console.log(msg); |
| 498 } | 499 } |
| 499 }; | 500 }; |
| 500 | 501 |
| 501 /** | 502 /** |
| 502 * Sync Mount status every time a mount/unmount message | 503 * Sync Mount status every time a mount/unmount message |
| 503 * is recieved from a process. | 504 * is recieved from a process. |
| 504 */ | 505 */ |
| 505 NaClProcessManager.prototype.syncMountStatus_ = function () { | 506 NaClProcessManager.prototype.syncMountStatus_ = function () { |
| 507 var self = this; |
| 506 var result = true; | 508 var result = true; |
| 507 | 509 |
| 508 if (g_mount.available) { | 510 if (g_mount.available) { |
| 509 Object.keys(this.processes).forEach(function (p) { | 511 Object.keys(self.processes).forEach(function (p) { |
| 510 result = (result && this.processes[p].mounted); | 512 result = (result && self.processes[p].mounted); |
| 511 }); | 513 }); |
| 512 } else { | 514 } else { |
| 513 result = false; | 515 result = false; |
| 514 Object.keys(this.processes).forEach(function (p) { | 516 Object.keys(self.processes).forEach(function (p) { |
| 515 result = (result || this.processes[p].mounted); | 517 result = (result || self.processes[p].mounted); |
| 516 }); | 518 }); |
| 517 } | 519 } |
| 518 | 520 |
| 519 g_mount.mounted = result; | 521 g_mount.mounted = result; |
| 520 if (this.mountUpdateCallback !== null) { | 522 if (self.mountUpdateCallback !== null) { |
| 521 this.mountUpdateCallback(); | 523 self.mountUpdateCallback(); |
| 522 } | 524 } |
| 523 return result; | 525 return result; |
| 524 }; | 526 }; |
| 525 | 527 |
| 526 /** | 528 /** |
| 527 * Makes the path in a NMF entry to fully specified path. | 529 * Makes the path in a NMF entry to fully specified path. |
| 528 * @private | 530 * @private |
| 529 */ | 531 */ |
| 530 NaClProcessManager.prototype.adjustNmfEntry_ = function (entry) { | 532 NaClProcessManager.prototype.adjustNmfEntry_ = function (entry) { |
| 531 Object.keys(entry).forEach(function (arch) { | 533 Object.keys(entry).forEach(function (arch) { |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 */ | 1492 */ |
| 1491 NaClProcessManager.prototype.sendStdinForeground = function (str) { | 1493 NaClProcessManager.prototype.sendStdinForeground = function (str) { |
| 1492 if (!this.foregroundProcess) { | 1494 if (!this.foregroundProcess) { |
| 1493 throw new Error(NaClProcessManager.NO_FG_ERROR); | 1495 throw new Error(NaClProcessManager.NO_FG_ERROR); |
| 1494 } | 1496 } |
| 1495 | 1497 |
| 1496 var message = {}; | 1498 var message = {}; |
| 1497 message[NaClProcessManager.prefix] = str; | 1499 message[NaClProcessManager.prefix] = str; |
| 1498 this.foregroundProcess.postMessage(message); | 1500 this.foregroundProcess.postMessage(message); |
| 1499 }; | 1501 }; |
| OLD | NEW |