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

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

Issue 11802003: Add API for access checks on observed objects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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/messages.js ('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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 function ObjectObserve(object, callback) { 69 function ObjectObserve(object, callback) {
70 if (!IS_SPEC_OBJECT(object)) 70 if (!IS_SPEC_OBJECT(object))
71 throw MakeTypeError("observe_non_object", ["observe"]); 71 throw MakeTypeError("observe_non_object", ["observe"]);
72 if (!IS_SPEC_FUNCTION(callback)) 72 if (!IS_SPEC_FUNCTION(callback))
73 throw MakeTypeError("observe_non_function", ["observe"]); 73 throw MakeTypeError("observe_non_function", ["observe"]);
74 if (ObjectIsFrozen(callback)) 74 if (ObjectIsFrozen(callback))
75 throw MakeTypeError("observe_callback_frozen"); 75 throw MakeTypeError("observe_callback_frozen");
76 76
77 // Not part of the spec, but also not allowed
78 if (!%ObjectObserveAllowed(object))
79 throw MakeTypeError("observe_access_check_failed");
80
77 if (!observerInfoMap.has(callback)) { 81 if (!observerInfoMap.has(callback)) {
78 observerInfoMap.set(callback, { 82 observerInfoMap.set(callback, {
79 pendingChangeRecords: null, 83 pendingChangeRecords: null,
80 priority: observationState.observerPriority++, 84 priority: observationState.observerPriority++,
81 }); 85 });
82 } 86 }
83 87
84 var objectInfo = objectInfoMap.get(object); 88 var objectInfo = objectInfoMap.get(object);
85 if (IS_UNDEFINED(objectInfo)) objectInfo = CreateObjectInfo(object); 89 if (IS_UNDEFINED(objectInfo)) objectInfo = CreateObjectInfo(object);
86 %SetIsObserved(object, true); 90 %SetIsObserved(object, true);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 "getNotifier", ObjectGetNotifier, 225 "getNotifier", ObjectGetNotifier,
222 "observe", ObjectObserve, 226 "observe", ObjectObserve,
223 "unobserve", ObjectUnobserve 227 "unobserve", ObjectUnobserve
224 )); 228 ));
225 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 229 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
226 "notify", ObjectNotifierNotify 230 "notify", ObjectNotifierNotify
227 )); 231 ));
228 } 232 }
229 233
230 SetupObjectObserve(); 234 SetupObjectObserve();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698