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

Unified Diff: net/proxy/dhcp_proxy_script_fetcher.h

Issue 6831025: Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add timeout on Win32 DHCP API. Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: net/proxy/dhcp_proxy_script_fetcher.h
diff --git a/net/proxy/dhcp_proxy_script_fetcher.h b/net/proxy/dhcp_proxy_script_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..3a01402a1231e2f07cc65b85a5861e1ac09b6fc6
--- /dev/null
+++ b/net/proxy/dhcp_proxy_script_fetcher.h
@@ -0,0 +1,79 @@
+// 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_H_
+#define NET_PROXY_DHCP_SCRIPT_FETCHER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/string16.h"
+#include "net/base/completion_callback.h"
+#include "net/proxy/proxy_script_fetcher.h"
+#include "net/url_request/url_request_context.h"
+
+namespace net {
+
+// Interface for classes that can fetch a proxy script as configured via DHCP.
+//
+// The Fetch method on this interface tries to retrieve the most appropriate
+// PAC script configured via DHCP.
+//
+// Normally there are zero or one DHCP scripts configured, but in the
+// presence of multiple adapters with DHCP enabled, the fetcher resolves
+// which PAC script to use if one or more are available.
+//
+// Implementations of this interface may return a few error codes in addition
+// to those documented for ProxyScriptFetcher::Fetch():
+//
+// ERR_PAC_NOT_IN_DHCP -- no script configured in DHCP
+//
+// The following all indicate there was one or more script configured
+// in DHCP but all failed to download, and the error for the most
+// preferred adapter that had a script configured was what the error
+// code says:
+//
+// ERR_TIMED_OUT -- fetch took too long to complete
+// ERR_FILE_TOO_BIG -- response body was too large.
+// ERR_PAC_STATUS_NOT_OK -- script failed to download.
+// ERR_NOT_IMPLEMENTED -- script required authentication.
+class DhcpProxyScriptFetcher : public ProxyScriptFetcher {
+ public:
+ // Destruction should cancel any outstanding requests.
+ virtual ~DhcpProxyScriptFetcher();
+
+ // After successful completion of |Fetch()|, this will return the URL
+ // retrieved from DHCP. It is reset if/when |Fetch()| is called again.
+ virtual GURL GetPacURL() const = 0;
+
+ // Intended for unit tests only, so they can test that factories return
+ // the right types under given circumstances.
+ virtual std::string GetFetcherName() const;
+
+ protected:
+ DhcpProxyScriptFetcher();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcher);
+};
+
+// A do-nothing retriever, always returns synchronously with
+// ERR_NOT_IMPLEMENTED result and empty text.
+class DoNothingDhcpProxyScriptFetcher : public DhcpProxyScriptFetcher {
+ public:
+ DoNothingDhcpProxyScriptFetcher();
+ virtual ~DoNothingDhcpProxyScriptFetcher();
+
+ virtual int Fetch(string16* utf16_text,
+ CompletionCallback* callback) OVERRIDE;
+ virtual void Cancel() OVERRIDE;
+ virtual URLRequestContext* GetRequestContext() const OVERRIDE;
+ virtual GURL GetPacURL() const OVERRIDE;
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DoNothingDhcpProxyScriptFetcher);
+};
+
+} // namespace net
+
+#endif // NET_PROXY_DHCP_SCRIPT_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698