OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 function onMessage(event) | 51 function onMessage(event) |
52 { | 52 { |
53 console.assert(event.data === "workerReady"); | 53 console.assert(event.data === "workerReady"); |
54 this._worker.onmessage = null; | 54 this._worker.onmessage = null; |
55 fulfill(this._worker); | 55 fulfill(this._worker); |
56 // No need to hold a reference to worker anymore as it's stored in | 56 // No need to hold a reference to worker anymore as it's stored in |
57 // the resolved promise. | 57 // the resolved promise. |
58 this._worker = null; | 58 this._worker = null; |
59 } | 59 } |
60 }); | 60 }); |
61 } | 61 }; |
62 | 62 |
63 WebInspector.Worker.prototype = { | 63 WebInspector.Worker.prototype = { |
64 /** | 64 /** |
65 * @param {*} message | 65 * @param {*} message |
66 */ | 66 */ |
67 postMessage: function(message) | 67 postMessage: function(message) |
68 { | 68 { |
69 this._workerPromise.then(worker => { | 69 this._workerPromise.then(worker => { |
70 if (!this._disposed) | 70 if (!this._disposed) |
71 worker.postMessage(message); | 71 worker.postMessage(message); |
(...skipping 19 matching lines...) Expand all Loading... |
91 this._workerPromise.then(worker => worker.onmessage = listener); | 91 this._workerPromise.then(worker => worker.onmessage = listener); |
92 }, | 92 }, |
93 | 93 |
94 /** | 94 /** |
95 * @param {?function(!Event)} listener | 95 * @param {?function(!Event)} listener |
96 */ | 96 */ |
97 set onerror(listener) | 97 set onerror(listener) |
98 { | 98 { |
99 this._workerPromise.then(worker => worker.onerror = listener); | 99 this._workerPromise.then(worker => worker.onerror = listener); |
100 } | 100 } |
101 } | 101 }; |
OLD | NEW |