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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/proxy/proxy_server_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/proxy/proxy_server.h"
6
7 #include <CoreFoundation/CoreFoundation.h>
8
9 #include <string>
10
11 #include "base/logging.h"
12 #include "base/mac/foundation_util.h"
13 #include "base/strings/sys_string_conversions.h"
14
15 namespace net {
16
17 // static
18 ProxyServer ProxyServer::FromDictionary(Scheme scheme,
19 CFDictionaryRef dict,
20 CFStringRef host_key,
21 CFStringRef port_key) {
22 if (scheme == SCHEME_INVALID || scheme == SCHEME_DIRECT) {
23 // No hostname port to extract; we are done.
24 return ProxyServer(scheme, HostPortPair());
25 }
26
27 CFStringRef host_ref =
28 base::mac::GetValueFromDictionary<CFStringRef>(dict, host_key);
29 if (!host_ref) {
30 LOG(WARNING) << "Could not find expected key "
31 << base::SysCFStringRefToUTF8(host_key)
32 << " in the proxy dictionary";
33 return ProxyServer(); // Invalid.
34 }
35 std::string host = base::SysCFStringRefToUTF8(host_ref);
36
37 CFNumberRef port_ref =
38 base::mac::GetValueFromDictionary<CFNumberRef>(dict, port_key);
39 int port;
40 if (port_ref) {
41 CFNumberGetValue(port_ref, kCFNumberIntType, &port);
42 } else {
43 port = GetDefaultPortForScheme(scheme);
44 }
45
46 return ProxyServer(scheme, HostPortPair(host, port));
47 }
48
49 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/proxy/proxy_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698