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

Unified Diff: content/shell/browser/shell_devtools_frontend.cc

Issue 784513002: DevTools: speed up DevToolsUIBindings::DispatchProtocolMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years 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 | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/shell_devtools_frontend.cc
diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc
index e7fe05cc2b385c9cbb6291b5c824efe36b09ea22..50da820da7447e9d22c30bf896341a609fe75d9d 100644
--- a/content/shell/browser/shell_devtools_frontend.cc
+++ b/content/shell/browser/shell_devtools_frontend.cc
@@ -26,6 +26,10 @@
namespace content {
+// This constant should be in sync with
+// the constant at devtools_ui_bindings.cc.
+const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
+
// static
ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
WebContents* inspected_contents) {
@@ -129,12 +133,23 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
void ShellDevToolsFrontend::DispatchProtocolMessage(
DevToolsAgentHost* agent_host, const std::string& message) {
- base::StringValue message_value(message);
- std::string param;
- base::JSONWriter::Write(&message_value, &param);
- std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
- base::string16 javascript = base::UTF8ToUTF16(code);
- web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+
+ if (message.length() < kMaxMessageChunkSize) {
+ base::string16 javascript = base::UTF8ToUTF16(
+ "DevToolsAPI.dispatchMessage(" + message + ");");
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+ return;
+ }
+
+ base::FundamentalValue total_size(static_cast<int>(message.length()));
+ for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
+ base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize));
+ std::string param;
+ base::JSONWriter::Write(&message_value, &param);
+ std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
+ base::string16 javascript = base::UTF8ToUTF16(code);
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+ }
}
void ShellDevToolsFrontend::AgentHostClosed(
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698