Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Side by Side Diff: src/object-observe.js

Issue 12183018: Create pre-frozen change records for Object.observe (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 observationState.pendingObservers[observerInfo.priority] = observer; 123 observationState.pendingObservers[observerInfo.priority] = observer;
124 %SetObserverDeliveryPending(); 124 %SetObserverDeliveryPending();
125 if (IS_NULL(observerInfo.pendingChangeRecords)) { 125 if (IS_NULL(observerInfo.pendingChangeRecords)) {
126 observerInfo.pendingChangeRecords = new InternalArray(changeRecord); 126 observerInfo.pendingChangeRecords = new InternalArray(changeRecord);
127 } else { 127 } else {
128 observerInfo.pendingChangeRecords.push(changeRecord); 128 observerInfo.pendingChangeRecords.push(changeRecord);
129 } 129 }
130 } 130 }
131 } 131 }
132 132
133 function NotifyChange(type, object, name, oldValue) { 133 function NotifyChange(changeRecord) {
134 var objectInfo = objectInfoMap.get(object); 134 var objectInfo = objectInfoMap.get(changeRecord.object);
135 var changeRecord = (arguments.length < 4) ?
136 { type: type, object: object, name: name } :
137 { type: type, object: object, name: name, oldValue: oldValue };
138 ObjectFreeze(changeRecord);
139 EnqueueChangeRecord(changeRecord, objectInfo.changeObservers); 135 EnqueueChangeRecord(changeRecord, objectInfo.changeObservers);
140 } 136 }
141 137
142 var notifierPrototype = {}; 138 var notifierPrototype = {};
143 139
144 function ObjectNotifierNotify(changeRecord) { 140 function ObjectNotifierNotify(changeRecord) {
145 if (!IS_SPEC_OBJECT(this)) 141 if (!IS_SPEC_OBJECT(this))
146 throw MakeTypeError("called_on_non_object", ["notify"]); 142 throw MakeTypeError("called_on_non_object", ["notify"]);
147 143
148 var target = notifierTargetMap.get(this); 144 var target = notifierTargetMap.get(this);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 "getNotifier", ObjectGetNotifier, 222 "getNotifier", ObjectGetNotifier,
227 "observe", ObjectObserve, 223 "observe", ObjectObserve,
228 "unobserve", ObjectUnobserve 224 "unobserve", ObjectUnobserve
229 )); 225 ));
230 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 226 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
231 "notify", ObjectNotifierNotify 227 "notify", ObjectNotifierNotify
232 )); 228 ));
233 } 229 }
234 230
235 SetupObjectObserve(); 231 SetupObjectObserve();
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698