Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: net/url_request/protocol_intercept_job_factory.h

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PolicyTests to unregister with URLRequestFilter Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ 5 #ifndef NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_
6 #define CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ 6 #define NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h"
10 #include "net/url_request/url_request_job_factory.h" 12 #include "net/url_request/url_request_job_factory.h"
11 13
12 class GURL; 14 class GURL;
13 15
14 namespace net { 16 namespace net {
15 17
16 class URLRequest; 18 class URLRequest;
17 class URLRequestJob; 19 class URLRequestJob;
18 20
19 // This class acts as a wrapper for URLRequestJobFactory. It handles HTTP and 21 // This class acts as a wrapper for URLRequestJobFactory. For requests with a
20 // HTTPS jobs using |protocol_handler_|, but forwards all other schemes to the 22 // scheme matching |scheme_| (or for any scheme if |scheme_| is NULL)
21 // old job factory to be handled there. 23 // |protocol_handler_| is given the option of creating a job. If
22 class HttpInterceptJobFactory : public URLRequestJobFactory { 24 // |protocol_handler_| does not create a job or the scheme does not match the
25 // request is forwarded to the |job_factory_| to be handled there.
26 class NET_EXPORT ProtocolInterceptJobFactory : public URLRequestJobFactory {
23 public: 27 public:
24 HttpInterceptJobFactory(const URLRequestJobFactory* job_factory, 28 // Passing NULL for |scheme| will cause |protocol_handler| to be passed all
25 ProtocolHandler* protocol_handler); 29 // requests.
26 virtual ~HttpInterceptJobFactory(); 30 ProtocolInterceptJobFactory(scoped_ptr<URLRequestJobFactory> job_factory,
31 const char* scheme,
32 ProtocolHandler* protocol_handler);
33 virtual ~ProtocolInterceptJobFactory();
27 34
28 // URLRequestJobFactory implementation 35 // URLRequestJobFactory implementation
29 virtual bool SetProtocolHandler(const std::string& scheme, 36 virtual bool SetProtocolHandler(const std::string& scheme,
30 ProtocolHandler* protocol_handler) OVERRIDE; 37 ProtocolHandler* protocol_handler) OVERRIDE;
31 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE; 38 virtual void AddInterceptor(Interceptor* interceptor) OVERRIDE;
32 virtual URLRequestJob* MaybeCreateJobWithInterceptor( 39 virtual URLRequestJob* MaybeCreateJobWithInterceptor(
33 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; 40 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE;
34 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler( 41 virtual URLRequestJob* MaybeCreateJobWithProtocolHandler(
35 const std::string& scheme, 42 const std::string& scheme,
36 URLRequest* request, 43 URLRequest* request,
37 NetworkDelegate* network_delegate) const OVERRIDE; 44 NetworkDelegate* network_delegate) const OVERRIDE;
38 virtual URLRequestJob* MaybeInterceptRedirect( 45 virtual URLRequestJob* MaybeInterceptRedirect(
39 const GURL& location, 46 const GURL& location,
40 URLRequest* request, 47 URLRequest* request,
41 NetworkDelegate* network_delegate) const OVERRIDE; 48 NetworkDelegate* network_delegate) const OVERRIDE;
42 virtual URLRequestJob* MaybeInterceptResponse( 49 virtual URLRequestJob* MaybeInterceptResponse(
43 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE; 50 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE;
44 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE; 51 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE;
45 virtual bool IsHandledURL(const GURL& url) const OVERRIDE; 52 virtual bool IsHandledURL(const GURL& url) const OVERRIDE;
46 53
47 private: 54 private:
48 const URLRequestJobFactory* job_factory_; 55 const char* scheme_;
erikwright (departed) 2012/12/07 20:12:05 I'm not sure what the convention for this kind of
pauljensen 2012/12/09 23:14:12 |scheme_| isn't really necessary...I'll remove it
49 ProtocolHandler* protocol_handler_; 56 scoped_ptr<URLRequestJobFactory> job_factory_;
57 scoped_ptr<ProtocolHandler> protocol_handler_;
50 58
51 DISALLOW_COPY_AND_ASSIGN(HttpInterceptJobFactory); 59 DISALLOW_COPY_AND_ASSIGN(ProtocolInterceptJobFactory);
52 }; 60 };
53 61
54 } // namespace net 62 } // namespace net
55 63
56 #endif // CHROME_BROWSER_NET_HTTP_INTERCEPT_JOB_FACTORY_H_ 64 #endif // NET_URL_REQUEST_PROTOCOL_INTERCEPT_JOB_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698