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

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

Issue 1122033002: Migrate error messages, part 7. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « src/messages.js ('k') | src/runtime/runtime-internal.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $observeNotifyChange; 5 var $observeNotifyChange;
6 var $observeEnqueueSpliceRecord; 6 var $observeEnqueueSpliceRecord;
7 var $observeBeginPerformSplice; 7 var $observeBeginPerformSplice;
8 var $observeEndPerformSplice; 8 var $observeEndPerformSplice;
9 var $observeNativeObjectObserve; 9 var $observeNativeObjectObserve;
10 var $observeNativeObjectGetNotifier; 10 var $observeNativeObjectGetNotifier;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 function ObjectInfoGetPerformingTypes(objectInfo) { 308 function ObjectInfoGetPerformingTypes(objectInfo) {
309 return objectInfo.performingCount > 0 ? objectInfo.performing : null; 309 return objectInfo.performingCount > 0 ? objectInfo.performing : null;
310 } 310 }
311 311
312 312
313 function ConvertAcceptListToTypeMap(arg) { 313 function ConvertAcceptListToTypeMap(arg) {
314 // We use undefined as a sentinel for the default accept list. 314 // We use undefined as a sentinel for the default accept list.
315 if (IS_UNDEFINED(arg)) 315 if (IS_UNDEFINED(arg))
316 return arg; 316 return arg;
317 317
318 if (!IS_SPEC_OBJECT(arg)) 318 if (!IS_SPEC_OBJECT(arg)) throw MakeTypeError(kObserveInvalidAccept);
319 throw MakeTypeError("observe_invalid_accept");
320 319
321 var len = ToInteger(arg.length); 320 var len = ToInteger(arg.length);
322 if (len < 0) len = 0; 321 if (len < 0) len = 0;
323 322
324 return TypeMapCreateFromList(arg, len); 323 return TypeMapCreateFromList(arg, len);
325 } 324 }
326 325
327 326
328 // CallbackInfo's optimized state is just a number which represents its global 327 // CallbackInfo's optimized state is just a number which represents its global
329 // priority. When a change record must be enqueued for the callback, it 328 // priority. When a change record must be enqueued for the callback, it
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 callbackInfo = new InternalArray; 364 callbackInfo = new InternalArray;
366 callbackInfo.priority = priority; 365 callbackInfo.priority = priority;
367 CallbackInfoSet(callback, callbackInfo); 366 CallbackInfoSet(callback, callbackInfo);
368 } 367 }
369 return callbackInfo; 368 return callbackInfo;
370 } 369 }
371 370
372 371
373 function ObjectObserve(object, callback, acceptList) { 372 function ObjectObserve(object, callback, acceptList) {
374 if (!IS_SPEC_OBJECT(object)) 373 if (!IS_SPEC_OBJECT(object))
375 throw MakeTypeError("observe_non_object", ["observe"]); 374 throw MakeTypeError(kObserveNonObject, "observe", "observe");
376 if (%IsJSGlobalProxy(object)) 375 if (%IsJSGlobalProxy(object))
377 throw MakeTypeError("observe_global_proxy", ["observe"]); 376 throw MakeTypeError(kObserveGlobalProxy, "observe");
378 if (!IS_SPEC_FUNCTION(callback)) 377 if (!IS_SPEC_FUNCTION(callback))
379 throw MakeTypeError("observe_non_function", ["observe"]); 378 throw MakeTypeError(kObserveNonFunction, "observe");
380 if (ObjectIsFrozen(callback)) 379 if (ObjectIsFrozen(callback))
381 throw MakeTypeError("observe_callback_frozen"); 380 throw MakeTypeError(kObserveCallbackFrozen);
382 381
383 var objectObserveFn = %GetObjectContextObjectObserve(object); 382 var objectObserveFn = %GetObjectContextObjectObserve(object);
384 return objectObserveFn(object, callback, acceptList); 383 return objectObserveFn(object, callback, acceptList);
385 } 384 }
386 385
387 386
388 function NativeObjectObserve(object, callback, acceptList) { 387 function NativeObjectObserve(object, callback, acceptList) {
389 var objectInfo = ObjectInfoGetOrCreate(object); 388 var objectInfo = ObjectInfoGetOrCreate(object);
390 var typeList = ConvertAcceptListToTypeMap(acceptList); 389 var typeList = ConvertAcceptListToTypeMap(acceptList);
391 ObjectInfoAddObserver(objectInfo, callback, typeList); 390 ObjectInfoAddObserver(objectInfo, callback, typeList);
392 return object; 391 return object;
393 } 392 }
394 393
395 394
396 function ObjectUnobserve(object, callback) { 395 function ObjectUnobserve(object, callback) {
397 if (!IS_SPEC_OBJECT(object)) 396 if (!IS_SPEC_OBJECT(object))
398 throw MakeTypeError("observe_non_object", ["unobserve"]); 397 throw MakeTypeError(kObserveNonObject, "unobserve", "unobserve");
399 if (%IsJSGlobalProxy(object)) 398 if (%IsJSGlobalProxy(object))
400 throw MakeTypeError("observe_global_proxy", ["unobserve"]); 399 throw MakeTypeError(kObserveGlobalProxy, "unobserve");
401 if (!IS_SPEC_FUNCTION(callback)) 400 if (!IS_SPEC_FUNCTION(callback))
402 throw MakeTypeError("observe_non_function", ["unobserve"]); 401 throw MakeTypeError(kObserveNonFunction, "unobserve");
403 402
404 var objectInfo = ObjectInfoGet(object); 403 var objectInfo = ObjectInfoGet(object);
405 if (IS_UNDEFINED(objectInfo)) 404 if (IS_UNDEFINED(objectInfo))
406 return object; 405 return object;
407 406
408 ObjectInfoRemoveObserver(objectInfo, callback); 407 ObjectInfoRemoveObserver(objectInfo, callback);
409 return object; 408 return object;
410 } 409 }
411 410
412 411
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); 550 ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
552 } 551 }
553 552
554 553
555 function ObjectNotifierNotify(changeRecord) { 554 function ObjectNotifierNotify(changeRecord) {
556 if (!IS_SPEC_OBJECT(this)) 555 if (!IS_SPEC_OBJECT(this))
557 throw MakeTypeError(kCalledOnNonObject, "notify"); 556 throw MakeTypeError(kCalledOnNonObject, "notify");
558 557
559 var objectInfo = ObjectInfoGetFromNotifier(this); 558 var objectInfo = ObjectInfoGetFromNotifier(this);
560 if (IS_UNDEFINED(objectInfo)) 559 if (IS_UNDEFINED(objectInfo))
561 throw MakeTypeError("observe_notify_non_notifier"); 560 throw MakeTypeError(kObserveNotifyNonNotifier);
562 if (!IS_STRING(changeRecord.type)) 561 if (!IS_STRING(changeRecord.type))
563 throw MakeTypeError("observe_type_non_string"); 562 throw MakeTypeError(kObserveTypeNonString);
564 563
565 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord); 564 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord);
566 } 565 }
567 566
568 567
569 function ObjectNotifierPerformChange(changeType, changeFn) { 568 function ObjectNotifierPerformChange(changeType, changeFn) {
570 if (!IS_SPEC_OBJECT(this)) 569 if (!IS_SPEC_OBJECT(this))
571 throw MakeTypeError(kCalledOnNonObject, "performChange"); 570 throw MakeTypeError(kCalledOnNonObject, "performChange");
572 571
573 var objectInfo = ObjectInfoGetFromNotifier(this); 572 var objectInfo = ObjectInfoGetFromNotifier(this);
574 if (IS_UNDEFINED(objectInfo)) 573 if (IS_UNDEFINED(objectInfo))
575 throw MakeTypeError("observe_notify_non_notifier"); 574 throw MakeTypeError(kObserveNotifyNonNotifier);
576 if (!IS_STRING(changeType)) 575 if (!IS_STRING(changeType))
577 throw MakeTypeError("observe_perform_non_string"); 576 throw MakeTypeError(kObservePerformNonString);
578 if (!IS_SPEC_FUNCTION(changeFn)) 577 if (!IS_SPEC_FUNCTION(changeFn))
579 throw MakeTypeError("observe_perform_non_function"); 578 throw MakeTypeError(kObservePerformNonFunction);
580 579
581 var performChangeFn = %GetObjectContextNotifierPerformChange(objectInfo); 580 var performChangeFn = %GetObjectContextNotifierPerformChange(objectInfo);
582 performChangeFn(objectInfo, changeType, changeFn); 581 performChangeFn(objectInfo, changeType, changeFn);
583 } 582 }
584 583
585 584
586 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) { 585 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) {
587 ObjectInfoAddPerformingType(objectInfo, changeType); 586 ObjectInfoAddPerformingType(objectInfo, changeType);
588 587
589 var changeRecord; 588 var changeRecord;
590 try { 589 try {
591 changeRecord = %_CallFunction(UNDEFINED, changeFn); 590 changeRecord = %_CallFunction(UNDEFINED, changeFn);
592 } finally { 591 } finally {
593 ObjectInfoRemovePerformingType(objectInfo, changeType); 592 ObjectInfoRemovePerformingType(objectInfo, changeType);
594 } 593 }
595 594
596 if (IS_SPEC_OBJECT(changeRecord)) 595 if (IS_SPEC_OBJECT(changeRecord))
597 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType); 596 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType);
598 } 597 }
599 598
600 599
601 function ObjectGetNotifier(object) { 600 function ObjectGetNotifier(object) {
602 if (!IS_SPEC_OBJECT(object)) 601 if (!IS_SPEC_OBJECT(object))
603 throw MakeTypeError("observe_non_object", ["getNotifier"]); 602 throw MakeTypeError(kObserveNonObject, "getNotifier", "getNotifier");
604 if (%IsJSGlobalProxy(object)) 603 if (%IsJSGlobalProxy(object))
605 throw MakeTypeError("observe_global_proxy", ["getNotifier"]); 604 throw MakeTypeError(kObserveGlobalProxy, "getNotifier");
606 605
607 if (ObjectIsFrozen(object)) return null; 606 if (ObjectIsFrozen(object)) return null;
608 607
609 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null; 608 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
610 609
611 var getNotifierFn = %GetObjectContextObjectGetNotifier(object); 610 var getNotifierFn = %GetObjectContextObjectGetNotifier(object);
612 return getNotifierFn(object); 611 return getNotifierFn(object);
613 } 612 }
614 613
615 614
(...skipping 21 matching lines...) Expand all
637 var delivered = []; 636 var delivered = [];
638 %MoveArrayContents(callbackInfo, delivered); 637 %MoveArrayContents(callbackInfo, delivered);
639 %DeliverObservationChangeRecords(callback, delivered); 638 %DeliverObservationChangeRecords(callback, delivered);
640 639
641 return true; 640 return true;
642 } 641 }
643 642
644 643
645 function ObjectDeliverChangeRecords(callback) { 644 function ObjectDeliverChangeRecords(callback) {
646 if (!IS_SPEC_FUNCTION(callback)) 645 if (!IS_SPEC_FUNCTION(callback))
647 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); 646 throw MakeTypeError(kObserveNonFunction, "deliverChangeRecords");
648 647
649 while (CallbackDeliverPending(callback)) {} 648 while (CallbackDeliverPending(callback)) {}
650 } 649 }
651 650
652 651
653 function ObserveMicrotaskRunner() { 652 function ObserveMicrotaskRunner() {
654 var pendingObservers = GetPendingObservers(); 653 var pendingObservers = GetPendingObservers();
655 if (!IS_NULL(pendingObservers)) { 654 if (!IS_NULL(pendingObservers)) {
656 SetPendingObservers(null); 655 SetPendingObservers(null);
657 for (var i in pendingObservers) { 656 for (var i in pendingObservers) {
(...skipping 21 matching lines...) Expand all
679 678
680 $observeNotifyChange = NotifyChange; 679 $observeNotifyChange = NotifyChange;
681 $observeEnqueueSpliceRecord = EnqueueSpliceRecord; 680 $observeEnqueueSpliceRecord = EnqueueSpliceRecord;
682 $observeBeginPerformSplice = BeginPerformSplice; 681 $observeBeginPerformSplice = BeginPerformSplice;
683 $observeEndPerformSplice = EndPerformSplice; 682 $observeEndPerformSplice = EndPerformSplice;
684 $observeNativeObjectObserve = NativeObjectObserve; 683 $observeNativeObjectObserve = NativeObjectObserve;
685 $observeNativeObjectGetNotifier = NativeObjectGetNotifier; 684 $observeNativeObjectGetNotifier = NativeObjectGetNotifier;
686 $observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange; 685 $observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange;
687 686
688 })(); 687 })();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698