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

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

Issue 2190353004: [DevTools] Replace InjectedScriptHost.suppressWarningsAndCallFunction with hasOwnProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void V8FunctionCall::appendArgument(int argument) 61 void V8FunctionCall::appendArgument(int argument)
62 { 62 {
63 m_arguments.push_back(v8::Number::New(m_context->GetIsolate(), argument)); 63 m_arguments.push_back(v8::Number::New(m_context->GetIsolate(), argument));
64 } 64 }
65 65
66 void V8FunctionCall::appendArgument(bool argument) 66 void V8FunctionCall::appendArgument(bool argument)
67 { 67 {
68 m_arguments.push_back(argument ? v8::True(m_context->GetIsolate()) : v8::Fal se(m_context->GetIsolate())); 68 m_arguments.push_back(argument ? v8::True(m_context->GetIsolate()) : v8::Fal se(m_context->GetIsolate()));
69 } 69 }
70 70
71 void V8FunctionCall::appendUndefinedArgument()
72 {
73 m_arguments.push_back(v8::Undefined(m_context->GetIsolate()));
74 }
75
76 v8::Local<v8::Value> V8FunctionCall::call(bool& hadException, bool reportExcepti ons) 71 v8::Local<v8::Value> V8FunctionCall::call(bool& hadException, bool reportExcepti ons)
77 { 72 {
78 v8::TryCatch tryCatch(m_context->GetIsolate()); 73 v8::TryCatch tryCatch(m_context->GetIsolate());
79 tryCatch.SetVerbose(reportExceptions); 74 tryCatch.SetVerbose(reportExceptions);
80 75
81 v8::Local<v8::Value> result = callWithoutExceptionHandling(); 76 v8::Local<v8::Value> result = callWithoutExceptionHandling();
82 hadException = tryCatch.HasCaught(); 77 hadException = tryCatch.HasCaught();
83 return result; 78 return result;
84 } 79 }
85 80
(...skipping 10 matching lines...) Expand all
96 91
97 DCHECK(value->IsFunction()); 92 DCHECK(value->IsFunction());
98 93
99 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); 94 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
100 std::unique_ptr<v8::Local<v8::Value>[]> info(new v8::Local<v8::Value>[m_argu ments.size()]); 95 std::unique_ptr<v8::Local<v8::Value>[]> info(new v8::Local<v8::Value>[m_argu ments.size()]);
101 for (size_t i = 0; i < m_arguments.size(); ++i) { 96 for (size_t i = 0; i < m_arguments.size(); ++i) {
102 info[i] = m_arguments[i]; 97 info[i] = m_arguments[i];
103 DCHECK(!info[i].IsEmpty()); 98 DCHECK(!info[i].IsEmpty());
104 } 99 }
105 100
101 int contextGroupId = V8DebuggerImpl::getGroupId(m_context);
102 if (contextGroupId)
103 m_debugger->client()->muteWarningsAndDeprecations(contextGroupId);
106 v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksS cope::kDoNotRunMicrotasks); 104 v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksS cope::kDoNotRunMicrotasks);
105 v8::MaybeLocal<v8::Value> maybeResult = function->Call(m_context, thisObject , m_arguments.size(), info.get());
106 if (contextGroupId)
107 m_debugger->client()->unmuteWarningsAndDeprecations(contextGroupId);
108
107 v8::Local<v8::Value> result; 109 v8::Local<v8::Value> result;
108 if (!function->Call(m_context, thisObject, m_arguments.size(), info.get()).T oLocal(&result)) 110 if (!maybeResult.ToLocal(&result))
109 return v8::Local<v8::Value>(); 111 return v8::Local<v8::Value>();
110 return result; 112 return result;
111 } 113 }
112 114
113 v8::Local<v8::Function> V8FunctionCall::function()
114 {
115 v8::TryCatch tryCatch(m_context->GetIsolate());
116 v8::Local<v8::Object> thisObject = v8::Local<v8::Object>::Cast(m_value);
117 v8::Local<v8::Value> value;
118 if (!thisObject->Get(m_context, m_name).ToLocal(&value))
119 return v8::Local<v8::Function>();
120
121 DCHECK(value->IsFunction());
122 return v8::Local<v8::Function>::Cast(value);
123 }
124
125 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698