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

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

Issue 2024813002: DevTools: Fix Maximum call stack size exceeded error while retrieving CPU profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/json/string_escape.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "components/devtools_http_handler/devtools_http_handler.h" 18 #include "components/devtools_http_handler/devtools_http_handler.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 259 }
259 260
260 if (request_id) 261 if (request_id)
261 SendMessageAck(request_id, nullptr); 262 SendMessageAck(request_id, nullptr);
262 } 263 }
263 264
264 void ShellDevToolsFrontend::DispatchProtocolMessage( 265 void ShellDevToolsFrontend::DispatchProtocolMessage(
265 DevToolsAgentHost* agent_host, const std::string& message) { 266 DevToolsAgentHost* agent_host, const std::string& message) {
266 267
267 if (message.length() < kMaxMessageChunkSize) { 268 if (message.length() < kMaxMessageChunkSize) {
268 base::string16 javascript = base::UTF8ToUTF16( 269 std::string param;
269 "DevToolsAPI.dispatchMessage(" + message + ");"); 270 base::EscapeJSONString(message, true, &param);
271 std::string code = "DevToolsAPI.dispatchMessage(" + param + ");";
272 base::string16 javascript = base::UTF8ToUTF16(code);
270 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 273 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
271 return; 274 return;
272 } 275 }
273 276
274 base::FundamentalValue total_size(static_cast<int>(message.length())); 277 size_t total_size = message.length();
275 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { 278 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
276 std::string param; 279 std::string param;
277 base::JSONWriter::Write( 280 base::EscapeJSONString(message.substr(pos, kMaxMessageChunkSize), true,
278 base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param); 281 &param);
279 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");"; 282 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
283 std::to_string(pos ? 0 : total_size) + ");";
280 base::string16 javascript = base::UTF8ToUTF16(code); 284 base::string16 javascript = base::UTF8ToUTF16(code);
281 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 285 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
282 } 286 }
283 } 287 }
284 288
285 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) { 289 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
286 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc. 290 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc.
287 // We should handle some of the commands including this one in content. 291 // We should handle some of the commands including this one in content.
288 DCHECK(source); 292 DCHECK(source);
289 PendingRequestsMap::iterator it = pending_requests_.find(source); 293 PendingRequestsMap::iterator it = pending_requests_.find(source);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 CallClientFunction("DevToolsAPI.embedderMessageAck", 340 CallClientFunction("DevToolsAPI.embedderMessageAck",
337 &id_value, arg, nullptr); 341 &id_value, arg, nullptr);
338 } 342 }
339 343
340 void ShellDevToolsFrontend::AgentHostClosed( 344 void ShellDevToolsFrontend::AgentHostClosed(
341 DevToolsAgentHost* agent_host, bool replaced) { 345 DevToolsAgentHost* agent_host, bool replaced) {
342 frontend_shell_->Close(); 346 frontend_shell_->Close();
343 } 347 }
344 348
345 } // namespace content 349 } // 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