| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 "platform/v8_inspector/V8Console.h" | 5 #include "platform/v8_inspector/V8Console.h" |
| 6 | 6 |
| 7 #include "platform/inspector_protocol/Platform.h" | 7 #include "platform/inspector_protocol/Platform.h" |
| 8 #include "platform/inspector_protocol/String16.h" | 8 #include "platform/inspector_protocol/String16.h" |
| 9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
| 10 #include "platform/v8_inspector/InspectedContext.h" | 10 #include "platform/v8_inspector/InspectedContext.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 std::vector<v8::Local<v8::Value>> arguments; | 91 std::vector<v8::Local<v8::Value>> arguments; |
| 92 for (int i = 0; i < m_info.Length(); ++i) | 92 for (int i = 0; i < m_info.Length(); ++i) |
| 93 arguments.push_back(m_info[i]); | 93 arguments.push_back(m_info[i]); |
| 94 if (!m_info.Length()) | 94 if (!m_info.Length()) |
| 95 arguments.push_back(toV8String(m_isolate, message)); | 95 arguments.push_back(toV8String(m_isolate, message)); |
| 96 reportCall(type, arguments); | 96 reportCall(type, arguments); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void reportCallWithArgument(ConsoleAPIType type, const String16& message) | 99 void reportCallWithArgument(ConsoleAPIType type, const String16& message) |
| 100 { | 100 { |
| 101 std::vector<v8::Local<v8::Value>> arguments = { toV8String(m_isolate, me
ssage) }; | 101 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes
sage)); |
| 102 reportCall(type, arguments); | 102 reportCall(type, arguments); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void reportCall(ConsoleAPIType type, const std::vector<v8::Local<v8::Value>>
& arguments) | 105 void reportCall(ConsoleAPIType type, const std::vector<v8::Local<v8::Value>>
& arguments) |
| 106 { | 106 { |
| 107 InspectedContext* inspectedContext = ensureInspectedContext(); | 107 InspectedContext* inspectedContext = ensureInspectedContext(); |
| 108 if (!inspectedContext) | 108 if (!inspectedContext) |
| 109 return; | 109 return; |
| 110 V8DebuggerImpl* debugger = inspectedContext->debugger(); | 110 V8DebuggerImpl* debugger = inspectedContext->debugger(); |
| 111 std::unique_ptr<V8ConsoleMessage> message = V8ConsoleMessage::createForC
onsoleAPI(debugger->client()->currentTimeMS(), type, arguments, debugger->captur
eStackTrace(false), inspectedContext); | 111 std::unique_ptr<V8ConsoleMessage> message = V8ConsoleMessage::createForC
onsoleAPI(debugger->client()->currentTimeMS(), type, arguments, debugger->captur
eStackTrace(false), inspectedContext); |
| 112 debugger->ensureConsoleMessageStorage(inspectedContext->contextGroupId()
)->addMessage(std::move(message)); | 112 debugger->ensureConsoleMessageStorage(inspectedContext->contextGroupId()
)->addMessage(std::move(message)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void reportDeprecatedCall(const char* id, const String16& message) | 115 void reportDeprecatedCall(const char* id, const String16& message) |
| 116 { | 116 { |
| 117 if (checkAndSetPrivateFlagOnConsole(id, false)) | 117 if (checkAndSetPrivateFlagOnConsole(id, false)) |
| 118 return; | 118 return; |
| 119 std::vector<v8::Local<v8::Value>> arguments = { toV8String(m_isolate, me
ssage) }; | 119 std::vector<v8::Local<v8::Value>> arguments(1, toV8String(m_isolate, mes
sage)); |
| 120 reportCall(ConsoleAPIType::kWarning, arguments); | 120 reportCall(ConsoleAPIType::kWarning, arguments); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool firstArgToBoolean(bool defaultValue) | 123 bool firstArgToBoolean(bool defaultValue) |
| 124 { | 124 { |
| 125 if (m_info.Length() < 1) | 125 if (m_info.Length() < 1) |
| 126 return defaultValue; | 126 return defaultValue; |
| 127 if (m_info[0]->IsBoolean()) | 127 if (m_info[0]->IsBoolean()) |
| 128 return m_info[0].As<v8::Boolean>()->Value(); | 128 return m_info[0].As<v8::Boolean>()->Value(); |
| 129 return m_info[0]->BooleanValue(m_context).FromMaybe(defaultValue); | 129 return m_info[0]->BooleanValue(m_context).FromMaybe(defaultValue); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 continue; | 822 continue; |
| 823 if (name->IsString()) { | 823 if (name->IsString()) { |
| 824 v8::Local<v8::Value> descriptor; | 824 v8::Local<v8::Value> descriptor; |
| 825 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc
al<v8::String>::Cast(name)).ToLocal(&descriptor); | 825 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc
al<v8::String>::Cast(name)).ToLocal(&descriptor); |
| 826 DCHECK(success); | 826 DCHECK(success); |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 | 830 |
| 831 } // namespace blink | 831 } // namespace blink |
| OLD | NEW |