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

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

Issue 154283002: V8 Microtask Queue & API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: heapconst Created 6 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/isolate.h ('k') | src/promise.js » ('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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 var callback = ObserverGetCallback(observer); 383 var callback = ObserverGetCallback(observer);
384 if (needsAccessCheck && 384 if (needsAccessCheck &&
385 // Drop all splice records on the floor for access-checked objects 385 // Drop all splice records on the floor for access-checked objects
386 (changeRecord.type == 'splice' || 386 (changeRecord.type == 'splice' ||
387 !%IsAccessAllowedForObserver( 387 !%IsAccessAllowedForObserver(
388 callback, changeRecord.object, changeRecord.name))) { 388 callback, changeRecord.object, changeRecord.name))) {
389 return; 389 return;
390 } 390 }
391 391
392 var callbackInfo = CallbackInfoNormalize(callback); 392 var callbackInfo = CallbackInfoNormalize(callback);
393 if (!observationState.pendingObservers) 393 if (IS_NULL(observationState.pendingObservers)) {
394 observationState.pendingObservers = nullProtoObject(); 394 observationState.pendingObservers = nullProtoObject();
395 GetMicrotaskQueue().push(ObserveMicrotaskRunner);
396 %SetMicrotaskPending(true);
397 }
395 observationState.pendingObservers[callbackInfo.priority] = callback; 398 observationState.pendingObservers[callbackInfo.priority] = callback;
396 callbackInfo.push(changeRecord); 399 callbackInfo.push(changeRecord);
397 %SetMicrotaskPending(true);
398 } 400 }
399 401
400 function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) { 402 function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) {
401 if (!ObjectInfoHasActiveObservers(objectInfo)) 403 if (!ObjectInfoHasActiveObservers(objectInfo))
402 return; 404 return;
403 405
404 var hasType = !IS_UNDEFINED(type); 406 var hasType = !IS_UNDEFINED(type);
405 var newRecord = hasType ? 407 var newRecord = hasType ?
406 { object: ObjectInfoGetObject(objectInfo), type: type } : 408 { object: ObjectInfoGetObject(objectInfo), type: type } :
407 { object: ObjectInfoGetObject(objectInfo) }; 409 { object: ObjectInfoGetObject(objectInfo) };
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 578
577 function ObserveMicrotaskRunner() { 579 function ObserveMicrotaskRunner() {
578 var pendingObservers = observationState.pendingObservers; 580 var pendingObservers = observationState.pendingObservers;
579 if (pendingObservers) { 581 if (pendingObservers) {
580 observationState.pendingObservers = null; 582 observationState.pendingObservers = null;
581 for (var i in pendingObservers) { 583 for (var i in pendingObservers) {
582 CallbackDeliverPending(pendingObservers[i]); 584 CallbackDeliverPending(pendingObservers[i]);
583 } 585 }
584 } 586 }
585 } 587 }
586 RunMicrotasks.runners.push(ObserveMicrotaskRunner);
587 588
588 function SetupObjectObserve() { 589 function SetupObjectObserve() {
589 %CheckIsBootstrapping(); 590 %CheckIsBootstrapping();
590 InstallFunctions($Object, DONT_ENUM, $Array( 591 InstallFunctions($Object, DONT_ENUM, $Array(
591 "deliverChangeRecords", ObjectDeliverChangeRecords, 592 "deliverChangeRecords", ObjectDeliverChangeRecords,
592 "getNotifier", ObjectGetNotifier, 593 "getNotifier", ObjectGetNotifier,
593 "observe", ObjectObserve, 594 "observe", ObjectObserve,
594 "unobserve", ObjectUnobserve 595 "unobserve", ObjectUnobserve
595 )); 596 ));
596 InstallFunctions($Array, DONT_ENUM, $Array( 597 InstallFunctions($Array, DONT_ENUM, $Array(
597 "observe", ArrayObserve, 598 "observe", ArrayObserve,
598 "unobserve", ArrayUnobserve 599 "unobserve", ArrayUnobserve
599 )); 600 ));
600 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 601 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
601 "notify", ObjectNotifierNotify, 602 "notify", ObjectNotifierNotify,
602 "performChange", ObjectNotifierPerformChange 603 "performChange", ObjectNotifierPerformChange
603 )); 604 ));
604 } 605 }
605 606
606 SetupObjectObserve(); 607 SetupObjectObserve();
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698