| 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 "chrome/browser/devtools/devtools_protocol.h" | 5 #include "chrome/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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 int id; | 122 int id; |
| 123 if (!command_dict->GetInteger(kIdParam, &id) || id < 0) | 123 if (!command_dict->GetInteger(kIdParam, &id) || id < 0) |
| 124 return NULL; | 124 return NULL; |
| 125 | 125 |
| 126 std::string method; | 126 std::string method; |
| 127 if (!command_dict->GetString(kMethodParam, &method)) | 127 if (!command_dict->GetString(kMethodParam, &method)) |
| 128 return NULL; | 128 return NULL; |
| 129 | 129 |
| 130 base::DictionaryValue* params = NULL; | 130 base::DictionaryValue* params = NULL; |
| 131 command_dict->GetDictionary(kParamsParam, ¶ms); | 131 command_dict->GetDictionary(kParamsParam, ¶ms); |
| 132 return new Command(id, method, params ? params->DeepCopy() : NULL); | 132 return new Command(id, method, params); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // static | 135 // static |
| 136 DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification( | 136 DevToolsProtocol::Notification* DevToolsProtocol::ParseNotification( |
| 137 const std::string& json) { | 137 const std::string& json) { |
| 138 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); | 138 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); |
| 139 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) | 139 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) |
| 140 return NULL; | 140 return NULL; |
| 141 | 141 |
| 142 scoped_ptr<base::DictionaryValue> dict( | 142 scoped_ptr<base::DictionaryValue> dict( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 163 int id; | 163 int id; |
| 164 if (!dict->GetInteger(kIdParam, &id)) | 164 if (!dict->GetInteger(kIdParam, &id)) |
| 165 return NULL; | 165 return NULL; |
| 166 | 166 |
| 167 int error_code = 0; | 167 int error_code = 0; |
| 168 base::DictionaryValue* error_dict = NULL; | 168 base::DictionaryValue* error_dict = NULL; |
| 169 if (dict->GetDictionary(kErrorParam, &error_dict)) | 169 if (dict->GetDictionary(kErrorParam, &error_dict)) |
| 170 error_dict->GetInteger(kErrorCodeParam, &error_code); | 170 error_dict->GetInteger(kErrorCodeParam, &error_code); |
| 171 return new Response(id, error_code, std::string()); | 171 return new Response(id, error_code, std::string()); |
| 172 } | 172 } |
| OLD | NEW |