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

Side by Side Diff: third_party/WebKit/Source/core/inspector/MainThreadDebugger.cpp

Issue 1992913006: [DevTools] Move monitor/unmonitor events CommandLineAPI to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-selectors-to-native
Patch Set: Created 4 years, 7 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 | « no previous file | third_party/WebKit/Source/core/inspector/ThreadDebugger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 bool MainThreadDebugger::isCommandLineAPIMethod(const String& name) 244 bool MainThreadDebugger::isCommandLineAPIMethod(const String& name)
245 { 245 {
246 DEFINE_STATIC_LOCAL(HashSet<String>, methods, ()); 246 DEFINE_STATIC_LOCAL(HashSet<String>, methods, ());
247 if (methods.size() == 0) { 247 if (methods.size() == 0) {
248 const char* members[] = { "$", "$$", "$x" }; 248 const char* members[] = { "$", "$$", "$x" };
249 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) 249 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i)
250 methods.add(members[i]); 250 methods.add(members[i]);
251 } 251 }
252 return methods.find(name) != methods.end() || V8Debugger::isCommandLineAPIMe thod(name); 252 return methods.find(name) != methods.end() || ThreadDebugger::isCommandLineA PIMethod(name);
253 }
254
255 static void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
256 {
257 info.GetReturnValue().Set(info.Data());
258 }
259
260 static void createFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8: :Object> object, const char* name, v8::FunctionCallback callback, const char* de scription)
261 {
262 v8::Local<v8::String> funcName = v8String(context->GetIsolate(), name);
263 v8::Local<v8::Function> func;
264 if (!v8::Function::New(context, callback).ToLocal(&func))
265 return;
266 func->SetName(funcName);
267 v8::Local<v8::String> returnValue = v8String(context->GetIsolate(), descript ion);
268 v8::Local<v8::Function> toStringFunction;
269 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toS tringFunction))
270 func->Set(v8String(context->GetIsolate(), "toString"), toStringFunction) ;
271 if (!object->Set(context, funcName, func).FromMaybe(false))
272 return;
273 } 253 }
274 254
275 void MainThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> context, v8::Local<v8::Object> object) 255 void MainThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
276 { 256 {
257 ThreadDebugger::installAdditionalCommandLineAPI(context, object);
277 createFunctionProperty(context, object, "$", MainThreadDebugger::querySelect orCallback, "function $(selector, [startNode]) { [Command Line API] }"); 258 createFunctionProperty(context, object, "$", MainThreadDebugger::querySelect orCallback, "function $(selector, [startNode]) { [Command Line API] }");
278 createFunctionProperty(context, object, "$$", MainThreadDebugger::querySelec torAllCallback, "function $$(selector, [startNode]) { [Command Line API] }"); 259 createFunctionProperty(context, object, "$$", MainThreadDebugger::querySelec torAllCallback, "function $$(selector, [startNode]) { [Command Line API] }");
279 createFunctionProperty(context, object, "$x", MainThreadDebugger::xpathSelec torCallback, "function $x(xpath, [startNode]) { [Command Line API] }"); 260 createFunctionProperty(context, object, "$x", MainThreadDebugger::xpathSelec torCallback, "function $x(xpath, [startNode]) { [Command Line API] }");
280 } 261 }
281 262
282 static Node* secondArgumentAsNode(const v8::FunctionCallbackInfo<v8::Value>& inf o) 263 static Node* secondArgumentAsNode(const v8::FunctionCallbackInfo<v8::Value>& inf o)
283 { 264 {
284 if (info.Length() > 1) { 265 if (info.Length() > 1) {
285 if (Node* node = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]) ) 266 if (Node* node = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]) )
286 return node; 267 return node;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return; 349 return;
369 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get Isolate())).FromMaybe(false)) 350 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get Isolate())).FromMaybe(false))
370 return; 351 return;
371 } 352 }
372 info.GetReturnValue().Set(nodes); 353 info.GetReturnValue().Set(nodes);
373 } 354 }
374 exceptionState.throwIfNeeded(); 355 exceptionState.throwIfNeeded();
375 } 356 }
376 357
377 } // namespace blink 358 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/inspector/ThreadDebugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698