Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 get: $WeakMap.prototype.get, | 36 get: $WeakMap.prototype.get, |
| 37 has: $WeakMap.prototype.has | 37 has: $WeakMap.prototype.has |
| 38 } | 38 } |
| 39 | 39 |
| 40 function createInternalWeakMap() { | 40 function createInternalWeakMap() { |
| 41 var map = new $WeakMap; | 41 var map = new $WeakMap; |
| 42 map.__proto__ = InternalWeakMapProto; | 42 map.__proto__ = InternalWeakMapProto; |
| 43 return map; | 43 return map; |
| 44 } | 44 } |
| 45 | 45 |
| 46 var observerInfoMap = createInternalWeakMap(); | 46 var objectObservationState = %GetObjectObservationState(); |
| 47 var objectInfoMap = createInternalWeakMap(); | 47 if (IS_UNDEFINED(objectObservationState.observerInfoMap)) { |
| 48 objectObservationState.observerInfoMap = createInternalWeakMap(); | |
|
Michael Starzinger
2012/11/05 13:08:10
This will make the WeakMap instantiated in this co
| |
| 49 objectObservationState.objectInfoMap = createInternalWeakMap(); | |
| 50 } | |
| 51 var observerInfoMap = objectObservationState.observerInfoMap; | |
| 52 var objectInfoMap = objectObservationState.objectInfoMap; | |
| 48 | 53 |
| 49 function ObjectObserve(object, callback) { | 54 function ObjectObserve(object, callback) { |
| 50 if (!IS_SPEC_OBJECT(object)) | 55 if (!IS_SPEC_OBJECT(object)) |
| 51 throw MakeTypeError("observe_non_object", ["observe"]); | 56 throw MakeTypeError("observe_non_object", ["observe"]); |
| 52 if (!IS_SPEC_FUNCTION(callback)) | 57 if (!IS_SPEC_FUNCTION(callback)) |
| 53 throw MakeTypeError("observe_non_function", ["observe"]); | 58 throw MakeTypeError("observe_non_function", ["observe"]); |
| 54 if (InternalObjectIsFrozen(callback)) | 59 if (InternalObjectIsFrozen(callback)) |
| 55 throw MakeTypeError("observe_callback_frozen"); | 60 throw MakeTypeError("observe_callback_frozen"); |
| 56 | 61 |
| 57 if (!observerInfoMap.has(callback)) { | 62 if (!observerInfoMap.has(callback)) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 function SetupObjectObserve() { | 159 function SetupObjectObserve() { |
| 155 %CheckIsBootstrapping(); | 160 %CheckIsBootstrapping(); |
| 156 InstallFunctions($Object, DONT_ENUM, $Array( | 161 InstallFunctions($Object, DONT_ENUM, $Array( |
| 157 "deliverChangeRecords", ObjectDeliverChangeRecords, | 162 "deliverChangeRecords", ObjectDeliverChangeRecords, |
| 158 "notify", ObjectNotify, // TODO: Remove when getNotifier is implemented. | 163 "notify", ObjectNotify, // TODO: Remove when getNotifier is implemented. |
| 159 "observe", ObjectObserve, | 164 "observe", ObjectObserve, |
| 160 "unobserve", ObjectUnobserve | 165 "unobserve", ObjectUnobserve |
| 161 )); | 166 )); |
| 162 } | 167 } |
| 163 | 168 |
| 164 SetupObjectObserve(); | 169 SetupObjectObserve(); |
| OLD | NEW |