| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 MainThreadDebugger* MainThreadDebugger::instance_ = nullptr; | 96 MainThreadDebugger* MainThreadDebugger::instance_ = nullptr; |
| 97 | 97 |
| 98 MainThreadDebugger::MainThreadDebugger(v8::Isolate* isolate) | 98 MainThreadDebugger::MainThreadDebugger(v8::Isolate* isolate) |
| 99 : ThreadDebugger(isolate), | 99 : ThreadDebugger(isolate), |
| 100 task_runner_(WTF::MakeUnique<InspectorTaskRunner>()), | 100 task_runner_(WTF::MakeUnique<InspectorTaskRunner>()), |
| 101 paused_(false) { | 101 paused_(false) { |
| 102 MutexLocker locker(CreationMutex()); | 102 MutexLocker locker(CreationMutex()); |
| 103 ASSERT(!instance_); | 103 DCHECK(!instance_); |
| 104 instance_ = this; | 104 instance_ = this; |
| 105 } | 105 } |
| 106 | 106 |
| 107 MainThreadDebugger::~MainThreadDebugger() { | 107 MainThreadDebugger::~MainThreadDebugger() { |
| 108 MutexLocker locker(CreationMutex()); | 108 MutexLocker locker(CreationMutex()); |
| 109 ASSERT(instance_ == this); | 109 ASSERT(instance_ == this); |
| 110 instance_ = nullptr; | 110 instance_ = nullptr; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void MainThreadDebugger::ReportConsoleMessage(ExecutionContext* context, | 113 void MainThreadDebugger::ReportConsoleMessage(ExecutionContext* context, |
| 114 MessageSource source, | 114 MessageSource source, |
| 115 MessageLevel level, | 115 MessageLevel level, |
| 116 const String& message, | 116 const String& message, |
| 117 SourceLocation* location) { | 117 SourceLocation* location) { |
| 118 if (LocalFrame* frame = ToFrame(context)) | 118 if (LocalFrame* frame = ToFrame(context)) |
| 119 frame->Console().ReportMessageToClient(source, level, message, location); | 119 frame->Console().ReportMessageToClient(source, level, message, location); |
| 120 } | 120 } |
| 121 | 121 |
| 122 int MainThreadDebugger::ContextGroupId(ExecutionContext* context) { | 122 int MainThreadDebugger::ContextGroupId(ExecutionContext* context) { |
| 123 LocalFrame* frame = ToFrame(context); | 123 LocalFrame* frame = ToFrame(context); |
| 124 return frame ? ContextGroupId(frame) : 0; | 124 return frame ? ContextGroupId(frame) : 0; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void MainThreadDebugger::SetClientMessageLoop( | 127 void MainThreadDebugger::SetClientMessageLoop( |
| 128 std::unique_ptr<ClientMessageLoop> client_message_loop) { | 128 std::unique_ptr<ClientMessageLoop> client_message_loop) { |
| 129 ASSERT(!client_message_loop_); | 129 DCHECK(!client_message_loop_); |
| 130 ASSERT(client_message_loop); | 130 DCHECK(client_message_loop); |
| 131 client_message_loop_ = std::move(client_message_loop); | 131 client_message_loop_ = std::move(client_message_loop); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void MainThreadDebugger::DidClearContextsForFrame(LocalFrame* frame) { | 134 void MainThreadDebugger::DidClearContextsForFrame(LocalFrame* frame) { |
| 135 DCHECK(IsMainThread()); | 135 DCHECK(IsMainThread()); |
| 136 if (frame->LocalFrameRoot() == frame) | 136 if (frame->LocalFrameRoot() == frame) |
| 137 GetV8Inspector()->resetContextGroup(ContextGroupId(frame)); | 137 GetV8Inspector()->resetContextGroup(ContextGroupId(frame)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void MainThreadDebugger::ContextCreated(ScriptState* script_state, | 140 void MainThreadDebugger::ContextCreated(ScriptState* script_state, |
| 141 LocalFrame* frame, | 141 LocalFrame* frame, |
| 142 SecurityOrigin* origin) { | 142 SecurityOrigin* origin) { |
| 143 ASSERT(IsMainThread()); | 143 DCHECK(IsMainThread()); |
| 144 v8::HandleScope handles(script_state->GetIsolate()); | 144 v8::HandleScope handles(script_state->GetIsolate()); |
| 145 DOMWrapperWorld& world = script_state->World(); | 145 DOMWrapperWorld& world = script_state->World(); |
| 146 StringBuilder aux_data_builder; | 146 StringBuilder aux_data_builder; |
| 147 aux_data_builder.Append("{\"isDefault\":"); | 147 aux_data_builder.Append("{\"isDefault\":"); |
| 148 aux_data_builder.Append(world.IsMainWorld() ? "true" : "false"); | 148 aux_data_builder.Append(world.IsMainWorld() ? "true" : "false"); |
| 149 aux_data_builder.Append(",\"frameId\":\""); | 149 aux_data_builder.Append(",\"frameId\":\""); |
| 150 aux_data_builder.Append(IdentifiersFactory::FrameId(frame)); | 150 aux_data_builder.Append(IdentifiersFactory::FrameId(frame)); |
| 151 aux_data_builder.Append("\"}"); | 151 aux_data_builder.Append("\"}"); |
| 152 String aux_data = aux_data_builder.ToString(); | 152 String aux_data = aux_data_builder.ToString(); |
| 153 String human_readable_name = world.IsIsolatedWorld() | 153 String human_readable_name = world.IsIsolatedWorld() |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return; | 330 return; |
| 331 if (frame->GetPage()) | 331 if (frame->GetPage()) |
| 332 frame->GetPage()->GetConsoleMessageStorage().Clear(); | 332 frame->GetPage()->GetConsoleMessageStorage().Clear(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo( | 335 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo( |
| 336 v8::Isolate* isolate, | 336 v8::Isolate* isolate, |
| 337 v8::Local<v8::Context> context) { | 337 v8::Local<v8::Context> context) { |
| 338 ExecutionContext* execution_context = ToExecutionContext(context); | 338 ExecutionContext* execution_context = ToExecutionContext(context); |
| 339 DCHECK(execution_context); | 339 DCHECK(execution_context); |
| 340 ASSERT(execution_context->IsDocument()); | 340 DCHECK(execution_context->IsDocument()); |
| 341 return ToV8(MemoryInfo::Create(), context->Global(), isolate); | 341 return ToV8(MemoryInfo::Create(), context->Global(), isolate); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void MainThreadDebugger::installAdditionalCommandLineAPI( | 344 void MainThreadDebugger::installAdditionalCommandLineAPI( |
| 345 v8::Local<v8::Context> context, | 345 v8::Local<v8::Context> context, |
| 346 v8::Local<v8::Object> object) { | 346 v8::Local<v8::Object> object) { |
| 347 ThreadDebugger::installAdditionalCommandLineAPI(context, object); | 347 ThreadDebugger::installAdditionalCommandLineAPI(context, object); |
| 348 CreateFunctionProperty( | 348 CreateFunctionProperty( |
| 349 context, object, "$", MainThreadDebugger::QuerySelectorCallback, | 349 context, object, "$", MainThreadDebugger::QuerySelectorCallback, |
| 350 "function $(selector, [startNode]) { [Command Line API] }"); | 350 "function $(selector, [startNode]) { [Command Line API] }"); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 context, nodes, index++, | 464 context, nodes, index++, |
| 465 ToV8(node, info.Holder(), info.GetIsolate())) | 465 ToV8(node, info.Holder(), info.GetIsolate())) |
| 466 .FromMaybe(false)) | 466 .FromMaybe(false)) |
| 467 return; | 467 return; |
| 468 } | 468 } |
| 469 info.GetReturnValue().Set(nodes); | 469 info.GetReturnValue().Set(nodes); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace blink | 473 } // namespace blink |
| OLD | NEW |