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

Side by Side Diff: content/shell/browser/shell_devtools_frontend.cc

Issue 2022673002: DevTools: Fix Maximum call stack size exceeded error while retrieving CPU profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make it more generic Created 4 years, 6 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 | « chrome/browser/devtools/devtools_ui_bindings.cc ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium 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 "content/shell/browser/shell_devtools_frontend.h" 5 #include "content/shell/browser/shell_devtools_frontend.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 if (request_id) 265 if (request_id)
266 SendMessageAck(request_id, nullptr); 266 SendMessageAck(request_id, nullptr);
267 } 267 }
268 268
269 void ShellDevToolsFrontend::DispatchProtocolMessage( 269 void ShellDevToolsFrontend::DispatchProtocolMessage(
270 DevToolsAgentHost* agent_host, const std::string& message) { 270 DevToolsAgentHost* agent_host, const std::string& message) {
271 271
272 if (message.length() < kMaxMessageChunkSize) { 272 if (message.length() < kMaxMessageChunkSize) {
273 base::string16 javascript = base::UTF8ToUTF16( 273 std::string param;
274 "DevToolsAPI.dispatchMessage(" + message + ");"); 274 base::JSONWriter::Write(base::StringValue(message), &param);
pfeldman 2016/05/28 02:26:03 EscapeJSONString
alph 2016/05/28 02:37:03 Done.
275 std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
276 base::string16 javascript = base::UTF8ToUTF16(code);
275 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 277 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
276 return; 278 return;
277 } 279 }
278 280
279 base::FundamentalValue total_size(static_cast<int>(message.length())); 281 size_t total_size = message.length();
280 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { 282 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
281 std::string param; 283 std::string param;
282 base::JSONWriter::Write( 284 base::JSONWriter::Write(
283 base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param); 285 base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param);
284 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");"; 286 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
287 std::to_string(pos ? 0 : total_size) + ");";
285 base::string16 javascript = base::UTF8ToUTF16(code); 288 base::string16 javascript = base::UTF8ToUTF16(code);
286 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 289 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
287 } 290 }
288 } 291 }
289 292
290 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) { 293 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
291 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc. 294 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc.
292 // We should handle some of the commands including this one in content. 295 // We should handle some of the commands including this one in content.
293 DCHECK(source); 296 DCHECK(source);
294 PendingRequestsMap::iterator it = pending_requests_.find(source); 297 PendingRequestsMap::iterator it = pending_requests_.find(source);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 CallClientFunction("DevToolsAPI.embedderMessageAck", 344 CallClientFunction("DevToolsAPI.embedderMessageAck",
342 &id_value, arg, nullptr); 345 &id_value, arg, nullptr);
343 } 346 }
344 347
345 void ShellDevToolsFrontend::AgentHostClosed( 348 void ShellDevToolsFrontend::AgentHostClosed(
346 DevToolsAgentHost* agent_host, bool replaced) { 349 DevToolsAgentHost* agent_host, bool replaced) {
347 frontend_shell_->Close(); 350 frontend_shell_->Close();
348 } 351 }
349 352
350 } // namespace content 353 } // namespace content
OLDNEW
« 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