Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [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 | |
| 5 | #ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_ |
| 6 | #define NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_ |
| 7 | |
Matt Menke | fd97885 | 2020-09-15 16:00:57 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 10 | #include "net/base/net_export.h" |
| 11 | |
| 12 | namespace net { |
| 13 | |
| 14 | class URLRequest; |
| 15 | class URLRequestJob; |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 16 | |
Matt Menke | c6c988e | 2019-09-11 02:30:40 | [diff] [blame] | 17 | // In tests, URLRequestFilter lets URLRequestInterceptors create URLRequestJobs |
| 18 | // to handle URLRequests before they're handed off to the ProtocolHandler for |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 19 | // the request's scheme. |
Matt Menke | c6c988e | 2019-09-11 02:30:40 | [diff] [blame] | 20 | // |
| 21 | // TODO(mmenke): Only include this file in test targets. Also consider using |
| 22 | // callbacks instead, or even removing URLRequestFilter. |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 23 | class NET_EXPORT URLRequestInterceptor { |
| 24 | public: |
| 25 | URLRequestInterceptor(); |
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame] | 26 | |
| 27 | URLRequestInterceptor(const URLRequestInterceptor&) = delete; |
| 28 | URLRequestInterceptor& operator=(const URLRequestInterceptor&) = delete; |
| 29 | |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 30 | virtual ~URLRequestInterceptor(); |
| 31 | |
| 32 | // Returns a URLRequestJob to handle |request|, if the interceptor wants to |
| 33 | // take over the handling the request instead of the default ProtocolHandler. |
Matt Menke | fd97885 | 2020-09-15 16:00:57 | [diff] [blame] | 34 | // Otherwise, returns nullptr. |
| 35 | virtual std::unique_ptr<URLRequestJob> MaybeInterceptRequest( |
| 36 | URLRequest* request) const = 0; |
[email protected] | 3b90aab | 2014-05-30 17:56:15 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace net |
| 40 | |
| 41 | #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_ |