summaryrefslogtreecommitdiffstats
path: root/net/proxy/mock_proxy_script_fetcher.cc
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 17:29:05 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 17:29:05 +0000
commitcfbcab964ac927102ce49c20ea1c4e1bcd667a04 (patch)
treeff34b602cae9072e4bd5b43f75d73abb91ba142b /net/proxy/mock_proxy_script_fetcher.cc
parent0179f39b00af02a9abde26f5003f213e25a4444a (diff)
downloadchromium_src-cfbcab964ac927102ce49c20ea1c4e1bcd667a04.zip
chromium_src-cfbcab964ac927102ce49c20ea1c4e1bcd667a04.tar.gz
chromium_src-cfbcab964ac927102ce49c20ea1c4e1bcd667a04.tar.bz2
Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol.
This is Windows-only for now, and is disabled by default. Start Chrome with the flag --enable-dhcp-wpad to enable the feature. See discussion in comment on DhcpProxyScriptFetcherFactory for why this needs to be done in a per-platform way rather than cross-platform. The code is factored so that adding other platform implementations will be straight forward. Most of the implementation is stand-alone and extends the ScriptProxyFetcher class hierarchy (and makes its interface slightly more generic). The integration point into existing code is in InitProxyResolver, which previously handled fallback from DNS auto-detect to custom PAC URL and now does fallback from DHCP to DNS to custom PAC URL. BUG=18575 TEST=net_unittests has good coverage for the new and changed code, but manual tests on a network with a PAC URL configured in DHCP are also needed. Review URL: http://codereview.chromium.org/6831025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/mock_proxy_script_fetcher.cc')
-rw-r--r--net/proxy/mock_proxy_script_fetcher.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/net/proxy/mock_proxy_script_fetcher.cc b/net/proxy/mock_proxy_script_fetcher.cc
new file mode 100644
index 0000000..3e9b601
--- /dev/null
+++ b/net/proxy/mock_proxy_script_fetcher.cc
@@ -0,0 +1,55 @@
+// 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.
+
+#include "net/proxy/mock_proxy_script_fetcher.h"
+
+#include "base/logging.h"
+#include "base/string16.h"
+#include "base/utf_string_conversions.h"
+#include "net/base/net_errors.h"
+
+namespace net {
+
+MockProxyScriptFetcher::MockProxyScriptFetcher()
+ : pending_request_callback_(NULL), pending_request_text_(NULL) {
+}
+
+// ProxyScriptFetcher implementation.
+int MockProxyScriptFetcher::Fetch(const GURL& url,
+ string16* text,
+ CompletionCallback* callback) {
+ DCHECK(!has_pending_request());
+
+ // Save the caller's information, and have them wait.
+ pending_request_url_ = url;
+ pending_request_callback_ = callback;
+ pending_request_text_ = text;
+ return ERR_IO_PENDING;
+}
+
+void MockProxyScriptFetcher::NotifyFetchCompletion(
+ int result, const std::string& ascii_text) {
+ DCHECK(has_pending_request());
+ *pending_request_text_ = ASCIIToUTF16(ascii_text);
+ CompletionCallback* callback = pending_request_callback_;
+ pending_request_callback_ = NULL;
+ callback->Run(result);
+}
+
+void MockProxyScriptFetcher::Cancel() {
+}
+
+URLRequestContext* MockProxyScriptFetcher::GetRequestContext() const {
+ return NULL;
+}
+
+const GURL& MockProxyScriptFetcher::pending_request_url() const {
+ return pending_request_url_;
+}
+
+bool MockProxyScriptFetcher::has_pending_request() const {
+ return pending_request_callback_ != NULL;
+}
+
+} // namespace net