url_request_interceptor.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_
  5. #define NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_
  6. #include <memory>
  7. #include "net/base/net_export.h"
  8. namespace net {
  9. class URLRequest;
  10. class URLRequestJob;
  11. // In tests, URLRequestFilter lets URLRequestInterceptors create URLRequestJobs
  12. // to handle URLRequests before they're handed off to the ProtocolHandler for
  13. // the request's scheme.
  14. //
  15. // TODO(mmenke): Only include this file in test targets. Also consider using
  16. // callbacks instead, or even removing URLRequestFilter.
  17. class NET_EXPORT URLRequestInterceptor {
  18. public:
  19. URLRequestInterceptor();
  20. URLRequestInterceptor(const URLRequestInterceptor&) = delete;
  21. URLRequestInterceptor& operator=(const URLRequestInterceptor&) = delete;
  22. virtual ~URLRequestInterceptor();
  23. // Returns a URLRequestJob to handle |request|, if the interceptor wants to
  24. // take over the handling the request instead of the default ProtocolHandler.
  25. // Otherwise, returns nullptr.
  26. virtual std::unique_ptr<URLRequestJob> MaybeInterceptRequest(
  27. URLRequest* request) const = 0;
  28. };
  29. } // namespace net
  30. #endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_