OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_handler.h" | 5 #include "content/browser/devtools/devtools_protocol_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 client_.SendMessage(session_id, *response); | 87 client_.SendMessage(session_id, *response); |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 return false; | 91 return false; |
92 } | 92 } |
93 | 93 |
94 std::unique_ptr<base::DictionaryValue> DevToolsProtocolHandler::ParseCommand( | 94 std::unique_ptr<base::DictionaryValue> DevToolsProtocolHandler::ParseCommand( |
95 int session_id, | 95 int session_id, |
96 std::unique_ptr<base::Value> value) { | 96 std::unique_ptr<base::Value> value) { |
97 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) { | 97 if (!value || !value->IsType(base::Value::Type::DICTIONARY)) { |
98 client_.SendError( | 98 client_.SendError( |
99 DevToolsCommandId(DevToolsCommandId::kNoId, session_id), | 99 DevToolsCommandId(DevToolsCommandId::kNoId, session_id), |
100 Response(kStatusParseError, "Message must be in JSON format")); | 100 Response(kStatusParseError, "Message must be in JSON format")); |
101 return nullptr; | 101 return nullptr; |
102 } | 102 } |
103 | 103 |
104 std::unique_ptr<base::DictionaryValue> command = | 104 std::unique_ptr<base::DictionaryValue> command = |
105 base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); | 105 base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); |
106 int call_id = DevToolsCommandId::kNoId; | 106 int call_id = DevToolsCommandId::kNoId; |
107 bool ok = command->GetInteger(kIdParam, &call_id) && call_id >= 0; | 107 bool ok = command->GetInteger(kIdParam, &call_id) && call_id >= 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 DevToolsProtocolDispatcher::CommandHandler command_handler( | 156 DevToolsProtocolDispatcher::CommandHandler command_handler( |
157 dispatcher_.FindCommandHandler(*method)); | 157 dispatcher_.FindCommandHandler(*method)); |
158 if (!command_handler.is_null()) { | 158 if (!command_handler.is_null()) { |
159 return command_handler.Run(DevToolsCommandId(*call_id, session_id), | 159 return command_handler.Run(DevToolsCommandId(*call_id, session_id), |
160 TakeDictionary(command.get(), kParamsParam)); | 160 TakeDictionary(command.get(), kParamsParam)); |
161 } | 161 } |
162 return false; | 162 return false; |
163 } | 163 } |
164 | 164 |
165 } // namespace content | 165 } // namespace content |
OLD | NEW |