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

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

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Rebase Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_bindings.h" 5 #include "content/shell/browser/shell_devtools_bindings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility>
10
9 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
11 #include "base/json/string_escape.h" 13 #include "base/json/string_escape.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 19 #include "base/values.h"
17 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_frame_host.h" 21 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/storage_partition.h" 23 #include "content/public/browser/storage_partition.h"
21 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 319 }
317 320
318 void ShellDevToolsBindings::OnURLFetchComplete(const net::URLFetcher* source) { 321 void ShellDevToolsBindings::OnURLFetchComplete(const net::URLFetcher* source) {
319 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc. 322 // TODO(pfeldman): this is a copy of chrome's devtools_ui_bindings.cc.
320 // We should handle some of the commands including this one in content. 323 // We should handle some of the commands including this one in content.
321 DCHECK(source); 324 DCHECK(source);
322 PendingRequestsMap::iterator it = pending_requests_.find(source); 325 PendingRequestsMap::iterator it = pending_requests_.find(source);
323 DCHECK(it != pending_requests_.end()); 326 DCHECK(it != pending_requests_.end());
324 327
325 base::DictionaryValue response; 328 base::DictionaryValue response;
326 base::DictionaryValue* headers = new base::DictionaryValue(); 329 auto headers = base::MakeUnique<base::DictionaryValue>();
327 net::HttpResponseHeaders* rh = source->GetResponseHeaders(); 330 net::HttpResponseHeaders* rh = source->GetResponseHeaders();
328 response.SetInteger("statusCode", rh ? rh->response_code() : 200); 331 response.SetInteger("statusCode", rh ? rh->response_code() : 200);
329 response.Set("headers", headers);
330 332
331 size_t iterator = 0; 333 size_t iterator = 0;
332 std::string name; 334 std::string name;
333 std::string value; 335 std::string value;
334 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value)) 336 while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
335 headers->SetString(name, value); 337 headers->SetString(name, value);
338 response.Set("headers", std::move(headers));
336 339
337 SendMessageAck(it->second, &response); 340 SendMessageAck(it->second, &response);
338 pending_requests_.erase(it); 341 pending_requests_.erase(it);
339 delete source; 342 delete source;
340 } 343 }
341 344
342 void ShellDevToolsBindings::CallClientFunction(const std::string& function_name, 345 void ShellDevToolsBindings::CallClientFunction(const std::string& function_name,
343 const base::Value* arg1, 346 const base::Value* arg1,
344 const base::Value* arg2, 347 const base::Value* arg2,
345 const base::Value* arg3) { 348 const base::Value* arg3) {
(...skipping 23 matching lines...) Expand all
369 } 372 }
370 373
371 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host, 374 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host,
372 bool replaced) { 375 bool replaced) {
373 agent_host_ = nullptr; 376 agent_host_ = nullptr;
374 if (delegate_) 377 if (delegate_)
375 delegate_->Close(); 378 delegate_->Close();
376 } 379 }
377 380
378 } // namespace content 381 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/peer_connection_tracker.cc ('k') | content/shell/browser/shell_net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698