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

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc

Issue 1017853003: Add ClientConfig proto, and JSON generation/parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting and unit test fix. Created 5 years, 9 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
Index: components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
index 770e3316cf1ddb26fe353e3174b09ec9e3e99bb0..55c48efa52bc64c46bea0a65851c8dcecd2989fa 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
@@ -9,6 +9,8 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_piece.h"
+#include "base/values.h"
+#include "components/data_reduction_proxy/core/common/client_config_parser.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "net/base/host_port_pair.h"
#include "net/proxy/proxy_server.h"
@@ -386,6 +388,39 @@ bool DataReductionProxyParams::IsDataReductionProxy(
return false;
}
+void DataReductionProxyParams::PopulateConfigResponse(
+ base::DictionaryValue* response) const {
+ scoped_ptr<base::Value> proxy_config(new base::DictionaryValue());
bengr 2015/03/19 16:31:15 #include "base/memory/scoped_ptr.h"
jeremyim 2015/03/20 16:21:12 Done.
+ if (!holdback_) {
+ base::DictionaryValue* proxy_config_dict = nullptr;
+ if (!proxy_config->GetAsDictionary(&proxy_config_dict))
+ return;
+
+ scoped_ptr<base::Value> proxy_servers(new base::ListValue());
+ base::ListValue* proxy_servers_list = nullptr;
+ if (!proxy_servers->GetAsList(&proxy_servers_list))
+ return;
+
+ proxy_servers->GetAsList(&proxy_servers_list);
+ scoped_ptr<base::DictionaryValue> server(new base::DictionaryValue());
+
+ server->SetString("scheme", GetSchemeString(origin_.scheme()));
bengr 2015/03/19 16:31:15 It might be worthwhile to define constants for "sc
jeremyim 2015/03/20 16:21:12 Done.
+ server->SetString("host", origin_.host_port_pair().host());
+ server->SetInteger("port", origin_.host_port_pair().port());
+ proxy_servers_list->Append(server.release());
+ server.reset(new base::DictionaryValue());
+
+ server->SetString("scheme", GetSchemeString(fallback_origin_.scheme()));
+ server->SetString("host", fallback_origin_.host_port_pair().host());
+ server->SetInteger("port", fallback_origin_.host_port_pair().port());
+ proxy_servers_list->Append(server.release());
+
+ proxy_config_dict->Set("httpProxyServers", proxy_servers.Pass());
+ }
+
+ response->Set("proxyConfig", proxy_config.Pass());
+}
+
// Returns the data reduction proxy primary origin.
const net::ProxyServer& DataReductionProxyParams::origin() const {
return origin_;

Powered by Google App Engine
This is Rietveld 408576698