OLD | NEW |
(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 #ifndef NET_PROXY_DHCP_SCRIPT_FETCHER_H_ |
| 6 #define NET_PROXY_DHCP_SCRIPT_FETCHER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/string16.h" |
| 12 #include "net/base/completion_callback.h" |
| 13 #include "net/proxy/proxy_script_fetcher.h" |
| 14 #include "net/url_request/url_request_context.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 // Interface for classes that can fetch a proxy script as configured via DHCP. |
| 19 // |
| 20 // The Fetch method on this interface tries to retrieve the most appropriate |
| 21 // PAC script configured via DHCP. |
| 22 // |
| 23 // Normally there are zero or one DHCP scripts configured, but in the |
| 24 // presence of multiple adapters with DHCP enabled, the fetcher resolves |
| 25 // which PAC script to use if one or more are available. |
| 26 // |
| 27 // Implementations of this interface may return a few error codes in addition |
| 28 // to those documented for ProxyScriptFetcher::Fetch(): |
| 29 // |
| 30 // ERR_PAC_NOT_IN_DHCP -- no script configured in DHCP |
| 31 // |
| 32 // The following all indicate there was one or more script configured |
| 33 // in DHCP but all failed to download, and the error for the most |
| 34 // preferred adapter that had a script configured was what the error |
| 35 // code says: |
| 36 // |
| 37 // ERR_TIMED_OUT -- fetch took too long to complete |
| 38 // ERR_FILE_TOO_BIG -- response body was too large. |
| 39 // ERR_PAC_STATUS_NOT_OK -- script failed to download. |
| 40 // ERR_NOT_IMPLEMENTED -- script required authentication. |
| 41 class DhcpProxyScriptFetcher : public ProxyScriptFetcher { |
| 42 public: |
| 43 // Destruction should cancel any outstanding requests. |
| 44 virtual ~DhcpProxyScriptFetcher(); |
| 45 |
| 46 // After successful completion of |Fetch()|, this will return the URL |
| 47 // retrieved from DHCP. It is reset if/when |Fetch()| is called again. |
| 48 virtual GURL GetPacURL() const = 0; |
| 49 |
| 50 // Intended for unit tests only, so they can test that factories return |
| 51 // the right types under given circumstances. |
| 52 virtual std::string GetFetcherName() const; |
| 53 |
| 54 protected: |
| 55 DhcpProxyScriptFetcher(); |
| 56 |
| 57 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcher); |
| 59 }; |
| 60 |
| 61 // A do-nothing retriever, always returns synchronously with |
| 62 // ERR_NOT_IMPLEMENTED result and empty text. |
| 63 class DoNothingDhcpProxyScriptFetcher : public DhcpProxyScriptFetcher { |
| 64 public: |
| 65 DoNothingDhcpProxyScriptFetcher(); |
| 66 virtual ~DoNothingDhcpProxyScriptFetcher(); |
| 67 |
| 68 virtual int Fetch(string16* utf16_text, |
| 69 CompletionCallback* callback) OVERRIDE; |
| 70 virtual void Cancel() OVERRIDE; |
| 71 virtual URLRequestContext* GetRequestContext() const OVERRIDE; |
| 72 virtual GURL GetPacURL() const OVERRIDE; |
| 73 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(DoNothingDhcpProxyScriptFetcher); |
| 75 }; |
| 76 |
| 77 } // namespace net |
| 78 |
| 79 #endif // NET_PROXY_DHCP_SCRIPT_FETCHER_H_ |
OLD | NEW |