1 // Copyright 2014 The Chromium Authors 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 8 #include <memory> 9 10 #include "net/base/net_export.h" 11 12 namespace net { 13 14 class URLRequest; 15 class URLRequestJob; 16 17 // In tests, URLRequestFilter lets URLRequestInterceptors create URLRequestJobs 18 // to handle URLRequests before they're handed off to the ProtocolHandler for 19 // the request's scheme. 20 // 21 // TODO(mmenke): Only include this file in test targets. Also consider using 22 // callbacks instead, or even removing URLRequestFilter. 23 class NET_EXPORT URLRequestInterceptor { 24 public: 25 URLRequestInterceptor(); 26 27 URLRequestInterceptor(const URLRequestInterceptor&) = delete; 28 URLRequestInterceptor& operator=(const URLRequestInterceptor&) = delete; 29 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. 34 // Otherwise, returns nullptr. 35 virtual std::unique_ptr<URLRequestJob> MaybeInterceptRequest( 36 URLRequest* request) const = 0; 37 }; 38 39 } // namespace net 40 41 #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_ 42