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

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: 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
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 int ResponseWriter::Finish(const net::CompletionCallback& callback) { 95 int ResponseWriter::Finish(const net::CompletionCallback& callback) {
96 return net::OK; 96 return net::OK;
97 } 97 }
98 98
99 } // namespace 99 } // namespace
100 100
101 // This constant should be in sync with 101 // This constant should be in sync with
102 // the constant at devtools_ui_bindings.cc. 102 // the constant at devtools_ui_bindings.cc.
103 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; 103 const size_t kMaxMessageChunkSize =
104 std::min(IPC::Channel::kMaximumMessageSize / 4, 20480ul);
104 105
105 // static 106 // static
106 ShellDevToolsFrontend* ShellDevToolsFrontend::Show( 107 ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
107 WebContents* inspected_contents) { 108 WebContents* inspected_contents) {
108 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(), 109 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(),
109 GURL(), 110 GURL(),
110 NULL, 111 NULL,
111 gfx::Size()); 112 gfx::Size());
112 ShellDevToolsFrontend* devtools_frontend = new ShellDevToolsFrontend( 113 ShellDevToolsFrontend* devtools_frontend = new ShellDevToolsFrontend(
113 shell, 114 shell,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 void ShellDevToolsFrontend::DispatchProtocolMessage( 270 void ShellDevToolsFrontend::DispatchProtocolMessage(
270 DevToolsAgentHost* agent_host, const std::string& message) { 271 DevToolsAgentHost* agent_host, const std::string& message) {
271 272
272 if (message.length() < kMaxMessageChunkSize) { 273 if (message.length() < kMaxMessageChunkSize) {
273 base::string16 javascript = base::UTF8ToUTF16( 274 base::string16 javascript = base::UTF8ToUTF16(
274 "DevToolsAPI.dispatchMessage(" + message + ");"); 275 "DevToolsAPI.dispatchMessage(" + message + ");");
275 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 276 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
276 return; 277 return;
277 } 278 }
278 279
279 base::FundamentalValue total_size(static_cast<int>(message.length())); 280 size_t total_size = message.length();
280 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { 281 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
281 std::string param; 282 std::string param;
282 base::JSONWriter::Write( 283 base::JSONWriter::Write(
283 base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param); 284 base::StringValue(message.substr(pos, kMaxMessageChunkSize)), &param);
284 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");"; 285 std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + "," +
286 std::to_string(pos ? 0 : total_size) + ");";
285 base::string16 javascript = base::UTF8ToUTF16(code); 287 base::string16 javascript = base::UTF8ToUTF16(code);
286 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript); 288 web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
287 } 289 }
288 } 290 }
289 291
290 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) { 292 void ShellDevToolsFrontend::OnURLFetchComplete(const net::URLFetcher* source) {
291 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc. 293 // 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. 294 // We should handle some of the commands including this one in content.
293 DCHECK(source); 295 DCHECK(source);
294 PendingRequestsMap::iterator it = pending_requests_.find(source); 296 PendingRequestsMap::iterator it = pending_requests_.find(source);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 CallClientFunction("DevToolsAPI.embedderMessageAck", 343 CallClientFunction("DevToolsAPI.embedderMessageAck",
342 &id_value, arg, nullptr); 344 &id_value, arg, nullptr);
343 } 345 }
344 346
345 void ShellDevToolsFrontend::AgentHostClosed( 347 void ShellDevToolsFrontend::AgentHostClosed(
346 DevToolsAgentHost* agent_host, bool replaced) { 348 DevToolsAgentHost* agent_host, bool replaced) {
347 frontend_shell_->Close(); 349 frontend_shell_->Close();
348 } 350 }
349 351
350 } // namespace content 352 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698