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 "chrome/browser/devtools/devtools_network_protocol_handler.h" | 5 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/devtools/devtools_network_conditions.h" | 10 #include "chrome/browser/devtools/devtools_network_conditions.h" |
11 #include "chrome/browser/devtools/devtools_network_controller_handle.h" | 11 #include "chrome/browser/devtools/devtools_network_controller_handle.h" |
12 #include "chrome/browser/devtools/devtools_protocol_constants.h" | 12 #include "chrome/browser/devtools/devtools_protocol_constants.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 | 16 |
17 DevToolsNetworkProtocolHandler::DevToolsNetworkProtocolHandler() { | 17 DevToolsNetworkProtocolHandler::DevToolsNetworkProtocolHandler() { |
18 } | 18 } |
19 | 19 |
20 DevToolsNetworkProtocolHandler::~DevToolsNetworkProtocolHandler() { | 20 DevToolsNetworkProtocolHandler::~DevToolsNetworkProtocolHandler() { |
21 } | 21 } |
22 | 22 |
23 base::DictionaryValue* DevToolsNetworkProtocolHandler::HandleCommand( | 23 base::DictionaryValue* DevToolsNetworkProtocolHandler::HandleCommand( |
24 content::DevToolsAgentHost* agent_host, | 24 content::DevToolsAgentHost* agent_host, |
25 base::DictionaryValue* command_dict) { | 25 int id, |
26 int id = 0; | 26 const std::string& method, |
27 std::string method; | 27 base::DictionaryValue* params) { |
28 base::DictionaryValue* params = nullptr; | |
29 if (!DevToolsProtocol::ParseCommand(command_dict, &id, &method, ¶ms)) | |
30 return nullptr; | |
31 | |
32 namespace network = ::chrome::devtools::Network; | 28 namespace network = ::chrome::devtools::Network; |
33 | 29 |
34 if (method == network::emulateNetworkConditions::kName) | 30 if (method == network::emulateNetworkConditions::kName) |
35 return EmulateNetworkConditions(agent_host, id, params).release(); | 31 return EmulateNetworkConditions(agent_host, id, params).release(); |
36 | 32 |
37 if (method == network::canEmulateNetworkConditions::kName) | 33 if (method == network::canEmulateNetworkConditions::kName) |
38 return CanEmulateNetworkConditions(agent_host, id, params).release(); | 34 return CanEmulateNetworkConditions(agent_host, id, params).release(); |
39 | 35 |
40 return nullptr; | 36 return nullptr; |
41 } | 37 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 103 } |
108 | 104 |
109 void DevToolsNetworkProtocolHandler::DevToolsAgentStateChanged( | 105 void DevToolsNetworkProtocolHandler::DevToolsAgentStateChanged( |
110 content::DevToolsAgentHost* agent_host, | 106 content::DevToolsAgentHost* agent_host, |
111 bool attached) { | 107 bool attached) { |
112 scoped_ptr<DevToolsNetworkConditions> conditions; | 108 scoped_ptr<DevToolsNetworkConditions> conditions; |
113 if (attached) | 109 if (attached) |
114 conditions.reset(new DevToolsNetworkConditions()); | 110 conditions.reset(new DevToolsNetworkConditions()); |
115 UpdateNetworkState(agent_host, std::move(conditions)); | 111 UpdateNetworkState(agent_host, std::move(conditions)); |
116 } | 112 } |
OLD | NEW |