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

Side by Side Diff: src/isolate.cc

Issue 1689863002: Introduce BeforeCallEnteredCallback. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed review comments Created 4 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
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 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 2601
2602 SetUpSubregistry(registry, map, "for"); 2602 SetUpSubregistry(registry, map, "for");
2603 SetUpSubregistry(registry, map, "for_api"); 2603 SetUpSubregistry(registry, map, "for_api");
2604 SetUpSubregistry(registry, map, "keyFor"); 2604 SetUpSubregistry(registry, map, "keyFor");
2605 SetUpSubregistry(registry, map, "private_api"); 2605 SetUpSubregistry(registry, map, "private_api");
2606 } 2606 }
2607 return Handle<JSObject>::cast(factory()->symbol_registry()); 2607 return Handle<JSObject>::cast(factory()->symbol_registry());
2608 } 2608 }
2609 2609
2610 2610
2611 void Isolate::AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback) {
2612 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
2613 if (callback == before_call_entered_callbacks_.at(i)) return;
2614 }
2615 before_call_entered_callbacks_.Add(callback);
2616 }
2617
2618
2619 void Isolate::RemoveBeforeCallEnteredCallback(
2620 BeforeCallEnteredCallback callback) {
2621 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
2622 if (callback == before_call_entered_callbacks_.at(i)) {
2623 before_call_entered_callbacks_.Remove(i);
2624 }
2625 }
2626 }
2627
2628
2629 void Isolate::FireBeforeCallEnteredCallback() {
2630 for (int i = 0; i < before_call_entered_callbacks_.length(); i++) {
2631 before_call_entered_callbacks_.at(i)(reinterpret_cast<v8::Isolate*>(this));
2632 }
2633 }
2634
2635
2611 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { 2636 void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) {
2612 for (int i = 0; i < call_completed_callbacks_.length(); i++) { 2637 for (int i = 0; i < call_completed_callbacks_.length(); i++) {
2613 if (callback == call_completed_callbacks_.at(i)) return; 2638 if (callback == call_completed_callbacks_.at(i)) return;
2614 } 2639 }
2615 call_completed_callbacks_.Add(callback); 2640 call_completed_callbacks_.Add(callback);
2616 } 2641 }
2617 2642
2618 2643
2619 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { 2644 void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) {
2620 for (int i = 0; i < call_completed_callbacks_.length(); i++) { 2645 for (int i = 0; i < call_completed_callbacks_.length(); i++) {
2621 if (callback == call_completed_callbacks_.at(i)) { 2646 if (callback == call_completed_callbacks_.at(i)) {
2622 call_completed_callbacks_.Remove(i); 2647 call_completed_callbacks_.Remove(i);
2623 } 2648 }
2624 } 2649 }
2625 } 2650 }
2626 2651
2627 2652
2628 void Isolate::FireCallCompletedCallback() { 2653 void Isolate::FireCallCompletedCallback() {
2629 bool has_call_completed_callbacks = !call_completed_callbacks_.is_empty(); 2654 bool has_call_completed_callbacks = !call_completed_callbacks_.is_empty();
2630 bool run_microtasks = autorun_microtasks() && pending_microtask_count(); 2655 bool run_microtasks = autorun_microtasks() && pending_microtask_count();
2631 if (!has_call_completed_callbacks && !run_microtasks) return; 2656 if (!has_call_completed_callbacks && !run_microtasks) return;
2632 2657
2633 if (!handle_scope_implementer()->CallDepthIsZero()) return; 2658 if (!handle_scope_implementer()->CallDepthIsZero()) return;
2634 if (run_microtasks) RunMicrotasks(); 2659 if (run_microtasks) RunMicrotasks();
2635 // Fire callbacks. Increase call depth to prevent recursive callbacks. 2660 // Fire callbacks. Increase call depth to prevent recursive callbacks.
2636 v8::Isolate::SuppressMicrotaskExecutionScope suppress( 2661 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this);
2637 reinterpret_cast<v8::Isolate*>(this)); 2662 v8::Isolate::SuppressMicrotaskExecutionScope suppress(isolate);
2638 for (int i = 0; i < call_completed_callbacks_.length(); i++) { 2663 for (int i = 0; i < call_completed_callbacks_.length(); i++) {
2639 call_completed_callbacks_.at(i)(); 2664 call_completed_callbacks_.at(i)(isolate);
2640 } 2665 }
2641 } 2666 }
2642 2667
2643 2668
2644 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { 2669 void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
2645 promise_reject_callback_ = callback; 2670 promise_reject_callback_ = callback;
2646 } 2671 }
2647 2672
2648 2673
2649 void Isolate::ReportPromiseReject(Handle<JSObject> promise, 2674 void Isolate::ReportPromiseReject(Handle<JSObject> promise,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 // Then check whether this scope intercepts. 2882 // Then check whether this scope intercepts.
2858 if ((flag & intercept_mask_)) { 2883 if ((flag & intercept_mask_)) {
2859 intercepted_flags_ |= flag; 2884 intercepted_flags_ |= flag;
2860 return true; 2885 return true;
2861 } 2886 }
2862 return false; 2887 return false;
2863 } 2888 }
2864 2889
2865 } // namespace internal 2890 } // namespace internal
2866 } // namespace v8 2891 } // namespace v8
OLDNEW
« include/v8.h ('K') | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698