Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: chrome/browser/devtools/chrome_devtools_manager_delegate.cc

Issue 319133002: DevToolsManagerDelegate: parse all "emulateNetworkConditions" parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win-gpu compiler warning Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_network_conditions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/chrome_devtools_manager_delegate.cc
diff --git a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
index 898f50a68b5d852843fbb3a856e9d7e3a5d845b1..31089eac346e7d468707b05a6dd420e7cc81ff7d 100644
--- a/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
+++ b/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
@@ -81,16 +81,39 @@ ChromeDevToolsManagerDelegate::EmulateNetworkConditions(
content::DevToolsAgentHost* agent_host,
DevToolsProtocol::Command* command) {
base::DictionaryValue* params = command->params();
+
+ std::vector<std::string> domains;
+ base::ListValue* domain_list = NULL;
+ const char* domains_param =
+ chrome::devtools::Network::emulateNetworkConditions::kParamDomains;
+ if (!params || !params->GetList(domains_param, &domain_list))
+ return command->InvalidParamResponse(domains_param);
+ size_t size = domain_list->GetSize();
+ for (size_t i = 0; i < size; ++i) {
+ std::string domain;
+ if (!domain_list->GetString(i, &domain))
+ return command->InvalidParamResponse(domains_param);
+ domains.push_back(domain);
+ }
+
bool offline = false;
const char* offline_param =
chrome::devtools::Network::emulateNetworkConditions::kParamOffline;
- if (!params || !params->GetBoolean(offline_param, &offline))
+ if (!params->GetBoolean(offline_param, &offline))
return command->InvalidParamResponse(offline_param);
+ double maximal_throughput = 0.0;
+ const char* maximal_throughput_param =
+chrome::devtools::Network::emulateNetworkConditions::kParamMaximalThroughput;
+ if (!params->GetDouble(maximal_throughput_param, &maximal_throughput))
+ return command->InvalidParamResponse(maximal_throughput_param);
+ if (maximal_throughput < 0.0)
+ maximal_throughput = 0.0;
+
EnsureDevtoolsCallbackRegistered();
scoped_refptr<DevToolsNetworkConditions> conditions;
- if (offline)
- conditions = new DevToolsNetworkConditions(std::vector<std::string>());
+ if (offline || maximal_throughput)
+ conditions = new DevToolsNetworkConditions(domains, maximal_throughput);
UpdateNetworkState(agent_host, conditions);
return command->SuccessResponse(NULL);
}
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_network_conditions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698