Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1796 { | 1796 { |
| 1797 return this._targetObject; | 1797 return this._targetObject; |
| 1798 }, | 1798 }, |
| 1799 | 1799 |
| 1800 clear: function() | 1800 clear: function() |
| 1801 { | 1801 { |
| 1802 this._targetObject = null; | 1802 this._targetObject = null; |
| 1803 } | 1803 } |
| 1804 }; | 1804 }; |
| 1805 | 1805 |
| 1806 /** | |
| 1807 * @param {function()} callback | |
| 1808 */ | |
| 1809 window.setImmediate = (function() { | |
| 1810 var dummy = { foo: 0 }; | |
| 1811 var callbacks = []; | |
| 1812 Object.observe(dummy, dummyChanged); | |
|
yurys
2014/08/07 17:02:13
Wouldn't it be more straightforward with Promise b
| |
| 1813 | |
| 1814 function dummyChanged() | |
| 1815 { | |
| 1816 var cbList = callbacks.slice(); | |
| 1817 callbacks.length = 0; | |
| 1818 cbList.forEach(function(callback) { callback(); }); | |
| 1819 }; | |
| 1820 | |
| 1821 return function setImmediate(callback) { | |
| 1822 if (!callbacks.length) | |
| 1823 dummy.foo++; | |
| 1824 callbacks.push(callback); | |
| 1825 }; | |
| 1826 })(); | |
| OLD | NEW |