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

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

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

Powered by Google App Engine
This is Rietveld 408576698