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

Side by Side 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: Responding to review comments. Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 class DhcpProxyScriptFetcher {
27 public:
28 // Destruction should cancel any outstanding requests.
29 virtual ~DhcpProxyScriptFetcher();
30
31 // Attempts to retrieve the most appropriate PAC script configured via DHCP,
32 // and invokes |callback| on completion.
33 //
34 // Returns OK on success, otherwise the error code. If the return code is
35 // ERR_IO_PENDING, then the request completes asynchronously, and |callback|
36 // will be invoked later with the final error code.
37 //
38 // After synchronous or asynchronous completion with a result code of OK,
39 // |*utf16_text| is filled with the response. On failure, the result text is
40 // an empty string, and the result code is a network error. Some special
41 // network errors that may occur are:
42 //
43 // ERR_PAC_NOT_IN_DHCP -- no script configured in DHCP.
44 //
45 // The following all indicate there was one or more script configured
46 // in DHCP but all failed to download, and the error for the most
47 // preferred adapter that had a script configured was what the error
48 // code says:
49 //
50 // ERR_TIMED_OUT -- fetch took too long to complete.
51 // ERR_FILE_TOO_BIG -- response body was too large.
52 // ERR_PAC_STATUS_NOT_OK -- script failed to download.
53 // ERR_NOT_IMPLEMENTED -- script required authentication.
54 //
55 // If the request is cancelled (either using the "Cancel()" method or by
56 // deleting |this|), then no callback is invoked.
57 //
58 // Only one fetch is allowed to be outstanding at a time.
59 virtual int Fetch(string16* utf16_text,
eroman 2011/05/13 05:03:32 Can this take a GURL* parameter rather than exposi
Jói 2011/05/13 20:19:09 It could, but in my opinion the current approach i
60 CompletionCallback* callback) = 0;
61
62 // Aborts the in-progress fetch (if any).
63 virtual void Cancel() = 0;
64
65 // Returns the request context that this fetcher uses to issue downloads,
66 // or NULL.
67 virtual URLRequestContext* GetRequestContext() const = 0;
eroman 2011/05/13 05:03:32 Is this necessary?
Jói 2011/05/13 20:19:09 Nope, it was a hold-over from when I merged the cl
68
69 // After successful completion of |Fetch()|, this will return the URL
70 // retrieved from DHCP. It is reset if/when |Fetch()| is called again.
71 virtual GURL GetPacURL() const = 0;
72
73 // Intended for unit tests only, so they can test that factories return
74 // the right types under given circumstances.
75 virtual std::string GetFetcherName() const;
76
77 protected:
78 DhcpProxyScriptFetcher();
79
80 private:
81 DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcher);
82 };
83
84 // A do-nothing retriever, always returns synchronously with
85 // ERR_NOT_IMPLEMENTED result and empty text.
86 class DoNothingDhcpProxyScriptFetcher : public DhcpProxyScriptFetcher {
87 public:
88 DoNothingDhcpProxyScriptFetcher();
89 virtual ~DoNothingDhcpProxyScriptFetcher();
90
91 virtual int Fetch(string16* utf16_text,
92 CompletionCallback* callback) OVERRIDE;
93 virtual void Cancel() OVERRIDE;
94 virtual URLRequestContext* GetRequestContext() const OVERRIDE;
95 virtual GURL GetPacURL() const OVERRIDE;
96 private:
97 DISALLOW_COPY_AND_ASSIGN(DoNothingDhcpProxyScriptFetcher);
98 };
99
100 } // namespace net
101
102 #endif // NET_PROXY_DHCP_SCRIPT_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698