OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/dhcp_proxy_script_fetcher_factory.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
6 | 6 |
7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
8 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 8 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" | 11 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
12 #endif | 12 #endif |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() | 16 DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() |
17 : feature_enabled_(false) { | 17 : feature_enabled_(false) { |
18 set_enabled(true); | 18 set_enabled(true); |
19 } | 19 } |
20 | 20 |
21 DhcpProxyScriptFetcher* DhcpProxyScriptFetcherFactory::Create( | 21 scoped_ptr<DhcpProxyScriptFetcher> DhcpProxyScriptFetcherFactory::Create( |
22 URLRequestContext* context) { | 22 URLRequestContext* context) { |
23 if (!feature_enabled_) { | 23 if (!feature_enabled_) { |
24 return new DoNothingDhcpProxyScriptFetcher(); | 24 return scoped_ptr<DhcpProxyScriptFetcher>( |
eroman
2015/08/21 20:03:12
I suggest using "make_scoped_ptr(new DoNothingDhcp
| |
25 new DoNothingDhcpProxyScriptFetcher()); | |
25 } else { | 26 } else { |
26 DCHECK(IsSupported()); | 27 DCHECK(IsSupported()); |
27 DhcpProxyScriptFetcher* ret = NULL; | 28 scoped_ptr<DhcpProxyScriptFetcher> ret(nullptr); |
eroman
2015/08/21 20:03:12
remove "nullptr". It certainly isn't wrong, howeve
| |
28 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
29 ret = new DhcpProxyScriptFetcherWin(context); | 30 ret.reset(new DhcpProxyScriptFetcherWin(context)); |
30 #endif | 31 #endif |
31 DCHECK(ret); | 32 DCHECK(ret); |
32 return ret; | 33 return ret.Pass(); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 void DhcpProxyScriptFetcherFactory::set_enabled(bool enabled) { | 37 void DhcpProxyScriptFetcherFactory::set_enabled(bool enabled) { |
37 if (IsSupported()) { | 38 if (IsSupported()) { |
38 feature_enabled_ = enabled; | 39 feature_enabled_ = enabled; |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 bool DhcpProxyScriptFetcherFactory::enabled() const { | 43 bool DhcpProxyScriptFetcherFactory::enabled() const { |
43 return feature_enabled_; | 44 return feature_enabled_; |
44 } | 45 } |
45 | 46 |
46 // static | 47 // static |
47 bool DhcpProxyScriptFetcherFactory::IsSupported() { | 48 bool DhcpProxyScriptFetcherFactory::IsSupported() { |
48 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
49 return true; | 50 return true; |
50 #else | 51 #else |
51 return false; | 52 return false; |
52 #endif | 53 #endif |
53 } | 54 } |
54 | 55 |
55 } // namespace net | 56 } // namespace net |
OLD | NEW |