• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_STORAGE_H_
6 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_STORAGE_H_
7 #pragma once
8 
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 
13 namespace net {
14 
15 class CertVerifier;
16 class CookiePolicy;
17 class CookieStore;
18 class DnsCertProvenanceChecker;
19 class DnsRRResolver;
20 class FtpTransactionFactory;
21 class HostResolver;
22 class HttpAuthHandlerFactory;
23 class HttpTransactionFactory;
24 class NetLog;
25 class NetworkDelegate;
26 class ProxyService;
27 class SSLConfigService;
28 class TransportSecurityState;
29 class URLRequestContext;
30 
31 // URLRequestContextStorage is a helper class that provides storage for unowned
32 // member variables of URLRequestContext.
33 class URLRequestContextStorage {
34  public:
35   // Note that URLRequestContextStorage does not acquire a reference to
36   // URLRequestContext, since it is often designed to be embedded in a
37   // URLRequestContext subclass.
38   explicit URLRequestContextStorage(URLRequestContext* context);
39   ~URLRequestContextStorage();
40 
41   // These setters will set both the member variables and call the setter on the
42   // URLRequestContext object.
43 
44   void set_net_log(NetLog* net_log);
45   void set_host_resolver(HostResolver* host_resolver);
46   void set_cert_verifier(CertVerifier* cert_verifier);
47   void set_dnsrr_resolver(DnsRRResolver* dnsrr_resolver);
48   void set_dns_cert_checker(DnsCertProvenanceChecker* dns_cert_checker);
49   void set_http_auth_handler_factory(
50       HttpAuthHandlerFactory* http_auth_handler_factory);
51   void set_proxy_service(ProxyService* proxy_service);
52   void set_ssl_config_service(SSLConfigService* ssl_config_service);
53   void set_network_delegate(NetworkDelegate* network_delegate);
54   void set_cookie_store(CookieStore* cookie_store);
55   void set_cookie_policy(CookiePolicy* cookie_policy);
56   void set_transport_security_state(
57       TransportSecurityState* transport_security_state);
58   void set_http_transaction_factory(
59       HttpTransactionFactory* http_transaction_factory);
60   void set_ftp_transaction_factory(
61       FtpTransactionFactory* ftp_transaction_factory);
62 
63  private:
64   // We use a raw pointer to prevent reference cycles, since
65   // URLRequestContextStorage can often be contained within a URLRequestContext
66   // subclass.
67   URLRequestContext* const context_;
68 
69   // Owned members.
70   scoped_ptr<NetLog> net_log_;
71   scoped_ptr<HostResolver> host_resolver_;
72   scoped_ptr<CertVerifier> cert_verifier_;
73   scoped_ptr<DnsRRResolver> dnsrr_resolver_;
74   scoped_ptr<DnsCertProvenanceChecker> dns_cert_checker_;
75   scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
76   // TODO(willchan): Remove refcounting on these members.
77   scoped_refptr<ProxyService> proxy_service_;
78   scoped_refptr<SSLConfigService> ssl_config_service_;
79   scoped_ptr<NetworkDelegate> network_delegate_;
80   scoped_refptr<CookieStore> cookie_store_;
81   scoped_ptr<CookiePolicy> cookie_policy_;
82   scoped_refptr<TransportSecurityState> transport_security_state_;
83 
84   scoped_ptr<HttpTransactionFactory> http_transaction_factory_;
85   scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
86 
87   DISALLOW_COPY_AND_ASSIGN(URLRequestContextStorage);
88 };
89 
90 }  // namespace net
91 
92 #endif  // NET_URL_REQUEST_URL_REQUEST_CONTEXT_STORAGE_H_
93