forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_request_intercepting_job_factory.h
74 lines (59 loc) · 2.56 KB
/
url_request_intercepting_job_factory.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// 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_INTERCEPTING_JOB_FACTORY_H_
#define NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "net/base/net_export.h"
#include "net/url_request/url_request_job_factory.h"
class GURL;
namespace net {
class URLRequest;
class URLRequestJob;
class URLRequestInterceptor;
// This class acts as a wrapper for URLRequestJobFactory. The
// URLRequestInteceptor is given the option of creating a URLRequestJob for each
// URLRequest. If the interceptor does not create a job, the URLRequest is
// forwarded to the wrapped URLRequestJobFactory instead.
//
// This class is only intended for use in intercepting requests before they
// are passed on to their default ProtocolHandler. Each supported scheme should
// have its own ProtocolHandler.
class NET_EXPORT URLRequestInterceptingJobFactory
: public URLRequestJobFactory {
public:
// Takes ownership of |job_factory| and |interceptor|.
URLRequestInterceptingJobFactory(
std::unique_ptr<URLRequestJobFactory> job_factory,
std::unique_ptr<URLRequestInterceptor> interceptor);
// Does not take ownership of |job_factory| and |interceptor|. Necessary if
// ownership is held elsewhere.
URLRequestInterceptingJobFactory(URLRequestJobFactory* job_factory,
URLRequestInterceptor* interceptor);
~URLRequestInterceptingJobFactory() override;
// URLRequestJobFactory implementation
URLRequestJob* MaybeCreateJobWithProtocolHandler(
const std::string& scheme,
URLRequest* request,
NetworkDelegate* network_delegate) const override;
URLRequestJob* MaybeInterceptRedirect(
URLRequest* request,
NetworkDelegate* network_delegate,
const GURL& location) const override;
URLRequestJob* MaybeInterceptResponse(
URLRequest* request,
NetworkDelegate* network_delegate) const override;
bool IsHandledProtocol(const std::string& scheme) const override;
bool IsSafeRedirectTarget(const GURL& location) const override;
private:
// |owning_| indicates if this object owns |job_factory_| and |interceptor_|.
bool owning_;
URLRequestJobFactory* job_factory_;
URLRequestInterceptor* interceptor_;
DISALLOW_COPY_AND_ASSIGN(URLRequestInterceptingJobFactory);
};
} // namespace net
#endif // NET_URL_REQUEST_URL_REQUEST_INTERCEPTING_JOB_FACTORY_H_