| OLD | NEW |
| 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 #ifndef NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ | 5 #ifndef NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |
| 6 #define NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ | 6 #define NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 class DhcpProxyScriptFetcher; | |
| 16 class URLRequestContext; | 16 class URLRequestContext; |
| 17 | 17 |
| 18 // Factory object for creating the appropriate concrete base class of | 18 // Factory object for creating the appropriate concrete base class of |
| 19 // DhcpProxyScriptFetcher for your operating system and settings. | 19 // DhcpProxyScriptFetcher for your operating system and settings. |
| 20 // | 20 // |
| 21 // You might think we could just implement a DHCP client at the protocol | 21 // You might think we could just implement a DHCP client at the protocol |
| 22 // level and have cross-platform support for retrieving PAC configuration | 22 // level and have cross-platform support for retrieving PAC configuration |
| 23 // from DHCP, but unfortunately the DHCP protocol assumes there is a single | 23 // from DHCP, but unfortunately the DHCP protocol assumes there is a single |
| 24 // client per machine (specifically per network interface card), and there | 24 // client per machine (specifically per network interface card), and there |
| 25 // is an implicit state machine between the client and server, so adding a | 25 // is an implicit state machine between the client and server, so adding a |
| 26 // second client to the machine would not be advisable (see e.g. some | 26 // second client to the machine would not be advisable (see e.g. some |
| 27 // discussion of what can happen at this URL: | 27 // discussion of what can happen at this URL: |
| 28 // http://www.net.princeton.edu/multi-dhcp-one-interface-handling.html). | 28 // http://www.net.princeton.edu/multi-dhcp-one-interface-handling.html). |
| 29 // | 29 // |
| 30 // Therefore, we have platform-specific implementations, and so we use | 30 // Therefore, we have platform-specific implementations, and so we use |
| 31 // this factory to select the right one. | 31 // this factory to select the right one. |
| 32 class NET_EXPORT DhcpProxyScriptFetcherFactory { | 32 class NET_EXPORT DhcpProxyScriptFetcherFactory { |
| 33 public: | 33 public: |
| 34 // Creates a new factory object with default settings. | 34 // Creates a new factory object with default settings. |
| 35 DhcpProxyScriptFetcherFactory(); | 35 DhcpProxyScriptFetcherFactory(); |
| 36 | 36 |
| 37 // Ownership is transferred to the caller. url_request_context must be valid | 37 // url_request_context must be valid and its lifetime must exceed that of the |
| 38 // and its lifetime must exceed that of the returned DhcpProxyScriptFetcher. | 38 // returned DhcpProxyScriptFetcher. |
| 39 // | 39 // |
| 40 // Note that while a request is in progress, the fetcher may be holding a | 40 // Note that while a request is in progress, the fetcher may be holding a |
| 41 // reference to |url_request_context|. Be careful not to create cycles | 41 // reference to |url_request_context|. Be careful not to create cycles |
| 42 // between the fetcher and the context; you can break such cycles by calling | 42 // between the fetcher and the context; you can break such cycles by calling |
| 43 // Cancel(). | 43 // Cancel(). |
| 44 DhcpProxyScriptFetcher* Create(URLRequestContext* url_request_context); | 44 scoped_ptr<DhcpProxyScriptFetcher> Create( |
| 45 URLRequestContext* url_request_context); |
| 45 | 46 |
| 46 // Attempts to enable/disable the DHCP WPAD feature. Does nothing | 47 // Attempts to enable/disable the DHCP WPAD feature. Does nothing |
| 47 // if |IsSupported()| returns false. | 48 // if |IsSupported()| returns false. |
| 48 // | 49 // |
| 49 // The default is |enabled() == true|. | 50 // The default is |enabled() == true|. |
| 50 void set_enabled(bool enabled); | 51 void set_enabled(bool enabled); |
| 51 | 52 |
| 52 // Returns true if the DHCP WPAD feature is enabled. Always returns | 53 // Returns true if the DHCP WPAD feature is enabled. Always returns |
| 53 // false if |IsSupported()| is false. | 54 // false if |IsSupported()| is false. |
| 54 bool enabled() const; | 55 bool enabled() const; |
| 55 | 56 |
| 56 // Returns true if the DHCP WPAD feature is supported on the current | 57 // Returns true if the DHCP WPAD feature is supported on the current |
| 57 // operating system. | 58 // operating system. |
| 58 static bool IsSupported(); | 59 static bool IsSupported(); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 bool feature_enabled_; | 62 bool feature_enabled_; |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcherFactory); | 64 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcherFactory); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 } // namespace net | 67 } // namespace net |
| 67 | 68 |
| 68 #endif // NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ | 69 #endif // NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |
| OLD | NEW |