OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/devtools/devtools_protocol.h" | 5 #include "content/browser/devtools/devtools_protocol.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 | 10 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 //static | 254 //static |
255 scoped_refptr<DevToolsProtocol::Response> | 255 scoped_refptr<DevToolsProtocol::Response> |
256 DevToolsProtocol::ParseResponse( | 256 DevToolsProtocol::ParseResponse( |
257 base::DictionaryValue* response_dict) { | 257 base::DictionaryValue* response_dict) { |
258 int id; | 258 int id; |
259 if (!response_dict->GetInteger(kIdParam, &id)) | 259 if (!response_dict->GetInteger(kIdParam, &id)) |
260 id = kNoId; | 260 id = kNoId; |
261 | 261 |
262 int error_code; | 262 const base::DictionaryValue* error_dict; |
263 if (!response_dict->GetInteger(kErrorCodeParam, &error_code)) | 263 if (response_dict->GetDictionary(kErrorParam, &error_dict)) { |
264 return new Response(id, kErrorInternalError, "Invalid response"); | 264 int error_code = kErrorInternalError; |
265 | 265 response_dict->GetInteger(kErrorCodeParam, &error_code); |
266 if (error_code) { | |
267 std::string error_message; | 266 std::string error_message; |
268 response_dict->GetString(kErrorMessageParam, &error_message); | 267 response_dict->GetString(kErrorMessageParam, &error_message); |
269 return new Response(id, error_code, error_message); | 268 return new Response(id, error_code, error_message); |
270 } | 269 } |
271 | 270 |
272 const base::DictionaryValue* result = NULL; | 271 const base::DictionaryValue* result = NULL; |
273 response_dict->GetDictionary(kResultParam, &result); | 272 response_dict->GetDictionary(kResultParam, &result); |
274 return new Response(id, result ? result->DeepCopy() : NULL); | 273 return new Response(id, result ? result->DeepCopy() : NULL); |
275 } | 274 } |
276 | 275 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 new Response(0, kErrorParseError, error_message); | 313 new Response(0, kErrorParseError, error_message); |
315 if (error_response) | 314 if (error_response) |
316 *error_response = response->Serialize(); | 315 *error_response = response->Serialize(); |
317 return NULL; | 316 return NULL; |
318 } | 317 } |
319 | 318 |
320 return static_cast<base::DictionaryValue*>(message.release()); | 319 return static_cast<base::DictionaryValue*>(message.release()); |
321 } | 320 } |
322 | 321 |
323 } // namespace content | 322 } // namespace content |
OLD | NEW |