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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 // static | 90 // static |
91 bool DevToolsProtocol::ParseNotification( | 91 bool DevToolsProtocol::ParseNotification( |
92 const std::string& json, | 92 const std::string& json, |
93 std::string* method, | 93 std::string* method, |
94 std::unique_ptr<base::DictionaryValue>* params) { | 94 std::unique_ptr<base::DictionaryValue>* params) { |
95 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 95 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
96 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) | 96 if (!value || !value->IsType(base::Value::Type::DICTIONARY)) |
97 return false; | 97 return false; |
98 | 98 |
99 std::unique_ptr<base::DictionaryValue> dict( | 99 std::unique_ptr<base::DictionaryValue> dict( |
100 static_cast<base::DictionaryValue*>(value.release())); | 100 static_cast<base::DictionaryValue*>(value.release())); |
101 | 101 |
102 if (!dict->GetString(kMethodParam, method)) | 102 if (!dict->GetString(kMethodParam, method)) |
103 return false; | 103 return false; |
104 | 104 |
105 std::unique_ptr<base::Value> params_value; | 105 std::unique_ptr<base::Value> params_value; |
106 dict->Remove(kParamsParam, ¶ms_value); | 106 dict->Remove(kParamsParam, ¶ms_value); |
107 if (params_value && params_value->IsType(base::Value::TYPE_DICTIONARY)) | 107 if (params_value && params_value->IsType(base::Value::Type::DICTIONARY)) |
108 params->reset(static_cast<base::DictionaryValue*>(params_value.release())); | 108 params->reset(static_cast<base::DictionaryValue*>(params_value.release())); |
109 | 109 |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 // static | 113 // static |
114 bool DevToolsProtocol::ParseResponse(const std::string& json, | 114 bool DevToolsProtocol::ParseResponse(const std::string& json, |
115 int* command_id, | 115 int* command_id, |
116 int* error_code) { | 116 int* error_code) { |
117 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 117 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
118 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) | 118 if (!value || !value->IsType(base::Value::Type::DICTIONARY)) |
119 return false; | 119 return false; |
120 | 120 |
121 std::unique_ptr<base::DictionaryValue> dict( | 121 std::unique_ptr<base::DictionaryValue> dict( |
122 static_cast<base::DictionaryValue*>(value.release())); | 122 static_cast<base::DictionaryValue*>(value.release())); |
123 | 123 |
124 if (!dict->GetInteger(kIdParam, command_id)) | 124 if (!dict->GetInteger(kIdParam, command_id)) |
125 return false; | 125 return false; |
126 | 126 |
127 *error_code = 0; | 127 *error_code = 0; |
128 base::DictionaryValue* error_dict = nullptr; | 128 base::DictionaryValue* error_dict = nullptr; |
129 if (dict->GetDictionary(kErrorParam, &error_dict)) | 129 if (dict->GetDictionary(kErrorParam, &error_dict)) |
130 error_dict->GetInteger(kErrorCodeParam, error_code); | 130 error_dict->GetInteger(kErrorCodeParam, error_code); |
131 return true; | 131 return true; |
132 } | 132 } |
OLD | NEW |