summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_interceptor.h
blob: f7d52751ec5c51ffa915b155fb62e12d21a83109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_
#define NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_

#include "base/macros.h"
#include "net/base/net_export.h"

class GURL;

namespace net {

class URLRequest;
class URLRequestJob;
class NetworkDelegate;

// A URLRequestInterceptor is given a chance to create a URLRequestJob to
// handle URLRequests before they're handed off to the ProtocolHandler for
// the request's scheme.
class NET_EXPORT URLRequestInterceptor {
 public:
  URLRequestInterceptor();
  virtual ~URLRequestInterceptor();

  // Returns a URLRequestJob to handle |request|, if the interceptor wants to
  // take over the handling the request instead of the default ProtocolHandler.
  // Otherwise, returns NULL.
  virtual URLRequestJob* MaybeInterceptRequest(
      URLRequest* request, NetworkDelegate* network_delegate) const = 0;

  // Returns a URLRequestJob to handle |request|, if the interceptor wants to
  // take over the handling of the request after a redirect is received,
  // instead of using the default ProtocolHandler. Otherwise, returns NULL.
  virtual URLRequestJob* MaybeInterceptRedirect(
      URLRequest* request,
      NetworkDelegate* network_delegate,
      const GURL& location) const;

  // Returns a URLRequestJob to handle |request, if the interceptor wants to
  // take over the handling of the request after a response has started,
  // instead of using the default ProtocolHandler. Otherwise, returns NULL.
  virtual URLRequestJob* MaybeInterceptResponse(
      URLRequest* request, NetworkDelegate* network_delegate) const;

 private:
  DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptor);
};

}  // namespace net

#endif  // NET_URL_REQUEST_URL_REQUEST_INTERCEPTOR_H_