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

Unified Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 418243003: [DevTools] Move DispatchOnDevToolsFrontend to embedder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/devtools/devtools_frontend_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/devtools_ui_bindings.cc
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc
index e87b70a0f5533e5693e52b41b5467d94cfb46224..7441341915dcd449e82ca902afdac6ddc63a1b5b 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -409,8 +409,9 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend(
// content::DevToolsClientHost implementation ---------------------------------
void DevToolsUIBindings::DispatchOnInspectorFrontend(
const std::string& message) {
- if (frontend_host_)
- frontend_host_->DispatchOnDevToolsFrontend(message);
+ base::StringValue message_value(message);
+ CallClientFunction("InspectorFrontendAPI.dispatchMessage",
+ &message_value, NULL, NULL);
}
void DevToolsUIBindings::InspectedContentsClosing() {
@@ -796,8 +797,30 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
}
}
}
- base::string16 javascript =
- base::UTF8ToUTF16(function_name + "(" + params + ");");
+
+ std::string code = function_name + "(" + params + ");";
+#if defined(DEBUG_DEVTOOLS)
+ // To debug DevTools itself, we should postpone incoming messages while
+ // paused in debugger. To achieve this, we wrap all calls in setTimeout
+ // and rely on the fact that timers are suspended when debugging.
+ code = "(function() {"
+ " if (!window.__callClientFunction) window.__callClientFunction = [];"
pfeldman 2014/07/31 14:25:08 Should we do this on the front-end side instead?
dgozman 2014/07/31 15:09:32 Done.
+ ""
+ " function executeCall() {" + code + "}"
+ ""
+ " function onTimeout() {"
+ " while (window.__callClientFunction.length) {"
+ " window.__callClientFunction.shift()();"
+ " }"
+ " }"
+ ""
+ " window.__callClientFunction.push(executeCall);"
+ " if (window.__callClientFunction.length == 1)"
+ " window.setTimeout(onTimeout, 0);"
+ "})();";
+#endif // defined(DEBUG_DEVTOOLS)
+
+ base::string16 javascript = base::UTF8ToUTF16(code);
web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
}
« no previous file with comments | « no previous file | content/browser/devtools/devtools_frontend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698