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

Side by Side Diff: src/debug/debug.cc

Issue 2628173005: [inspector] merged type and name of async task event (Closed)
Patch Set: addressed comments Created 3 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
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug.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 // 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/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 1675
1676 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, 1676 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
1677 v8::DebugEvent type) { 1677 v8::DebugEvent type) {
1678 // Create the compile event object. 1678 // Create the compile event object.
1679 Handle<Object> script_wrapper = Script::GetWrapper(script); 1679 Handle<Object> script_wrapper = Script::GetWrapper(script);
1680 Handle<Object> argv[] = { script_wrapper, 1680 Handle<Object> argv[] = { script_wrapper,
1681 isolate_->factory()->NewNumberFromInt(type) }; 1681 isolate_->factory()->NewNumberFromInt(type) };
1682 return CallFunction("MakeCompileEvent", arraysize(argv), argv); 1682 return CallFunction("MakeCompileEvent", arraysize(argv), argv);
1683 } 1683 }
1684 1684
1685 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<Smi> type, Handle<Smi> id, 1685 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<Smi> type,
1686 Handle<Smi> name) { 1686 Handle<Smi> id) {
1687 DCHECK(id->IsNumber()); 1687 DCHECK(id->IsNumber());
1688 // Create the async task event object. 1688 // Create the async task event object.
1689 Handle<Object> argv[] = {type, id, name}; 1689 Handle<Object> argv[] = {type, id};
1690 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv); 1690 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv);
1691 } 1691 }
1692 1692
1693 1693
1694 void Debug::OnThrow(Handle<Object> exception) { 1694 void Debug::OnThrow(Handle<Object> exception) {
1695 if (in_debug_scope() || ignore_events()) return; 1695 if (in_debug_scope() || ignore_events()) return;
1696 PrepareStepOnThrow(); 1696 PrepareStepOnThrow();
1697 // Temporarily clear any scheduled_exception to allow evaluating 1697 // Temporarily clear any scheduled_exception to allow evaluating
1698 // JavaScript from the debug event handler. 1698 // JavaScript from the debug event handler.
1699 HandleScope scope(isolate_); 1699 HandleScope scope(isolate_);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 CollectedCallbackData(Object** location, int id, Debug* debug, 1814 CollectedCallbackData(Object** location, int id, Debug* debug,
1815 Isolate* isolate) 1815 Isolate* isolate)
1816 : location(location), id(id), debug(debug), isolate(isolate) {} 1816 : location(location), id(id), debug(debug), isolate(isolate) {}
1817 }; 1817 };
1818 1818
1819 void SendAsyncTaskEventCancel(const v8::WeakCallbackInfo<void>& info) { 1819 void SendAsyncTaskEventCancel(const v8::WeakCallbackInfo<void>& info) {
1820 std::unique_ptr<CollectedCallbackData> data( 1820 std::unique_ptr<CollectedCallbackData> data(
1821 reinterpret_cast<CollectedCallbackData*>(info.GetParameter())); 1821 reinterpret_cast<CollectedCallbackData*>(info.GetParameter()));
1822 if (!data->debug->is_active()) return; 1822 if (!data->debug->is_active()) return;
1823 HandleScope scope(data->isolate); 1823 HandleScope scope(data->isolate);
1824 data->debug->OnAsyncTaskEvent(debug::kDebugCancel, data->id, 1824 data->debug->OnAsyncTaskEvent(debug::kDebugPromiseCollected, data->id);
1825 kDebugPromiseCollected);
1826 } 1825 }
1827 1826
1828 void ResetPromiseHandle(const v8::WeakCallbackInfo<void>& info) { 1827 void ResetPromiseHandle(const v8::WeakCallbackInfo<void>& info) {
1829 CollectedCallbackData* data = 1828 CollectedCallbackData* data =
1830 reinterpret_cast<CollectedCallbackData*>(info.GetParameter()); 1829 reinterpret_cast<CollectedCallbackData*>(info.GetParameter());
1831 GlobalHandles::Destroy(data->location); 1830 GlobalHandles::Destroy(data->location);
1832 info.SetSecondPassCallback(&SendAsyncTaskEventCancel); 1831 info.SetSecondPassCallback(&SendAsyncTaskEventCancel);
1833 } 1832 }
1834 } // namespace 1833 } // namespace
1835 1834
(...skipping 17 matching lines...) Expand all
1853 // Since we holding promise when at least one microtask is scheduled (inside 1852 // Since we holding promise when at least one microtask is scheduled (inside
1854 // PromiseReactionJobInfo), we can send cancel event in weak callback. 1853 // PromiseReactionJobInfo), we can send cancel event in weak callback.
1855 GlobalHandles::MakeWeak( 1854 GlobalHandles::MakeWeak(
1856 global_handle.location(), 1855 global_handle.location(),
1857 new CollectedCallbackData(global_handle.location(), async_id->value(), 1856 new CollectedCallbackData(global_handle.location(), async_id->value(),
1858 this, isolate_), 1857 this, isolate_),
1859 &ResetPromiseHandle, v8::WeakCallbackType::kParameter); 1858 &ResetPromiseHandle, v8::WeakCallbackType::kParameter);
1860 return async_id->value(); 1859 return async_id->value();
1861 } 1860 }
1862 1861
1863 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id, 1862 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) {
1864 PromiseDebugActionName name) {
1865 if (in_debug_scope() || ignore_events()) return; 1863 if (in_debug_scope() || ignore_events()) return;
1866 1864
1867 HandleScope scope(isolate_); 1865 HandleScope scope(isolate_);
1868 DebugScope debug_scope(this); 1866 DebugScope debug_scope(this);
1869 if (debug_scope.failed()) return; 1867 if (debug_scope.failed()) return;
1870 1868
1871 // Create the script collected state object. 1869 // Create the script collected state object.
1872 Handle<Object> event_data; 1870 Handle<Object> event_data;
1873 // Bail out and don't call debugger if exception. 1871 // Bail out and don't call debugger if exception.
1874 if (!MakeAsyncTaskEvent(handle(Smi::FromInt(type), isolate_), 1872 if (!MakeAsyncTaskEvent(handle(Smi::FromInt(type), isolate_),
1875 handle(Smi::FromInt(id), isolate_), 1873 handle(Smi::FromInt(id), isolate_))
1876 handle(Smi::FromInt(name), isolate_))
1877 .ToHandle(&event_data)) 1874 .ToHandle(&event_data))
1878 return; 1875 return;
1879 1876
1880 // Process debug event. 1877 // Process debug event.
1881 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data), 1878 ProcessDebugEvent(v8::AsyncTaskEvent, Handle<JSObject>::cast(event_data),
1882 true); 1879 true);
1883 } 1880 }
1884 1881
1885 void Debug::ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data, 1882 void Debug::ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data,
1886 bool auto_continue) { 1883 bool auto_continue) {
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 logger_->DebugEvent("Put", message.text()); 2625 logger_->DebugEvent("Put", message.text());
2629 } 2626 }
2630 2627
2631 void LockingCommandMessageQueue::Clear() { 2628 void LockingCommandMessageQueue::Clear() {
2632 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2629 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2633 queue_.Clear(); 2630 queue_.Clear();
2634 } 2631 }
2635 2632
2636 } // namespace internal 2633 } // namespace internal
2637 } // namespace v8 2634 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698