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, ¶m); |
- 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, ¶m); |
+ std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");"; |
+ base::string16 javascript = base::UTF8ToUTF16(code); |
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); |
+ } |
} |
void ShellDevToolsFrontend::AgentHostClosed( |