| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 isolate_->AddMessageListener(MessageHandler); | 167 isolate_->AddMessageListener(MessageHandler); |
| 168 channel_.reset(new ChannelImpl(frontend_channel_)); | 168 channel_.reset(new ChannelImpl(frontend_channel_)); |
| 169 inspector_ = v8_inspector::V8Inspector::create(isolate_, this); | 169 inspector_ = v8_inspector::V8Inspector::create(isolate_, this); |
| 170 | 170 |
| 171 if (states_.empty()) { | 171 if (states_.empty()) { |
| 172 int context_group_id = TaskRunner::GetContextGroupId(context); | 172 int context_group_id = TaskRunner::GetContextGroupId(context); |
| 173 v8_inspector::StringView state; | 173 v8_inspector::StringView state; |
| 174 sessions_[context_group_id] = | 174 sessions_[context_group_id] = |
| 175 inspector_->connect(context_group_id, channel_.get(), state); | 175 inspector_->connect(context_group_id, channel_.get(), state); |
| 176 context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this); | 176 context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this); |
| 177 v8_inspector::V8ContextInfo info(context, context_group_id, | 177 inspector_->contextCreated(v8_inspector::V8ContextInfo( |
| 178 v8_inspector::StringView()); | 178 context, context_group_id, v8_inspector::StringView())); |
| 179 info.hasMemoryOnConsole = true; | |
| 180 inspector_->contextCreated(info); | |
| 181 } else { | 179 } else { |
| 182 for (const auto& it : states_) { | 180 for (const auto& it : states_) { |
| 183 int context_group_id = it.first; | 181 int context_group_id = it.first; |
| 184 v8::Local<v8::Context> context = | 182 v8::Local<v8::Context> context = |
| 185 task_runner_->GetContext(context_group_id); | 183 task_runner_->GetContext(context_group_id); |
| 186 v8_inspector::StringView state = it.second->string(); | 184 v8_inspector::StringView state = it.second->string(); |
| 187 sessions_[context_group_id] = | 185 sessions_[context_group_id] = |
| 188 inspector_->connect(context_group_id, channel_.get(), state); | 186 inspector_->connect(context_group_id, channel_.get(), state); |
| 189 context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this); | 187 context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this); |
| 190 v8_inspector::V8ContextInfo info(context, context_group_id, | 188 inspector_->contextCreated(v8_inspector::V8ContextInfo( |
| 191 v8_inspector::StringView()); | 189 context, context_group_id, v8_inspector::StringView())); |
| 192 info.hasMemoryOnConsole = true; | |
| 193 inspector_->contextCreated(info); | |
| 194 } | 190 } |
| 195 } | 191 } |
| 196 states_.clear(); | 192 states_.clear(); |
| 197 } | 193 } |
| 198 | 194 |
| 199 void InspectorClientImpl::scheduleReconnect( | 195 void InspectorClientImpl::scheduleReconnect( |
| 200 v8::base::Semaphore* ready_semaphore) { | 196 v8::base::Semaphore* ready_semaphore) { |
| 201 task_runner_->Append(new DisconnectTask(this)); | 197 task_runner_->Append(new DisconnectTask(this)); |
| 202 task_runner_->Append(new ConnectTask(this, ready_semaphore)); | 198 task_runner_->Append(new ConnectTask(this, ready_semaphore)); |
| 203 } | 199 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void InspectorClientImpl::setCurrentTimeMSForTest(double time) { | 249 void InspectorClientImpl::setCurrentTimeMSForTest(double time) { |
| 254 current_time_ = time; | 250 current_time_ = time; |
| 255 current_time_set_for_test_ = true; | 251 current_time_set_for_test_ = true; |
| 256 } | 252 } |
| 257 | 253 |
| 258 double InspectorClientImpl::currentTimeMS() { | 254 double InspectorClientImpl::currentTimeMS() { |
| 259 if (current_time_set_for_test_) return current_time_; | 255 if (current_time_set_for_test_) return current_time_; |
| 260 return v8::base::OS::TimeCurrentMillis(); | 256 return v8::base::OS::TimeCurrentMillis(); |
| 261 } | 257 } |
| 262 | 258 |
| 263 void InspectorClientImpl::setMemoryInfoForTest( | |
| 264 v8::Local<v8::Value> memory_info) { | |
| 265 memory_info_.Reset(isolate_, memory_info); | |
| 266 } | |
| 267 | |
| 268 v8::MaybeLocal<v8::Value> InspectorClientImpl::memoryInfo( | |
| 269 v8::Isolate* isolate, v8::Local<v8::Context>) { | |
| 270 if (memory_info_.IsEmpty()) return v8::MaybeLocal<v8::Value>(); | |
| 271 return memory_info_.Get(isolate); | |
| 272 } | |
| 273 | |
| 274 void InspectorClientImpl::runMessageLoopOnPause(int) { | 259 void InspectorClientImpl::runMessageLoopOnPause(int) { |
| 275 task_runner_->RunMessageLoop(true); | 260 task_runner_->RunMessageLoop(true); |
| 276 } | 261 } |
| 277 | 262 |
| 278 void InspectorClientImpl::quitMessageLoopOnPause() { | 263 void InspectorClientImpl::quitMessageLoopOnPause() { |
| 279 task_runner_->QuitMessageLoop(); | 264 task_runner_->QuitMessageLoop(); |
| 280 } | 265 } |
| 281 | 266 |
| 282 v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext( | 267 v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext( |
| 283 v8::Local<v8::Context> context) { | 268 v8::Local<v8::Context> context) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 326 } |
| 342 | 327 |
| 343 void SendMessageToBackendExtension::SendMessageToBackend( | 328 void SendMessageToBackendExtension::SendMessageToBackend( |
| 344 const v8::FunctionCallbackInfo<v8::Value>& args) { | 329 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 345 CHECK(backend_task_runner_); | 330 CHECK(backend_task_runner_); |
| 346 CHECK(args.Length() == 2 && args[0]->IsString() && args[1]->IsInt32()); | 331 CHECK(args.Length() == 2 && args[0]->IsString() && args[1]->IsInt32()); |
| 347 v8::Local<v8::String> message = args[0].As<v8::String>(); | 332 v8::Local<v8::String> message = args[0].As<v8::String>(); |
| 348 backend_task_runner_->Append(new SendMessageToBackendTask( | 333 backend_task_runner_->Append(new SendMessageToBackendTask( |
| 349 ToVector(message), args[1].As<v8::Int32>()->Value())); | 334 ToVector(message), args[1].As<v8::Int32>()->Value())); |
| 350 } | 335 } |
| OLD | NEW |