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

Side by Side Diff: test/inspector/isolate-data.cc

Issue 2916803005: [inspector] Create InjectedScript per session in each context (Closed)
Patch Set: rebased Created 3 years, 6 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/isolate-data.h ('k') | test/inspector/protocol-test.js » ('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 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/isolate-data.h" 5 #include "test/inspector/isolate-data.h"
6 6
7 #include "src/inspector/test-interface.h" 7 #include "src/inspector/test-interface.h"
8 #include "test/inspector/task-runner.h" 8 #include "test/inspector/task-runner.h"
9 9
10 namespace { 10 namespace {
(...skipping 21 matching lines...) Expand all
32 static_cast<int>(string.length())) 32 static_cast<int>(string.length()))
33 .ToLocalChecked(); 33 .ToLocalChecked();
34 } 34 }
35 35
36 void Print(v8::Isolate* isolate, const v8_inspector::StringView& string) { 36 void Print(v8::Isolate* isolate, const v8_inspector::StringView& string) {
37 v8::Local<v8::String> v8_string = ToString(isolate, string); 37 v8::Local<v8::String> v8_string = ToString(isolate, string);
38 v8::String::Utf8Value utf8_string(v8_string); 38 v8::String::Utf8Value utf8_string(v8_string);
39 fwrite(*utf8_string, sizeof(**utf8_string), utf8_string.length(), stdout); 39 fwrite(*utf8_string, sizeof(**utf8_string), utf8_string.length(), stdout);
40 } 40 }
41 41
42 class Inspectable : public v8_inspector::V8InspectorSession::Inspectable {
43 public:
44 Inspectable(v8::Isolate* isolate, v8::Local<v8::Value> object)
45 : object_(isolate, object) {}
46 ~Inspectable() override {}
47 v8::Local<v8::Value> get(v8::Local<v8::Context> context) override {
48 return object_.Get(context->GetIsolate());
49 }
50
51 private:
52 v8::Global<v8::Value> object_;
53 };
54
42 } // namespace 55 } // namespace
43 56
44 IsolateData::IsolateData(TaskRunner* task_runner, 57 IsolateData::IsolateData(TaskRunner* task_runner,
45 IsolateData::SetupGlobalTasks setup_global_tasks, 58 IsolateData::SetupGlobalTasks setup_global_tasks,
46 v8::StartupData* startup_data, bool with_inspector) 59 v8::StartupData* startup_data, bool with_inspector)
47 : task_runner_(task_runner), 60 : task_runner_(task_runner),
48 setup_global_tasks_(std::move(setup_global_tasks)) { 61 setup_global_tasks_(std::move(setup_global_tasks)) {
49 v8::Isolate::CreateParams params; 62 v8::Isolate::CreateParams params;
50 params.array_buffer_allocator = 63 params.array_buffer_allocator =
51 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); 64 v8::ArrayBuffer::Allocator::NewDefaultAllocator();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 189 }
177 190
178 void IsolateData::AsyncTaskStarted(void* task) { 191 void IsolateData::AsyncTaskStarted(void* task) {
179 inspector_->asyncTaskStarted(task); 192 inspector_->asyncTaskStarted(task);
180 } 193 }
181 194
182 void IsolateData::AsyncTaskFinished(void* task) { 195 void IsolateData::AsyncTaskFinished(void* task) {
183 inspector_->asyncTaskFinished(task); 196 inspector_->asyncTaskFinished(task);
184 } 197 }
185 198
199 void IsolateData::AddInspectedObject(int session_id,
200 v8::Local<v8::Value> object) {
201 auto it = sessions_.find(session_id);
202 if (it == sessions_.end()) return;
203 std::unique_ptr<Inspectable> inspectable(new Inspectable(isolate_, object));
204 it->second->addInspectedObject(std::move(inspectable));
205 }
206
186 void IsolateData::SetMaxAsyncTaskStacksForTest(int limit) { 207 void IsolateData::SetMaxAsyncTaskStacksForTest(int limit) {
187 v8_inspector::SetMaxAsyncTaskStacksForTest(inspector_.get(), limit); 208 v8_inspector::SetMaxAsyncTaskStacksForTest(inspector_.get(), limit);
188 } 209 }
189 210
190 void IsolateData::DumpAsyncTaskStacksStateForTest() { 211 void IsolateData::DumpAsyncTaskStacksStateForTest() {
191 v8_inspector::DumpAsyncTaskStacksStateForTest(inspector_.get()); 212 v8_inspector::DumpAsyncTaskStacksStateForTest(inspector_.get());
192 } 213 }
193 214
194 // static 215 // static
195 int IsolateData::HandleMessage(v8::Local<v8::Message> message, 216 int IsolateData::HandleMessage(v8::Local<v8::Message> message,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 unsigned lineNumber, unsigned columnNumber, 367 unsigned lineNumber, unsigned columnNumber,
347 v8_inspector::V8StackTrace* stack) { 368 v8_inspector::V8StackTrace* stack) {
348 if (!log_console_api_message_calls_) return; 369 if (!log_console_api_message_calls_) return;
349 Print(isolate_, message); 370 Print(isolate_, message);
350 fprintf(stdout, " ("); 371 fprintf(stdout, " (");
351 Print(isolate_, url); 372 Print(isolate_, url);
352 fprintf(stdout, ":%d:%d)", lineNumber, columnNumber); 373 fprintf(stdout, ":%d:%d)", lineNumber, columnNumber);
353 Print(isolate_, stack->toString()->string()); 374 Print(isolate_, stack->toString()->string());
354 fprintf(stdout, "\n"); 375 fprintf(stdout, "\n");
355 } 376 }
OLDNEW
« no previous file with comments | « test/inspector/isolate-data.h ('k') | test/inspector/protocol-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698