blob: 7213ad39a26c3371ded7f9bfde01750d7cefbdbd [file] [log] [blame]
[email protected]1f6fdd42012-01-05 05:47:561// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]7258def2011-05-17 19:53:002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Eric Romand44cc642018-11-14 02:04:485#ifndef NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_
6#define NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_
[email protected]7258def2011-05-17 19:53:007
8#include "base/compiler_specific.h"
Bence Békycc5b88a2018-05-25 20:24:179#include "net/base/completion_once_callback.h"
Lily Houghton582d4622018-01-22 22:43:4010#include "net/proxy_resolution/pac_file_fetcher.h"
Ramin Halavatibb8c4d82018-03-16 08:04:3111#include "net/traffic_annotation/network_traffic_annotation.h"
[email protected]f89276a72013-07-12 06:41:5412#include "url/gurl.h"
[email protected]7258def2011-05-17 19:53:0013
14#include <string>
15
16namespace net {
17
18class URLRequestContext;
19
Lily Houghton99597862018-03-07 16:40:4220// A mock PacFileFetcher. No result will be returned to the fetch client
[email protected]7258def2011-05-17 19:53:0021// until we call NotifyFetchCompletion() to set the results.
Lily Houghton99597862018-03-07 16:40:4222class MockPacFileFetcher : public PacFileFetcher {
[email protected]7258def2011-05-17 19:53:0023 public:
Lily Houghton99597862018-03-07 16:40:4224 MockPacFileFetcher();
25 ~MockPacFileFetcher() override;
[email protected]7258def2011-05-17 19:53:0026
Lily Houghton99597862018-03-07 16:40:4227 // PacFileFetcher implementation.
dchengb03027d2014-10-21 12:00:2028 int Fetch(const GURL& url,
29 base::string16* text,
Bence Békycc5b88a2018-05-25 20:24:1730 CompletionOnceCallback callback,
Ramin Halavatibb8c4d82018-03-16 08:04:3131 const NetworkTrafficAnnotationTag traffic_annotation) override;
dchengb03027d2014-10-21 12:00:2032 void Cancel() override;
mmenkeed8d7e432017-05-03 16:48:3333 void OnShutdown() override;
dchengb03027d2014-10-21 12:00:2034 URLRequestContext* GetRequestContext() const override;
[email protected]7258def2011-05-17 19:53:0035
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]1f6fdd42012-01-05 05:47:5640 // Spins the message loop until this->Fetch() is invoked.
41 void WaitUntilFetch();
42
[email protected]7258def2011-05-17 19:53:0043 private:
44 GURL pending_request_url_;
Bence Békycc5b88a2018-05-25 20:24:1745 CompletionOnceCallback pending_request_callback_;
[email protected]42cba2fb2013-03-29 19:58:5746 base::string16* pending_request_text_;
Wez53f3d302018-09-21 16:55:1647 base::OnceClosure on_fetch_complete_;
mmenkeed8d7e432017-05-03 16:48:3348 bool is_shutdown_;
[email protected]7258def2011-05-17 19:53:0049};
50
51} // namespace net
52
Eric Romand44cc642018-11-14 02:04:4853#endif // NET_PROXY_RESOLUTION_MOCK_PAC_FILE_FETCHER_H_