Evict resources from resource pool after timeout
[chromium-blink-merge.git] / net / url_request / url_request_job_factory_impl.h
blobcba11248ca03ec7b46563832ddeb1852718ffe1a
1 // Copyright (c) 2011 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.
5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_IMPL_H_
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_IMPL_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "net/base/net_export.h"
15 #include "net/url_request/url_request_job_factory.h"
17 namespace net {
19 class URLRequestInterceptor;
21 class NET_EXPORT URLRequestJobFactoryImpl : public URLRequestJobFactory {
22 public:
23 URLRequestJobFactoryImpl();
24 ~URLRequestJobFactoryImpl() override;
26 // Sets the ProtocolHandler for a scheme. Returns true on success, false on
27 // failure (a ProtocolHandler already exists for |scheme|).
28 bool SetProtocolHandler(const std::string& scheme,
29 scoped_ptr<ProtocolHandler> protocol_handler);
31 // URLRequestJobFactory implementation
32 URLRequestJob* MaybeCreateJobWithProtocolHandler(
33 const std::string& scheme,
34 URLRequest* request,
35 NetworkDelegate* network_delegate) const override;
37 URLRequestJob* MaybeInterceptRedirect(
38 URLRequest* request,
39 NetworkDelegate* network_delegate,
40 const GURL& location) const override;
42 URLRequestJob* MaybeInterceptResponse(
43 URLRequest* request,
44 NetworkDelegate* network_delegate) const override;
46 bool IsHandledProtocol(const std::string& scheme) const override;
47 bool IsHandledURL(const GURL& url) const override;
48 bool IsSafeRedirectTarget(const GURL& location) const override;
50 private:
51 // For testing only.
52 friend class URLRequestFilter;
54 typedef std::map<std::string, ProtocolHandler*> ProtocolHandlerMap;
56 // Sets a global URLRequestInterceptor for testing purposes. The interceptor
57 // is given the chance to intercept any request before the corresponding
58 // ProtocolHandler, but after any other URLRequestJobFactories layered on top
59 // of the URLRequestJobFactoryImpl.
60 // If an interceptor is set, the old interceptor must be cleared before
61 // setting a new one.
62 static void SetInterceptorForTesting(URLRequestInterceptor* interceptor);
64 ProtocolHandlerMap protocol_handler_map_;
66 DISALLOW_COPY_AND_ASSIGN(URLRequestJobFactoryImpl);
69 } // namespace net
71 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_FACTORY_IMPL_H_