OLD | NEW |
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 3622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3633 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 3633 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
3634 } | 3634 } |
3635 | 3635 |
3636 | 3636 |
3637 v8::Handle<v8::Object> MessageImpl::GetEventData() const { | 3637 v8::Handle<v8::Object> MessageImpl::GetEventData() const { |
3638 return v8::Utils::ToLocal(event_data_); | 3638 return v8::Utils::ToLocal(event_data_); |
3639 } | 3639 } |
3640 | 3640 |
3641 | 3641 |
3642 v8::Handle<v8::String> MessageImpl::GetJSON() const { | 3642 v8::Handle<v8::String> MessageImpl::GetJSON() const { |
3643 v8::HandleScope scope( | 3643 v8::EscapableHandleScope scope( |
3644 reinterpret_cast<v8::Isolate*>(event_data_->GetIsolate())); | 3644 reinterpret_cast<v8::Isolate*>(event_data_->GetIsolate())); |
3645 | 3645 |
3646 if (IsEvent()) { | 3646 if (IsEvent()) { |
3647 // Call toJSONProtocol on the debug event object. | 3647 // Call toJSONProtocol on the debug event object. |
3648 Handle<Object> fun = GetProperty(event_data_, "toJSONProtocol"); | 3648 Handle<Object> fun = GetProperty(event_data_, "toJSONProtocol"); |
3649 if (!fun->IsJSFunction()) { | 3649 if (!fun->IsJSFunction()) { |
3650 return v8::Handle<v8::String>(); | 3650 return v8::Handle<v8::String>(); |
3651 } | 3651 } |
3652 bool caught_exception; | 3652 bool caught_exception; |
3653 Handle<Object> json = Execution::TryCall(Handle<JSFunction>::cast(fun), | 3653 Handle<Object> json = Execution::TryCall(Handle<JSFunction>::cast(fun), |
3654 event_data_, | 3654 event_data_, |
3655 0, NULL, &caught_exception); | 3655 0, NULL, &caught_exception); |
3656 if (caught_exception || !json->IsString()) { | 3656 if (caught_exception || !json->IsString()) { |
3657 return v8::Handle<v8::String>(); | 3657 return v8::Handle<v8::String>(); |
3658 } | 3658 } |
3659 return scope.Close(v8::Utils::ToLocal(Handle<String>::cast(json))); | 3659 return scope.Escape(v8::Utils::ToLocal(Handle<String>::cast(json))); |
3660 } else { | 3660 } else { |
3661 return v8::Utils::ToLocal(response_json_); | 3661 return v8::Utils::ToLocal(response_json_); |
3662 } | 3662 } |
3663 } | 3663 } |
3664 | 3664 |
3665 | 3665 |
3666 v8::Handle<v8::Context> MessageImpl::GetEventContext() const { | 3666 v8::Handle<v8::Context> MessageImpl::GetEventContext() const { |
3667 Isolate* isolate = event_data_->GetIsolate(); | 3667 Isolate* isolate = event_data_->GetIsolate(); |
3668 v8::Handle<v8::Context> context = GetDebugEventContext(isolate); | 3668 v8::Handle<v8::Context> context = GetDebugEventContext(isolate); |
3669 // Isolate::context() may be NULL when "script collected" event occures. | 3669 // Isolate::context() may be NULL when "script collected" event occures. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3854 { | 3854 { |
3855 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3855 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3856 isolate_->debugger()->CallMessageDispatchHandler(); | 3856 isolate_->debugger()->CallMessageDispatchHandler(); |
3857 } | 3857 } |
3858 } | 3858 } |
3859 } | 3859 } |
3860 | 3860 |
3861 #endif // ENABLE_DEBUGGER_SUPPORT | 3861 #endif // ENABLE_DEBUGGER_SUPPORT |
3862 | 3862 |
3863 } } // namespace v8::internal | 3863 } } // namespace v8::internal |
OLD | NEW |