OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/inspector/v8-console.h" | 5 #include "src/inspector/v8-console.h" |
6 | 6 |
7 #include "src/base/macros.h" | 7 #include "src/base/macros.h" |
8 #include "src/inspector/injected-script.h" | 8 #include "src/inspector/injected-script.h" |
9 #include "src/inspector/inspected-context.h" | 9 #include "src/inspector/inspected-context.h" |
10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace v8_inspector { | 22 namespace v8_inspector { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 v8::Local<v8::Private> inspectedContextPrivateKey(v8::Isolate* isolate) { | 26 v8::Local<v8::Private> inspectedContextPrivateKey(v8::Isolate* isolate) { |
27 return v8::Private::ForApi( | 27 return v8::Private::ForApi( |
28 isolate, toV8StringInternalized(isolate, "V8Console#InspectedContext")); | 28 isolate, toV8StringInternalized(isolate, "V8Console#InspectedContext")); |
29 } | 29 } |
30 | 30 |
31 class ConsoleHelper { | 31 class ConsoleHelper { |
32 DISALLOW_COPY_AND_ASSIGN(ConsoleHelper); | |
33 | |
34 public: | 32 public: |
35 ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info) | 33 explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info) |
36 : m_info(info), | 34 : m_info(info), |
37 m_isolate(info.GetIsolate()), | 35 m_isolate(info.GetIsolate()), |
38 m_context(info.GetIsolate()->GetCurrentContext()), | 36 m_context(info.GetIsolate()->GetCurrentContext()), |
39 m_inspectedContext(nullptr), | 37 m_inspectedContext(nullptr), |
40 m_inspectorClient(nullptr) {} | 38 m_inspectorClient(nullptr) {} |
41 | 39 |
42 v8::Local<v8::Object> ensureConsole() { | 40 v8::Local<v8::Object> ensureConsole() { |
43 if (m_console.IsEmpty()) { | 41 if (m_console.IsEmpty()) { |
44 DCHECK(!m_info.Data().IsEmpty()); | 42 DCHECK(!m_info.Data().IsEmpty()); |
45 DCHECK(!m_info.Data()->IsUndefined()); | 43 DCHECK(!m_info.Data()->IsUndefined()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 DCHECK(flagValue->IsUndefined() || flagValue->IsBoolean()); | 232 DCHECK(flagValue->IsUndefined() || flagValue->IsBoolean()); |
235 if (flagValue->IsBoolean()) { | 233 if (flagValue->IsBoolean()) { |
236 DCHECK(flagValue.As<v8::Boolean>()->Value()); | 234 DCHECK(flagValue.As<v8::Boolean>()->Value()); |
237 return true; | 235 return true; |
238 } | 236 } |
239 if (!console->SetPrivate(m_context, key, v8::True(m_isolate)) | 237 if (!console->SetPrivate(m_context, key, v8::True(m_isolate)) |
240 .FromMaybe(false)) | 238 .FromMaybe(false)) |
241 return defaultValue; | 239 return defaultValue; |
242 return false; | 240 return false; |
243 } | 241 } |
| 242 |
| 243 DISALLOW_COPY_AND_ASSIGN(ConsoleHelper); |
244 }; | 244 }; |
245 | 245 |
246 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 246 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { |
247 info.GetReturnValue().Set(info.Data()); | 247 info.GetReturnValue().Set(info.Data()); |
248 } | 248 } |
249 | 249 |
250 void createBoundFunctionProperty(v8::Local<v8::Context> context, | 250 void createBoundFunctionProperty(v8::Local<v8::Context> context, |
251 v8::Local<v8::Object> console, | 251 v8::Local<v8::Object> console, |
252 const char* name, | 252 const char* name, |
253 v8::FunctionCallback callback, | 253 v8::FunctionCallback callback, |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 ->GetOwnPropertyDescriptor( | 908 ->GetOwnPropertyDescriptor( |
909 m_context, v8::Local<v8::String>::Cast(name)) | 909 m_context, v8::Local<v8::String>::Cast(name)) |
910 .ToLocal(&descriptor); | 910 .ToLocal(&descriptor); |
911 DCHECK(success); | 911 DCHECK(success); |
912 USE(success); | 912 USE(success); |
913 } | 913 } |
914 } | 914 } |
915 } | 915 } |
916 | 916 |
917 } // namespace v8_inspector | 917 } // namespace v8_inspector |
OLD | NEW |