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