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

Side by Side Diff: net/proxy/proxy_config.cc

Issue 1149763005: Change NetLog::ParametersCallback to return a scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments on ownership removed Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « net/log/net_log_util.cc ('k') | net/proxy/proxy_resolver_v8_tracing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/proxy/proxy_config.h" 5 #include "net/proxy/proxy_config.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 bool ProxyConfig::HasAutomaticSettings() const { 225 bool ProxyConfig::HasAutomaticSettings() const {
226 return auto_detect_ || has_pac_url(); 226 return auto_detect_ || has_pac_url();
227 } 227 }
228 228
229 void ProxyConfig::ClearAutomaticSettings() { 229 void ProxyConfig::ClearAutomaticSettings() {
230 auto_detect_ = false; 230 auto_detect_ = false;
231 pac_url_ = GURL(); 231 pac_url_ = GURL();
232 } 232 }
233 233
234 base::DictionaryValue* ProxyConfig::ToValue() const { 234 base::DictionaryValue* ProxyConfig::ToValue() const {
235 base::DictionaryValue* dict = new base::DictionaryValue(); 235 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
236 236
237 // Output the automatic settings. 237 // Output the automatic settings.
238 if (auto_detect_) 238 if (auto_detect_)
239 dict->SetBoolean("auto_detect", auto_detect_); 239 dict->SetBoolean("auto_detect", auto_detect_);
240 if (has_pac_url()) { 240 if (has_pac_url()) {
241 dict->SetString("pac_url", pac_url_.possibly_invalid_spec()); 241 dict->SetString("pac_url", pac_url_.possibly_invalid_spec());
242 if (pac_mandatory_) 242 if (pac_mandatory_)
243 dict->SetBoolean("pac_mandatory", pac_mandatory_); 243 dict->SetBoolean("pac_mandatory", pac_mandatory_);
244 } 244 }
245 245
246 // Output the manual settings. 246 // Output the manual settings.
247 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) { 247 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) {
248 switch (proxy_rules_.type) { 248 switch (proxy_rules_.type) {
249 case ProxyRules::TYPE_SINGLE_PROXY: 249 case ProxyRules::TYPE_SINGLE_PROXY:
250 AddProxyListToValue("single_proxy", 250 AddProxyListToValue("single_proxy", proxy_rules_.single_proxies,
251 proxy_rules_.single_proxies, dict); 251 dict.get());
252 break; 252 break;
253 case ProxyRules::TYPE_PROXY_PER_SCHEME: { 253 case ProxyRules::TYPE_PROXY_PER_SCHEME: {
254 base::DictionaryValue* dict2 = new base::DictionaryValue(); 254 scoped_ptr<base::DictionaryValue> dict2(new base::DictionaryValue());
255 AddProxyListToValue("http", proxy_rules_.proxies_for_http, dict2); 255 AddProxyListToValue("http", proxy_rules_.proxies_for_http, dict2.get());
256 AddProxyListToValue("https", proxy_rules_.proxies_for_https, dict2); 256 AddProxyListToValue("https", proxy_rules_.proxies_for_https,
257 AddProxyListToValue("ftp", proxy_rules_.proxies_for_ftp, dict2); 257 dict2.get());
258 AddProxyListToValue("fallback", proxy_rules_.fallback_proxies, dict2); 258 AddProxyListToValue("ftp", proxy_rules_.proxies_for_ftp, dict2.get());
259 dict->Set("proxy_per_scheme", dict2); 259 AddProxyListToValue("fallback", proxy_rules_.fallback_proxies,
260 dict2.get());
261 dict->Set("proxy_per_scheme", dict2.Pass());
260 break; 262 break;
261 } 263 }
262 default: 264 default:
263 NOTREACHED(); 265 NOTREACHED();
264 } 266 }
265 267
266 // Output the bypass rules. 268 // Output the bypass rules.
267 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules; 269 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules;
268 if (!bypass.rules().empty()) { 270 if (!bypass.rules().empty()) {
269 if (proxy_rules_.reverse_bypass) 271 if (proxy_rules_.reverse_bypass)
270 dict->SetBoolean("reverse_bypass", true); 272 dict->SetBoolean("reverse_bypass", true);
271 273
272 base::ListValue* list = new base::ListValue(); 274 base::ListValue* list = new base::ListValue();
273 275
274 for (ProxyBypassRules::RuleList::const_iterator it = 276 for (ProxyBypassRules::RuleList::const_iterator it =
275 bypass.rules().begin(); 277 bypass.rules().begin();
276 it != bypass.rules().end(); ++it) { 278 it != bypass.rules().end(); ++it) {
277 list->Append(new base::StringValue((*it)->ToString())); 279 list->Append(new base::StringValue((*it)->ToString()));
278 } 280 }
279 281
280 dict->Set("bypass_list", list); 282 dict->Set("bypass_list", list);
281 } 283 }
282 } 284 }
283 285
284 // Output the source. 286 // Output the source.
285 dict->SetString("source", ProxyConfigSourceToString(source_)); 287 dict->SetString("source", ProxyConfigSourceToString(source_));
286 288
287 return dict; 289 return dict.release();
288 } 290 }
289 291
290 } // namespace net 292 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log_util.cc ('k') | net/proxy/proxy_resolver_v8_tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698