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 19 matching lines...) Expand all Loading... |
30 int command_id, | 30 int command_id, |
31 const std::string& method, | 31 const std::string& method, |
32 scoped_ptr<base::DictionaryValue> params) { | 32 scoped_ptr<base::DictionaryValue> params) { |
33 base::DictionaryValue command; | 33 base::DictionaryValue command; |
34 command.SetInteger(kIdParam, command_id); | 34 command.SetInteger(kIdParam, command_id); |
35 command.SetString(kMethodParam, method); | 35 command.SetString(kMethodParam, method); |
36 if (params) | 36 if (params) |
37 command.Set(kParamsParam, params.release()); | 37 command.Set(kParamsParam, params.release()); |
38 | 38 |
39 std::string json_command; | 39 std::string json_command; |
40 base::JSONWriter::Write(&command, &json_command); | 40 base::JSONWriter::Write(command, &json_command); |
41 return json_command; | 41 return json_command; |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 scoped_ptr<base::DictionaryValue> | 45 scoped_ptr<base::DictionaryValue> |
46 DevToolsProtocol::CreateInvalidParamsResponse(int command_id, | 46 DevToolsProtocol::CreateInvalidParamsResponse(int command_id, |
47 const std::string& param) { | 47 const std::string& param) { |
48 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); | 48 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); |
49 base::DictionaryValue* error_object = new base::DictionaryValue(); | 49 base::DictionaryValue* error_object = new base::DictionaryValue(); |
50 response->Set(kErrorParam, error_object); | 50 response->Set(kErrorParam, error_object); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 if (!dict->GetInteger(kIdParam, command_id)) | 125 if (!dict->GetInteger(kIdParam, command_id)) |
126 return false; | 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 |