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

Unified Diff: net/proxy/init_proxy_resolver.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: Responding to review comments. 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/init_proxy_resolver.h
diff --git a/net/proxy/init_proxy_resolver.h b/net/proxy/init_proxy_resolver.h
index fd6564278ac83cd15525b18bb9499be873285fe8..0dac10d1f7d892ed4469b704ee36768a161c02a5 100644
--- a/net/proxy/init_proxy_resolver.h
+++ b/net/proxy/init_proxy_resolver.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -11,15 +11,19 @@
#include "base/string16.h"
#include "base/time.h"
#include "base/timer.h"
+#include "base/scoped_ptr.h"
#include "googleurl/src/gurl.h"
#include "net/base/completion_callback.h"
#include "net/base/net_log.h"
namespace net {
+class DhcpProxyScriptFetcher;
+class NetLogParameter;
class ProxyConfig;
class ProxyResolver;
class ProxyScriptFetcher;
+class URLRequestContext;
// InitProxyResolver is a helper class used by ProxyService to
// initialize a ProxyResolver with the PAC script data specified
@@ -43,10 +47,11 @@ class InitProxyResolver {
// the lifespan of InitProxyResolver.
InitProxyResolver(ProxyResolver* resolver,
ProxyScriptFetcher* proxy_script_fetcher,
+ DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
NetLog* net_log);
// Aborts any in-progress request.
- ~InitProxyResolver();
+ virtual ~InitProxyResolver();
// Applies the PAC settings of |config| to |resolver_|.
// If |wait_delay| is positive, the initialization will pause for this
@@ -63,14 +68,23 @@ class InitProxyResolver {
CompletionCallback* callback);
private:
- struct PacURL {
- PacURL(bool auto_detect, const GURL& url)
- : auto_detect(auto_detect), url(url) {}
- bool auto_detect;
- GURL url;
+ // Represents the sources from which we can get PAC files; two types of
+ // auto-detect or a custom URL.
+ struct PacSource {
+ enum Type {
+ WPAD_DHCP,
+ WPAD_DNS,
+ CUSTOM
+ };
+
+ PacSource(Type type, const GURL& url)
+ : type(type), url(url) {}
+
+ Type type;
+ GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|.
};
- typedef std::vector<PacURL> UrlList;
+ typedef std::vector<PacSource> PacSourceList;
enum State {
STATE_NONE,
@@ -83,7 +97,7 @@ class InitProxyResolver {
};
// Returns ordered list of PAC urls to try for |config|.
- UrlList BuildPacUrlsFallbackList(const ProxyConfig& config) const;
+ PacSourceList BuildPacSourcesFallbackList(const ProxyConfig& config) const;
void OnIOCompletion(int result);
int DoLoop(int result);
@@ -99,17 +113,20 @@ class InitProxyResolver {
int DoSetPacScriptComplete(int result);
// Tries restarting using the next fallback PAC URL:
- // |pac_urls_[++current_pac_url_index]|.
+ // |pac_sources_[++current_pac_source_index]|.
// Returns OK and rewinds the state machine when there
// is something to try, otherwise returns |error|.
- int TryToFallbackPacUrl(int error);
+ int TryToFallbackPacSource(int error);
// Gets the initial state (we skip fetching when the
// ProxyResolver doesn't |expect_pac_bytes()|.
State GetStartState() const;
+ NetLogStringParameter* CreateNetLogParameterForSource(
+ const PacSource& pac_source, GURL* effective_pac_url);
+
// Returns the current PAC URL we are fetching/testing.
- const PacURL& current_pac_url() const;
+ const PacSource& current_pac_source() const;
void OnWaitTimerFired();
void DidCompleteInit();
@@ -117,16 +134,17 @@ class InitProxyResolver {
ProxyResolver* resolver_;
ProxyScriptFetcher* proxy_script_fetcher_;
+ DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_;
CompletionCallbackImpl<InitProxyResolver> io_callback_;
CompletionCallback* user_callback_;
- size_t current_pac_url_index_;
+ size_t current_pac_source_index_;
// Filled when the PAC script fetch completes.
string16 pac_script_;
- UrlList pac_urls_;
+ PacSourceList pac_sources_;
State next_state_;
BoundNetLog net_log_;

Powered by Google App Engine
This is Rietveld 408576698