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

Side by Side Diff: src/inspector/v8-console-message.cc

Issue 2899113003: Use all of the arguments to build the console messages
Patch Set: Created 3 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
« no previous file with comments | « AUTHORS ('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 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-message.h" 5 #include "src/inspector/v8-console-message.h"
6 6
7 #include "src/debug/debug-interface.h" 7 #include "src/debug/debug-interface.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; 58 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log;
59 } 59 }
60 60
61 const unsigned maxConsoleMessageCount = 1000; 61 const unsigned maxConsoleMessageCount = 1000;
62 const int maxConsoleMessageV8Size = 10 * 1024 * 1024; 62 const int maxConsoleMessageV8Size = 10 * 1024 * 1024;
63 const unsigned maxArrayItemsLimit = 10000; 63 const unsigned maxArrayItemsLimit = 10000;
64 const unsigned maxStackDepthLimit = 32; 64 const unsigned maxStackDepthLimit = 32;
65 65
66 class V8ValueStringBuilder { 66 class V8ValueStringBuilder {
67 public: 67 public:
68 static String16 toString(v8::Local<v8::Value> value, 68 static String16 toString(const std::vector<v8::Local<v8::Value>>& arguments,
69 v8::Local<v8::Context> context) { 69 v8::Local<v8::Context> context) {
70 V8ValueStringBuilder builder(context); 70 V8ValueStringBuilder builder(context);
71 if (!builder.append(value)) return String16(); 71 for (size_t i = 0; i < arguments.size(); ++i) {
72 if (i > 0) builder.append(" ");
73 if (!builder.append(arguments.at(i))) return String16();
74 }
72 return builder.toString(); 75 return builder.toString();
73 } 76 }
74 77
75 private: 78 private:
76 enum { 79 enum {
77 IgnoreNull = 1 << 0, 80 IgnoreNull = 1 << 0,
78 IgnoreUndefined = 1 << 1, 81 IgnoreUndefined = 1 << 1,
79 }; 82 };
80 83
81 explicit V8ValueStringBuilder(v8::Local<v8::Context> context) 84 explicit V8ValueStringBuilder(v8::Local<v8::Context> context)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 m_builder.append(')'); 157 m_builder.append(')');
155 return result; 158 return result;
156 } 159 }
157 160
158 bool append(v8::Local<v8::String> string) { 161 bool append(v8::Local<v8::String> string) {
159 if (m_tryCatch.HasCaught()) return false; 162 if (m_tryCatch.HasCaught()) return false;
160 if (!string.IsEmpty()) m_builder.append(toProtocolString(string)); 163 if (!string.IsEmpty()) m_builder.append(toProtocolString(string));
161 return true; 164 return true;
162 } 165 }
163 166
167 bool append(const String16& string) {
168 m_builder.append(string);
169 return true;
170 }
171
164 String16 toString() { 172 String16 toString() {
165 if (m_tryCatch.HasCaught()) return String16(); 173 if (m_tryCatch.HasCaught()) return String16();
166 return m_builder.toString(); 174 return m_builder.toString();
167 } 175 }
168 176
169 uint32_t m_arrayLimit; 177 uint32_t m_arrayLimit;
170 v8::Isolate* m_isolate; 178 v8::Isolate* m_isolate;
171 String16Builder m_builder; 179 String16Builder m_builder;
172 std::vector<v8::Local<v8::Array>> m_visitedArrays; 180 std::vector<v8::Local<v8::Array>> m_visitedArrays;
173 v8::TryCatch m_tryCatch; 181 v8::TryCatch m_tryCatch;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 message->m_stackTrace = std::move(stackTrace); 377 message->m_stackTrace = std::move(stackTrace);
370 message->m_type = type; 378 message->m_type = type;
371 message->m_contextId = contextId; 379 message->m_contextId = contextId;
372 for (size_t i = 0; i < arguments.size(); ++i) { 380 for (size_t i = 0; i < arguments.size(); ++i) {
373 message->m_arguments.push_back(std::unique_ptr<v8::Global<v8::Value>>( 381 message->m_arguments.push_back(std::unique_ptr<v8::Global<v8::Value>>(
374 new v8::Global<v8::Value>(isolate, arguments.at(i)))); 382 new v8::Global<v8::Value>(isolate, arguments.at(i))));
375 message->m_v8Size += 383 message->m_v8Size +=
376 v8::debug::EstimatedValueSize(isolate, arguments.at(i)); 384 v8::debug::EstimatedValueSize(isolate, arguments.at(i));
377 } 385 }
378 if (arguments.size()) 386 if (arguments.size())
379 message->m_message = 387 message->m_message = V8ValueStringBuilder::toString(arguments, v8Context);
380 V8ValueStringBuilder::toString(arguments[0], v8Context);
381 388
382 v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo; 389 v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo;
383 if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || 390 if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
384 type == ConsoleAPIType::kTimeEnd) { 391 type == ConsoleAPIType::kTimeEnd) {
385 clientLevel = v8::Isolate::kMessageDebug; 392 clientLevel = v8::Isolate::kMessageDebug;
386 } else if (type == ConsoleAPIType::kError || 393 } else if (type == ConsoleAPIType::kError ||
387 type == ConsoleAPIType::kAssert) { 394 type == ConsoleAPIType::kAssert) {
388 clientLevel = v8::Isolate::kMessageError; 395 clientLevel = v8::Isolate::kMessageError;
389 } else if (type == ConsoleAPIType::kWarning) { 396 } else if (type == ConsoleAPIType::kWarning) {
390 clientLevel = v8::Isolate::kMessageWarning; 397 clientLevel = v8::Isolate::kMessageWarning;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 m_estimatedSize = 0; 531 m_estimatedSize = 0;
525 for (size_t i = 0; i < m_messages.size(); ++i) { 532 for (size_t i = 0; i < m_messages.size(); ++i) {
526 m_messages[i]->contextDestroyed(contextId); 533 m_messages[i]->contextDestroyed(contextId);
527 m_estimatedSize += m_messages[i]->estimatedSize(); 534 m_estimatedSize += m_messages[i]->estimatedSize();
528 } 535 }
529 auto it = m_data.find(contextId); 536 auto it = m_data.find(contextId);
530 if (it != m_data.end()) m_data.erase(contextId); 537 if (it != m_data.end()) m_data.erase(contextId);
531 } 538 }
532 539
533 } // namespace v8_inspector 540 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698