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

Side by Side Diff: test/inspector/inspector-impl.cc

Issue 2816043006: [inspector] avoid cloning of async call chains (Closed)
Patch Set: lines and columns in stack string should be 1-based Created 3 years, 8 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 | « test/inspector/inspector-impl.h ('k') | test/inspector/inspector-test.cc » ('j') | 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 "test/inspector/inspector-impl.h" 5 #include "test/inspector/inspector-impl.h"
6 6
7 #include "include/v8.h" 7 #include "include/v8.h"
8 8
9 #include "src/vector.h" 9 #include "src/vector.h"
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 url_string = 78 url_string =
79 ToVector(message->GetScriptOrigin().ResourceName().As<v8::String>()); 79 ToVector(message->GetScriptOrigin().ResourceName().As<v8::String>());
80 } 80 }
81 v8_inspector::StringView url(url_string.start(), url_string.length()); 81 v8_inspector::StringView url(url_string.start(), url_string.length());
82 82
83 inspector->exceptionThrown(context, message_text, exception, detailed_message, 83 inspector->exceptionThrown(context, message_text, exception, detailed_message,
84 url, line_number, column_number, 84 url, line_number, column_number,
85 inspector->createStackTrace(stack), script_id); 85 inspector->createStackTrace(stack), script_id);
86 } 86 }
87 87
88 v8::Local<v8::String> ToString(v8::Isolate* isolate,
89 const v8_inspector::StringView& string) {
90 if (string.is8Bit())
91 return v8::String::NewFromOneByte(isolate, string.characters8(),
92 v8::NewStringType::kNormal,
93 static_cast<int>(string.length()))
94 .ToLocalChecked();
95 else
96 return v8::String::NewFromTwoByte(isolate, string.characters16(),
97 v8::NewStringType::kNormal,
98 static_cast<int>(string.length()))
99 .ToLocalChecked();
100 }
101
102 void Print(v8::Isolate* isolate, const v8_inspector::StringView& string) {
103 v8::Local<v8::String> v8_string = ToString(isolate, string);
104 v8::String::Utf8Value utf8_string(v8_string);
105 fwrite(*utf8_string, sizeof(**utf8_string), utf8_string.length(), stdout);
106 }
88 } // namespace 107 } // namespace
89 108
90 class ConnectTask : public TaskRunner::Task { 109 class ConnectTask : public TaskRunner::Task {
91 public: 110 public:
92 ConnectTask(InspectorClientImpl* client, v8::base::Semaphore* ready_semaphore) 111 ConnectTask(InspectorClientImpl* client, v8::base::Semaphore* ready_semaphore)
93 : client_(client), ready_semaphore_(ready_semaphore) {} 112 : client_(client), ready_semaphore_(ready_semaphore) {}
94 virtual ~ConnectTask() = default; 113 virtual ~ConnectTask() = default;
95 114
96 bool is_inspector_task() final { return true; } 115 bool is_inspector_task() final { return true; }
97 116
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 double InspectorClientImpl::currentTimeMS() { 277 double InspectorClientImpl::currentTimeMS() {
259 if (current_time_set_for_test_) return current_time_; 278 if (current_time_set_for_test_) return current_time_;
260 return v8::base::OS::TimeCurrentMillis(); 279 return v8::base::OS::TimeCurrentMillis();
261 } 280 }
262 281
263 void InspectorClientImpl::setMemoryInfoForTest( 282 void InspectorClientImpl::setMemoryInfoForTest(
264 v8::Local<v8::Value> memory_info) { 283 v8::Local<v8::Value> memory_info) {
265 memory_info_.Reset(isolate_, memory_info); 284 memory_info_.Reset(isolate_, memory_info);
266 } 285 }
267 286
287 void InspectorClientImpl::setLogConsoleApiMessageCalls(bool log) {
288 log_console_api_message_calls_ = log;
289 }
290
268 v8::MaybeLocal<v8::Value> InspectorClientImpl::memoryInfo( 291 v8::MaybeLocal<v8::Value> InspectorClientImpl::memoryInfo(
269 v8::Isolate* isolate, v8::Local<v8::Context>) { 292 v8::Isolate* isolate, v8::Local<v8::Context>) {
270 if (memory_info_.IsEmpty()) return v8::MaybeLocal<v8::Value>(); 293 if (memory_info_.IsEmpty()) return v8::MaybeLocal<v8::Value>();
271 return memory_info_.Get(isolate); 294 return memory_info_.Get(isolate);
272 } 295 }
273 296
274 void InspectorClientImpl::runMessageLoopOnPause(int) { 297 void InspectorClientImpl::runMessageLoopOnPause(int) {
275 task_runner_->RunMessageLoop(true); 298 task_runner_->RunMessageLoop(true);
276 } 299 }
277 300
278 void InspectorClientImpl::quitMessageLoopOnPause() { 301 void InspectorClientImpl::quitMessageLoopOnPause() {
279 task_runner_->QuitMessageLoop(); 302 task_runner_->QuitMessageLoop();
280 } 303 }
281 304
305 void InspectorClientImpl::consoleAPIMessage(
306 int contextGroupId, v8::Isolate::MessageErrorLevel level,
307 const v8_inspector::StringView& message,
308 const v8_inspector::StringView& url, unsigned lineNumber,
309 unsigned columnNumber, v8_inspector::V8StackTrace* stack) {
310 if (!log_console_api_message_calls_) return;
311 Print(isolate_, message);
312 fprintf(stdout, " (");
313 Print(isolate_, url);
314 fprintf(stdout, ":%d:%d)", lineNumber, columnNumber);
315 Print(isolate_, stack->toString()->string());
316 fprintf(stdout, "\n");
317 }
318
282 v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext( 319 v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext(
283 v8::Local<v8::Context> context) { 320 v8::Local<v8::Context> context) {
284 return InspectorClientFromContext(context)->inspector_.get(); 321 return InspectorClientFromContext(context)->inspector_.get();
285 } 322 }
286 323
287 v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext( 324 v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext(
288 v8::Local<v8::Context> context) { 325 v8::Local<v8::Context> context) {
289 int context_group_id = TaskRunner::GetContextGroupId(context); 326 int context_group_id = TaskRunner::GetContextGroupId(context);
290 return InspectorClientFromContext(context)->sessions_[context_group_id].get(); 327 return InspectorClientFromContext(context)->sessions_[context_group_id].get();
291 } 328 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 378 }
342 379
343 void SendMessageToBackendExtension::SendMessageToBackend( 380 void SendMessageToBackendExtension::SendMessageToBackend(
344 const v8::FunctionCallbackInfo<v8::Value>& args) { 381 const v8::FunctionCallbackInfo<v8::Value>& args) {
345 CHECK(backend_task_runner_); 382 CHECK(backend_task_runner_);
346 CHECK(args.Length() == 2 && args[0]->IsString() && args[1]->IsInt32()); 383 CHECK(args.Length() == 2 && args[0]->IsString() && args[1]->IsInt32());
347 v8::Local<v8::String> message = args[0].As<v8::String>(); 384 v8::Local<v8::String> message = args[0].As<v8::String>();
348 backend_task_runner_->Append(new SendMessageToBackendTask( 385 backend_task_runner_->Append(new SendMessageToBackendTask(
349 ToVector(message), args[1].As<v8::Int32>()->Value())); 386 ToVector(message), args[1].As<v8::Int32>()->Value()));
350 } 387 }
OLDNEW
« no previous file with comments | « test/inspector/inspector-impl.h ('k') | test/inspector/inspector-test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698