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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp

Issue 2001893002: DevTools: expose raw pointers in protocol collections, s/ASSERT/DCHECK/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/InjectedScript.h" 8 #include "platform/v8_inspector/InjectedScript.h"
9 #include "platform/v8_inspector/InspectedContext.h" 9 #include "platform/v8_inspector/InspectedContext.h"
10 #include "platform/v8_inspector/V8Compat.h" 10 #include "platform/v8_inspector/V8Compat.h"
(...skipping 25 matching lines...) Expand all
36 , m_isolate(info.GetIsolate()) 36 , m_isolate(info.GetIsolate())
37 , m_context(info.GetIsolate()->GetCurrentContext()) 37 , m_context(info.GetIsolate()->GetCurrentContext())
38 , m_inspectedContext(nullptr) 38 , m_inspectedContext(nullptr)
39 , m_debuggerClient(nullptr) 39 , m_debuggerClient(nullptr)
40 { 40 {
41 } 41 }
42 42
43 v8::Local<v8::Object> ensureConsole() 43 v8::Local<v8::Object> ensureConsole()
44 { 44 {
45 if (m_console.IsEmpty()) { 45 if (m_console.IsEmpty()) {
46 ASSERT(!m_info.Data().IsEmpty()); 46 DCHECK(!m_info.Data().IsEmpty());
47 ASSERT(!m_info.Data()->IsUndefined()); 47 DCHECK(!m_info.Data()->IsUndefined());
48 m_console = m_info.Data().As<v8::Object>(); 48 m_console = m_info.Data().As<v8::Object>();
49 } 49 }
50 return m_console; 50 return m_console;
51 } 51 }
52 52
53 InspectedContext* ensureInspectedContext() 53 InspectedContext* ensureInspectedContext()
54 { 54 {
55 if (m_inspectedContext) 55 if (m_inspectedContext)
56 return m_inspectedContext; 56 return m_inspectedContext;
57 v8::Local<v8::Object> console = ensureConsole(); 57 v8::Local<v8::Object> console = ensureConsole();
58 58
59 v8::Local<v8::Private> key = inspectedContextPrivateKey(m_isolate); 59 v8::Local<v8::Private> key = inspectedContextPrivateKey(m_isolate);
60 v8::Local<v8::Value> inspectedContextValue; 60 v8::Local<v8::Value> inspectedContextValue;
61 if (!console->GetPrivate(m_context, key).ToLocal(&inspectedContextValue) ) 61 if (!console->GetPrivate(m_context, key).ToLocal(&inspectedContextValue) )
62 return nullptr; 62 return nullptr;
63 ASSERT(inspectedContextValue->IsExternal()); 63 DCHECK(inspectedContextValue->IsExternal());
64 m_inspectedContext = static_cast<InspectedContext*>(inspectedContextValu e.As<v8::External>()->Value()); 64 m_inspectedContext = static_cast<InspectedContext*>(inspectedContextValu e.As<v8::External>()->Value());
65 return m_inspectedContext; 65 return m_inspectedContext;
66 } 66 }
67 67
68 V8DebuggerClient* ensureDebuggerClient() 68 V8DebuggerClient* ensureDebuggerClient()
69 { 69 {
70 if (m_debuggerClient) 70 if (m_debuggerClient)
71 return m_debuggerClient; 71 return m_debuggerClient;
72 InspectedContext* inspectedContext = ensureInspectedContext(); 72 InspectedContext* inspectedContext = ensureInspectedContext();
73 if (!inspectedContext) 73 if (!inspectedContext)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 InspectedContext* m_inspectedContext; 222 InspectedContext* m_inspectedContext;
223 V8DebuggerClient* m_debuggerClient; 223 V8DebuggerClient* m_debuggerClient;
224 224
225 bool checkAndSetPrivateFlagOnConsole(const char* name, bool defaultValue) 225 bool checkAndSetPrivateFlagOnConsole(const char* name, bool defaultValue)
226 { 226 {
227 v8::Local<v8::Object> console = ensureConsole(); 227 v8::Local<v8::Object> console = ensureConsole();
228 v8::Local<v8::Private> key = v8::Private::ForApi(m_isolate, toV8StringIn ternalized(m_isolate, name)); 228 v8::Local<v8::Private> key = v8::Private::ForApi(m_isolate, toV8StringIn ternalized(m_isolate, name));
229 v8::Local<v8::Value> flagValue; 229 v8::Local<v8::Value> flagValue;
230 if (!console->GetPrivate(m_context, key).ToLocal(&flagValue)) 230 if (!console->GetPrivate(m_context, key).ToLocal(&flagValue))
231 return defaultValue; 231 return defaultValue;
232 ASSERT(flagValue->IsUndefined() || flagValue->IsBoolean()); 232 DCHECK(flagValue->IsUndefined() || flagValue->IsBoolean());
233 if (flagValue->IsBoolean()) { 233 if (flagValue->IsBoolean()) {
234 ASSERT(flagValue.As<v8::Boolean>()->Value()); 234 DCHECK(flagValue.As<v8::Boolean>()->Value());
235 return true; 235 return true;
236 } 236 }
237 if (!console->SetPrivate(m_context, key, v8::True(m_isolate)).FromMaybe( false)) 237 if (!console->SetPrivate(m_context, key, v8::True(m_isolate)).FromMaybe( false))
238 return defaultValue; 238 return defaultValue;
239 return false; 239 return false;
240 } 240 }
241 }; 241 };
242 242
243 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 243 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
244 { 244 {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 inspectImpl(info, false); 605 inspectImpl(info, false);
606 } 606 }
607 607
608 void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 608 void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
609 { 609 {
610 inspectImpl(info, true); 610 inspectImpl(info, true);
611 } 611 }
612 612
613 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, unsigned num) 613 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, unsigned num)
614 { 614 {
615 ASSERT(num < V8InspectorSessionImpl::kInspectedObjectBufferSize); 615 DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize);
616 ConsoleHelper helper(info); 616 ConsoleHelper helper(info);
617 if (V8InspectorSessionImpl* session = helper.currentSession()) { 617 if (V8InspectorSessionImpl* session = helper.currentSession()) {
618 V8InspectorSession::Inspectable* object = session->inspectedObject(num); 618 V8InspectorSession::Inspectable* object = session->inspectedObject(num);
619 v8::Isolate* isolate = info.GetIsolate(); 619 v8::Isolate* isolate = info.GetIsolate();
620 if (object) 620 if (object)
621 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ; 621 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())) ;
622 else 622 else
623 info.GetReturnValue().Set(v8::Undefined(isolate)); 623 info.GetReturnValue().Set(v8::Undefined(isolate));
624 } 624 }
625 } 625 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); 726 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ());
727 if (getters.size() == 0) { 727 if (getters.size() == 0) {
728 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; 728 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" };
729 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) 729 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i)
730 getters.add(members[i]); 730 getters.add(members[i]);
731 } 731 }
732 return getters.find(name) != getters.end(); 732 return getters.find(name) != getters.end();
733 } 733 }
734 734
735 } // namespace blink 735 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698