Chromium Code Reviews| Index: net/proxy/dhcp_proxy_script_fetcher_factory.h |
| diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory.h b/net/proxy/dhcp_proxy_script_fetcher_factory.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10aea406ecc829bbfd1fa2d708f477d96a0ed769 |
| --- /dev/null |
| +++ b/net/proxy/dhcp_proxy_script_fetcher_factory.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |
| +#define NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/singleton.h" |
| +#include "net/base/completion_callback.h" |
| +#include "net/url_request/url_request_context.h" |
| + |
| +namespace net { |
| + |
| +class DhcpProxyScriptFetcher; |
| + |
| +// Factory for creating the appropriate concrete base class of |
| +// DhcpProxyScriptFetcher for your operating system and settings. |
| +// |
| +// You might think we could just implement a DHCP client at the protocol |
| +// level and have cross-platform support for retrieving PAC configuration |
| +// from DHCP, but unfortunately the DHCP protocol assumes there is a single |
| +// client per machine (specifically per network interface card), and there |
| +// is an implicit state machine between the client and server, so adding a |
| +// second client to the machine would not be advisable (see e.g. some |
| +// discussion of what can happen at this URL: |
| +// http://www.net.princeton.edu/multi-dhcp-one-interface-handling.html). |
| +// |
| +// Therefore, we have platform-specific implementations, and so we use |
| +// this factory to select the right one. |
| +class DhcpProxyScriptFetcherFactory { |
| + public: |
| + // This object is used as a Singleton by production code. |
| + static DhcpProxyScriptFetcherFactory* GetInstance(); |
|
eroman
2011/04/21 05:22:48
We can avoid singletons here by passing this as a
Jói
2011/05/03 21:20:59
I've changed this class to just have the static fl
|
| + |
| + // Ownership is transferred to the caller. url_request_context must be valid |
| + // and its lifetime must exceed that of the returned DhcpProxyScriptFetcher. |
| + // |
| + // Note that while a request is in progress, the fetcher may be holding a |
| + // reference to |url_request_context|. Be careful not to create cycles |
| + // between the fetcher and the context; you can break such cycles by calling |
| + // Cancel(). |
| + DhcpProxyScriptFetcher* Create(URLRequestContext* url_request_context) const; |
| + |
| + // Attempts to enable/disable the DHCP WPAD feature. Does nothing |
| + // if |IsSupported()| returns false. |
| + // |
| + // The feature is disabled by default, for now. |
| + void SetEnabled(bool enabled); |
| + |
| + // Returns true if the DHCP WPAD feature is enabled. Always returns |
| + // false if |IsSupported()| is false. |
| + bool IsEnabled() const; |
| + |
| + // Returns true if the DHCP WPAD feature is supported on the current |
| + // operating system. |
| + static bool IsSupported(); |
| + |
| + protected: |
| + DhcpProxyScriptFetcherFactory(); |
| + ~DhcpProxyScriptFetcherFactory(); |
| + friend struct DefaultSingletonTraits<DhcpProxyScriptFetcherFactory>; |
| + |
| + bool feature_enabled_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcherFactory); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_PROXY_DHCP_SCRIPT_FETCHER_FACTORY_H_ |