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

Side by Side Diff: net/proxy/proxy_script_fetcher.h

Issue 13251: Add a ProxyScriptFetcher class for doing asynch downloads of PAC scripts.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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
« no previous file with comments | « net/net_unittests.scons ('k') | net/proxy/proxy_script_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 // ProxyScriptFetcher is an async interface for fetching a proxy auto config
6 // script. It is specific to fetching a PAC script; enforces timeout, max-size,
7 // status code.
8
9 #ifndef NET_PROXY_PROXY_SCRIPT_FETCHER_H_
10 #define NET_PROXY_PROXY_SCRIPT_FETCHER_H_
11
12 #include "net/base/completion_callback.h"
13 #include "testing/gtest/include/gtest/gtest_prod.h"
14
15 class GURL;
16 class URLRequestContext;
17
18 namespace net {
19
20 class ProxyScriptFetcher {
21 public:
22 // Destruction should cancel any outstanding requests.
23 virtual ~ProxyScriptFetcher() {}
24
25 // Downloads the given PAC URL, and invokes |callback| on completion.
26 // On success |callback| is executed with a result code of OK, and a
27 // string of the response bytes. On failure, the result bytes is an empty
28 // string, and the result code is a network error. Some special network
29 // errors that may occur are:
30 //
31 // ERR_TIMED_OUT -- the fetch took too long to complete.
32 // ERR_FILE_TOO_BIG -- the response's body was too large.
33 // ERR_PAC_STATUS_NOT_OK -- non-200 HTTP status code.
34 // ERR_NOT_IMPLEMENTED -- the response required authentication.
35 //
36 // If the request is cancelled (either using the "Cancel()" method or by
37 // deleting |this|), then no callback is invoked.
38 //
39 // Only one fetch is allowed to be outstanding at a time.
40 virtual void Fetch(const GURL& url, std::string* bytes,
41 CompletionCallback* callback) = 0;
42
43 // Aborts the in-progress fetch (if any).
44 virtual void Cancel() = 0;
45
46 // Create a ProxyScriptFetcher that uses |url_request_context|.
47 static ProxyScriptFetcher* Create(URLRequestContext* url_request_context);
48
49 // --------------------------------------------------------------------------
50 // Testing helpers (only available to unit-tests).
51 // --------------------------------------------------------------------------
52 private:
53 FRIEND_TEST(ProxyScriptFetcherTest, Hang);
54 FRIEND_TEST(ProxyScriptFetcherTest, TooLarge);
55
56 // Sets the maximum duration for a fetch to |timeout_ms|. Returns the previous
57 // bound.
58 static int SetTimeoutConstraintForUnittest(int timeout_ms);
59
60 // Sets the maximum response size for a fetch to |size_bytes|. Returns the
61 // previous bound.
62 static size_t SetSizeConstraintForUnittest(size_t size_bytes);
63 };
64
65 } // namespace net
66
67 #endif // NET_PROXY_PROXY_SCRIPT_FETCHER_H_
OLDNEW
« no previous file with comments | « net/net_unittests.scons ('k') | net/proxy/proxy_script_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698