[email protected] | 1f6fdd4 | 2012-01-05 05:47:56 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
Eric Roman | d44cc64 | 2018-11-14 02:04:48 | [diff] [blame] | 5 | #ifndef NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_ |
6 | #define NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_ | ||||
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 7 | |
8 | #include "base/compiler_specific.h" | ||||
Bence Béky | cc5b88a | 2018-05-25 20:24:17 | [diff] [blame] | 9 | #include "net/base/completion_once_callback.h" |
Lily Houghton | 582d462 | 2018-01-22 22:43:40 | [diff] [blame] | 10 | #include "net/proxy_resolution/pac_file_fetcher.h" |
Ramin Halavati | bb8c4d8 | 2018-03-16 08:04:31 | [diff] [blame] | 11 | #include "net/traffic_annotation/network_traffic_annotation.h" |
[email protected] | f89276a7 | 2013-07-12 06:41:54 | [diff] [blame] | 12 | #include "url/gurl.h" |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 13 | |
14 | #include <string> | ||||
15 | |||||
16 | namespace net { | ||||
17 | |||||
18 | class URLRequestContext; | ||||
19 | |||||
Lily Houghton | 9959786 | 2018-03-07 16:40:42 | [diff] [blame] | 20 | // A mock PacFileFetcher. No result will be returned to the fetch client |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 21 | // until we call NotifyFetchCompletion() to set the results. |
Lily Houghton | 9959786 | 2018-03-07 16:40:42 | [diff] [blame] | 22 | class MockPacFileFetcher : public PacFileFetcher { |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 23 | public: |
Lily Houghton | 9959786 | 2018-03-07 16:40:42 | [diff] [blame] | 24 | MockPacFileFetcher(); |
25 | ~MockPacFileFetcher() override; | ||||
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 26 | |
Lily Houghton | 9959786 | 2018-03-07 16:40:42 | [diff] [blame] | 27 | // PacFileFetcher implementation. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 28 | int Fetch(const GURL& url, |
29 | base::string16* text, | ||||
Bence Béky | cc5b88a | 2018-05-25 20:24:17 | [diff] [blame] | 30 | CompletionOnceCallback callback, |
Ramin Halavati | bb8c4d8 | 2018-03-16 08:04:31 | [diff] [blame] | 31 | const NetworkTrafficAnnotationTag traffic_annotation) override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 32 | void Cancel() override; |
mmenke | ed8d7e43 | 2017-05-03 16:48:33 | [diff] [blame] | 33 | void OnShutdown() override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 34 | URLRequestContext* GetRequestContext() const override; |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 35 | |
36 | void NotifyFetchCompletion(int result, const std::string& ascii_text); | ||||
37 | const GURL& pending_request_url() const; | ||||
38 | bool has_pending_request() const; | ||||
39 | |||||
[email protected] | 1f6fdd4 | 2012-01-05 05:47:56 | [diff] [blame] | 40 | // Spins the message loop until this->Fetch() is invoked. |
41 | void WaitUntilFetch(); | ||||
42 | |||||
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 43 | private: |
44 | GURL pending_request_url_; | ||||
Bence Béky | cc5b88a | 2018-05-25 20:24:17 | [diff] [blame] | 45 | CompletionOnceCallback pending_request_callback_; |
[email protected] | 42cba2fb | 2013-03-29 19:58:57 | [diff] [blame] | 46 | base::string16* pending_request_text_; |
Wez | 53f3d30 | 2018-09-21 16:55:16 | [diff] [blame] | 47 | base::OnceClosure on_fetch_complete_; |
mmenke | ed8d7e43 | 2017-05-03 16:48:33 | [diff] [blame] | 48 | bool is_shutdown_; |
[email protected] | 7258def | 2011-05-17 19:53:00 | [diff] [blame] | 49 | }; |
50 | |||||
51 | } // namespace net | ||||
52 | |||||
Eric Roman | d44cc64 | 2018-11-14 02:04:48 | [diff] [blame] | 53 | #endif // NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_ |