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

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

Issue 2037593004: [DevTools] Remove unnecessary knowledge about console from core. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more test Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/inspector/ScriptArguments.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
74 return nullptr; 74 return nullptr;
75 m_debuggerClient = inspectedContext->debugger()->client(); 75 m_debuggerClient = inspectedContext->debugger()->client();
76 return m_debuggerClient; 76 return m_debuggerClient;
77 } 77 }
78 78
79 void addMessage(MessageType type, MessageLevel level, bool allowEmptyArgumen ts, int skipArgumentCount) 79 void addMessage(MessageType type, MessageLevel level, String16 emptyText, in t skipArgumentCount)
80 { 80 {
81 if (!allowEmptyArguments && !m_info.Length()) 81 if (emptyText.isEmpty() && !m_info.Length())
82 return; 82 return;
83 if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) 83 if (V8DebuggerClient* debuggerClient = ensureDebuggerClient())
84 debuggerClient->reportMessageToConsole(m_context, type, level, Strin g16(), &m_info, skipArgumentCount); 84 debuggerClient->reportMessageToConsole(m_context, type, level, m_inf o.Length() <= skipArgumentCount ? emptyText : String16(), &m_info, skipArgumentC ount);
85 } 85 }
86 86
87 void addMessage(MessageType type, MessageLevel level, const String16& messag e) 87 void addMessage(MessageType type, MessageLevel level, const String16& messag e)
88 { 88 {
89 if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) 89 if (V8DebuggerClient* debuggerClient = ensureDebuggerClient())
90 debuggerClient->reportMessageToConsole(m_context, type, level, messa ge, nullptr, 0 /* skipArgumentsCount */); 90 debuggerClient->reportMessageToConsole(m_context, type, level, messa ge, nullptr, 0 /* skipArgumentsCount */);
91 } 91 }
92 92
93 void addDeprecationMessage(const char* id, const String16& message) 93 void addDeprecationMessage(const char* id, const String16& message)
94 { 94 {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction); 259 func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction);
260 } 260 }
261 if (!console->Set(context, funcName, func).FromMaybe(false)) 261 if (!console->Set(context, funcName, func).FromMaybe(false))
262 return; 262 return;
263 } 263 }
264 264
265 } // namespace 265 } // namespace
266 266
267 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 267 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
268 { 268 {
269 ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, false, 0); 269 ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, String16() , 0);
270 } 270 }
271 271
272 void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 272 void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
273 { 273 {
274 ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, false, 0); 274 ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, String16() , 0);
275 } 275 }
276 276
277 void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 277 void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
278 { 278 {
279 ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, false, 0); 279 ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, String16(), 0);
280 } 280 }
281 281
282 void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 282 void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
283 { 283 {
284 ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, false, 0); 284 ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, String16(), 0);
285 } 285 }
286 286
287 void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 287 void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
288 { 288 {
289 ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, false, 0 ); 289 ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, String16 (), 0);
290 } 290 }
291 291
292 void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 292 void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
293 { 293 {
294 ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, false, 0); 294 ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, String16(), 0);
295 } 295 }
296 296
297 void V8Console::dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 297 void V8Console::dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
298 { 298 {
299 ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, false, 0) ; 299 ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, String16( ), 0);
300 } 300 }
301 301
302 void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 302 void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
303 { 303 {
304 ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, false, 0); 304 ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, String16() , 0);
305 } 305 }
306 306
307 void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 307 void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
308 { 308 {
309 ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, true, 0); 309 ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, String16(" console.trace"), 0);
310 } 310 }
311 311
312 void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 312 void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
313 { 313 {
314 ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, true, 0); 314 ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, Strin g16("console.group"), 0);
315 } 315 }
316 316
317 void V8Console::groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value> & info) 317 void V8Console::groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value> & info)
318 { 318 {
319 ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLev el, true, 0); 319 ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLev el, String16("console.groupCollapsed"), 0);
320 } 320 }
321 321
322 void V8Console::groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info ) 322 void V8Console::groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info )
323 { 323 {
324 ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, true, 0 ); 324 ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, String1 6("console.groupEnd"), 0);
325 } 325 }
326 326
327 void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 327 void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
328 { 328 {
329 ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, true, 0); 329 ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, String16(" console.clear"), 0);
330 } 330 }
331 331
332 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 332 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
333 { 333 {
334 ConsoleHelper helper(info); 334 ConsoleHelper helper(info);
335 335
336 String16 title = helper.firstArgToString(String16()); 336 String16 title = helper.firstArgToString(String16());
337 String16 identifier; 337 String16 identifier;
338 if (title.isEmpty()) { 338 if (title.isEmpty()) {
339 std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture (nullptr, 1); 339 std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture (nullptr, 1);
340 if (stackTrace) 340 if (stackTrace)
341 identifier = stackTrace->topSourceURL() + ":" + String16::number(sta ckTrace->topLineNumber()); 341 identifier = stackTrace->topSourceURL() + ":" + String16::number(sta ckTrace->topLineNumber());
342 } else { 342 } else {
343 identifier = title + "@"; 343 identifier = title + "@";
344 } 344 }
345 345
346 v8::Local<v8::Map> countMap; 346 v8::Local<v8::Map> countMap;
347 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) 347 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap))
348 return; 348 return;
349 int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; 349 int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1;
350 helper.setIntOnMap(countMap, identifier, count); 350 helper.setIntOnMap(countMap, identifier, count);
351 helper.addMessage(CountMessageType, DebugMessageLevel, title + ": " + String 16::number(count)); 351 helper.addMessage(CountMessageType, DebugMessageLevel, title + ": " + String 16::number(count));
352 } 352 }
353 353
354 void V8Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 354 void V8Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
355 { 355 {
356 ConsoleHelper helper(info); 356 ConsoleHelper helper(info);
357 if (helper.firstArgToBoolean(false)) 357 if (helper.firstArgToBoolean(false))
358 return; 358 return;
359 helper.addMessage(AssertMessageType, ErrorMessageLevel, true, 1); 359 helper.addMessage(AssertMessageType, ErrorMessageLevel, String16("console.as sert"), 1);
360 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) 360 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent())
361 debuggerAgent->breakProgramOnException(protocol::Debugger::Paused::Reaso nEnum::Assert, nullptr); 361 debuggerAgent->breakProgramOnException(protocol::Debugger::Paused::Reaso nEnum::Assert, nullptr);
362 } 362 }
363 363
364 void V8Console::markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 364 void V8Console::markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
365 { 365 {
366 ConsoleHelper(info).addDeprecationMessage("V8Console#markTimelineDeprecated" , "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead. "); 366 ConsoleHelper(info).addDeprecationMessage("V8Console#markTimelineDeprecated" , "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead. ");
367 timeStampCallback(info); 367 timeStampCallback(info);
368 } 368 }
369 369
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); 725 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ());
726 if (getters.size() == 0) { 726 if (getters.size() == 0) {
727 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; 727 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" };
728 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) 728 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i)
729 getters.add(members[i]); 729 getters.add(members[i]);
730 } 730 }
731 return getters.find(name) != getters.end(); 731 return getters.find(name) != getters.end();
732 } 732 }
733 733
734 } // namespace blink 734 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/ScriptArguments.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698