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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 // static | 114 // static |
115 bool DevToolsProtocol::ParseResponse(const std::string& json, | 115 bool DevToolsProtocol::ParseResponse(const std::string& json, |
116 int* command_id, | 116 int* command_id, |
117 int* error_code) { | 117 int* error_code) { |
118 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); | 118 scoped_ptr<base::Value> value(base::JSONReader::Read(json)); |
119 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) | 119 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) |
120 return nullptr; | 120 return false; |
121 | 121 |
122 scoped_ptr<base::DictionaryValue> dict( | 122 scoped_ptr<base::DictionaryValue> dict( |
123 static_cast<base::DictionaryValue*>(value.release())); | 123 static_cast<base::DictionaryValue*>(value.release())); |
124 | 124 |
125 if (!dict->GetInteger(kIdParam, command_id)) | 125 if (!dict->GetInteger(kIdParam, command_id)) |
126 return nullptr; | 126 return false; |
127 | 127 |
128 *error_code = 0; | 128 *error_code = 0; |
129 base::DictionaryValue* error_dict = nullptr; | 129 base::DictionaryValue* error_dict = nullptr; |
130 if (dict->GetDictionary(kErrorParam, &error_dict)) | 130 if (dict->GetDictionary(kErrorParam, &error_dict)) |
131 error_dict->GetInteger(kErrorCodeParam, error_code); | 131 error_dict->GetInteger(kErrorCodeParam, error_code); |
132 return true; | 132 return true; |
133 } | 133 } |
OLD | NEW |