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

Side by Side Diff: test/inspector/task-runner.cc

Issue 2403493002: [inspector] don't use String16 in inspector test runner (Closed)
Patch Set: a Created 4 years, 2 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/task-runner.h ('k') | no next file » | 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/task-runner.h" 5 #include "test/inspector/task-runner.h"
6 6
7 #if !defined(_WIN32) && !defined(_WIN64) 7 #if !defined(_WIN32) && !defined(_WIN64)
8 #include <unistd.h> // NOLINT 8 #include <unistd.h> // NOLINT
9 #endif // !defined(_WIN32) && !defined(_WIN64) 9 #endif // !defined(_WIN32) && !defined(_WIN64)
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 UNREACHABLE(); 111 UNREACHABLE();
112 return nullptr; 112 return nullptr;
113 } 113 }
114 114
115 TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) { 115 TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) {
116 return static_cast<TaskRunner*>( 116 return static_cast<TaskRunner*>(
117 context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex)); 117 context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex));
118 } 118 }
119 119
120 ExecuteStringTask::ExecuteStringTask(const v8_inspector::String16& expression) 120 ExecuteStringTask::ExecuteStringTask(
121 const v8::internal::Vector<uint16_t>& expression)
121 : expression_(expression) {} 122 : expression_(expression) {}
122 123
124 ExecuteStringTask::ExecuteStringTask(
125 const v8::internal::Vector<const char>& expression)
126 : expression_utf8_(expression) {}
127
123 void ExecuteStringTask::Run(v8::Isolate* isolate, 128 void ExecuteStringTask::Run(v8::Isolate* isolate,
124 const v8::Global<v8::Context>& context) { 129 const v8::Global<v8::Context>& context) {
125 v8::MicrotasksScope microtasks_scope(isolate, 130 v8::MicrotasksScope microtasks_scope(isolate,
126 v8::MicrotasksScope::kRunMicrotasks); 131 v8::MicrotasksScope::kRunMicrotasks);
127 v8::HandleScope handle_scope(isolate); 132 v8::HandleScope handle_scope(isolate);
128 v8::Local<v8::Context> local_context = context.Get(isolate); 133 v8::Local<v8::Context> local_context = context.Get(isolate);
129 v8::Context::Scope context_scope(local_context); 134 v8::Context::Scope context_scope(local_context);
130 135
131 v8::ScriptOrigin origin(v8::String::Empty(isolate)); 136 v8::ScriptOrigin origin(v8::String::Empty(isolate));
132 v8::Local<v8::String> source = 137 v8::Local<v8::String> source;
133 v8::String::NewFromTwoByte(isolate, expression_.characters16(), 138 if (expression_.length()) {
134 v8::NewStringType::kNormal, 139 source = v8::String::NewFromTwoByte(isolate, expression_.start(),
135 static_cast<int>(expression_.length())) 140 v8::NewStringType::kNormal,
136 .ToLocalChecked(); 141 expression_.length())
142 .ToLocalChecked();
143 } else {
144 source = v8::String::NewFromUtf8(isolate, expression_utf8_.start(),
145 v8::NewStringType::kNormal,
146 expression_utf8_.length())
147 .ToLocalChecked();
148 }
137 149
138 v8::ScriptCompiler::Source scriptSource(source, origin); 150 v8::ScriptCompiler::Source scriptSource(source, origin);
139 v8::Local<v8::Script> script; 151 v8::Local<v8::Script> script;
140 if (!v8::ScriptCompiler::Compile(local_context, &scriptSource) 152 if (!v8::ScriptCompiler::Compile(local_context, &scriptSource)
141 .ToLocal(&script)) 153 .ToLocal(&script))
142 return; 154 return;
143 v8::MaybeLocal<v8::Value> result; 155 v8::MaybeLocal<v8::Value> result;
144 result = script->Run(local_context); 156 result = script->Run(local_context);
145 } 157 }
OLDNEW
« no previous file with comments | « test/inspector/task-runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698