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

Side by Side Diff: headless/lib/browser/headless_devtools_client_impl.cc

Issue 1898633006: headless: Fix handling of replies without any parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "headless/lib/browser/headless_devtools_client_impl.h" 5 #include "headless/lib/browser/headless_devtools_client_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 NOTREACHED() << "Badly formed reply"; 88 NOTREACHED() << "Badly formed reply";
89 return; 89 return;
90 } 90 }
91 int id = 0; 91 int id = 0;
92 DCHECK(message_dict->GetInteger("id", &id)); 92 DCHECK(message_dict->GetInteger("id", &id));
93 auto it = pending_messages_.find(id); 93 auto it = pending_messages_.find(id);
94 if (it == pending_messages_.end()) { 94 if (it == pending_messages_.end()) {
95 NOTREACHED() << "Unexpected reply"; 95 NOTREACHED() << "Unexpected reply";
96 return; 96 return;
97 } 97 }
98 base::DictionaryValue* result_dict; 98 if (!it->second.callback_with_result.is_null()) {
99 if (message_dict->GetDictionary("result", &result_dict)) { 99 base::DictionaryValue* result_dict;
100 if (!message_dict->GetDictionary("result", &result_dict)) {
101 NOTREACHED() << "Badly formed reply result";
102 return;
103 }
100 it->second.callback_with_result.Run(*result_dict); 104 it->second.callback_with_result.Run(*result_dict);
101 } else { 105 } else if (!it->second.callback.is_null()) {
102 it->second.callback.Run(); 106 it->second.callback.Run();
103 } 107 }
104 pending_messages_.erase(it); 108 pending_messages_.erase(it);
105 } 109 }
106 110
107 void HeadlessDevToolsClientImpl::AgentHostClosed( 111 void HeadlessDevToolsClientImpl::AgentHostClosed(
108 content::DevToolsAgentHost* agent_host, 112 content::DevToolsAgentHost* agent_host,
109 bool replaced_with_another_client) { 113 bool replaced_with_another_client) {
110 DCHECK_EQ(agent_host_, agent_host); 114 DCHECK_EQ(agent_host_, agent_host);
111 agent_host = nullptr; 115 agent_host = nullptr;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 base::Callback<void(const base::Value&)> callback) 303 base::Callback<void(const base::Value&)> callback)
300 : callback_with_result(callback) {} 304 : callback_with_result(callback) {}
301 305
302 HeadlessDevToolsClientImpl::PendingMessage::~PendingMessage() {} 306 HeadlessDevToolsClientImpl::PendingMessage::~PendingMessage() {}
303 307
304 HeadlessDevToolsClientImpl::PendingMessage& 308 HeadlessDevToolsClientImpl::PendingMessage&
305 HeadlessDevToolsClientImpl::PendingMessage::operator=(PendingMessage&& other) = 309 HeadlessDevToolsClientImpl::PendingMessage::operator=(PendingMessage&& other) =
306 default; 310 default;
307 311
308 } // namespace headless 312 } // namespace headless
OLDNEW
« no previous file with comments | « no previous file | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698