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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
10 #include "content/browser/devtools/devtools_agent_host_impl.h" | 12 #include "content/browser/devtools/devtools_agent_host_impl.h" |
11 #include "content/browser/devtools/devtools_manager.h" | 13 #include "content/browser/devtools/devtools_manager.h" |
12 #include "content/public/browser/devtools_manager_delegate.h" | 14 #include "content/public/browser/devtools_manager_delegate.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 namespace { | 18 namespace { |
(...skipping 26 matching lines...) Expand all Loading... |
43 DevToolsProtocolHandler::~DevToolsProtocolHandler() { | 45 DevToolsProtocolHandler::~DevToolsProtocolHandler() { |
44 } | 46 } |
45 | 47 |
46 void DevToolsProtocolHandler::HandleMessage(int session_id, | 48 void DevToolsProtocolHandler::HandleMessage(int session_id, |
47 const std::string& message) { | 49 const std::string& message) { |
48 scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); | 50 scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); |
49 if (!command) | 51 if (!command) |
50 return; | 52 return; |
51 if (PassCommandToDelegate(session_id, command.get())) | 53 if (PassCommandToDelegate(session_id, command.get())) |
52 return; | 54 return; |
53 HandleCommand(session_id, command.Pass()); | 55 HandleCommand(session_id, std::move(command)); |
54 } | 56 } |
55 | 57 |
56 bool DevToolsProtocolHandler::HandleOptionalMessage(int session_id, | 58 bool DevToolsProtocolHandler::HandleOptionalMessage(int session_id, |
57 const std::string& message, | 59 const std::string& message, |
58 int* call_id) { | 60 int* call_id) { |
59 scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); | 61 scoped_ptr<base::DictionaryValue> command = ParseCommand(session_id, message); |
60 if (!command) | 62 if (!command) |
61 return true; | 63 return true; |
62 if (PassCommandToDelegate(session_id, command.get())) | 64 if (PassCommandToDelegate(session_id, command.get())) |
63 return true; | 65 return true; |
64 return HandleOptionalCommand(session_id, command.Pass(), call_id); | 66 return HandleOptionalCommand(session_id, std::move(command), call_id); |
65 } | 67 } |
66 | 68 |
67 bool DevToolsProtocolHandler::PassCommandToDelegate( | 69 bool DevToolsProtocolHandler::PassCommandToDelegate( |
68 int session_id, | 70 int session_id, |
69 base::DictionaryValue* command) { | 71 base::DictionaryValue* command) { |
70 DevToolsManagerDelegate* delegate = | 72 DevToolsManagerDelegate* delegate = |
71 DevToolsManager::GetInstance()->delegate(); | 73 DevToolsManager::GetInstance()->delegate(); |
72 if (!delegate) | 74 if (!delegate) |
73 return false; | 75 return false; |
74 | 76 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 DevToolsProtocolDispatcher::CommandHandler command_handler( | 150 DevToolsProtocolDispatcher::CommandHandler command_handler( |
149 dispatcher_.FindCommandHandler(method)); | 151 dispatcher_.FindCommandHandler(method)); |
150 if (!command_handler.is_null()) { | 152 if (!command_handler.is_null()) { |
151 return command_handler.Run(DevToolsCommandId(*call_id, session_id), | 153 return command_handler.Run(DevToolsCommandId(*call_id, session_id), |
152 TakeDictionary(command.get(), kParamsParam)); | 154 TakeDictionary(command.get(), kParamsParam)); |
153 } | 155 } |
154 return false; | 156 return false; |
155 } | 157 } |
156 | 158 |
157 } // namespace content | 159 } // namespace content |
OLD | NEW |