1 // Copyright (c) 2012 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_CONTEXT_STORAGE_H_
6 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_STORAGE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h"
16 class ChannelIDService
;
18 class FtpTransactionFactory
;
20 class HttpAuthHandlerFactory
;
21 class HttpServerProperties
;
22 class HttpTransactionFactory
;
23 class HttpUserAgentSettings
;
25 class NetworkDelegate
;
28 class SSLConfigService
;
29 class TransportSecurityState
;
30 class URLRequestContext
;
31 class URLRequestBackoffManager
;
32 class URLRequestJobFactory
;
33 class URLRequestThrottlerManager
;
35 // URLRequestContextStorage is a helper class that provides storage for unowned
36 // member variables of URLRequestContext.
37 class NET_EXPORT URLRequestContextStorage
{
39 // Note that URLRequestContextStorage does not acquire a reference to
40 // URLRequestContext, since it is often designed to be embedded in a
41 // URLRequestContext subclass.
42 explicit URLRequestContextStorage(URLRequestContext
* context
);
43 ~URLRequestContextStorage();
45 // These setters will set both the member variables and call the setter on the
46 // URLRequestContext object. In all cases, ownership is passed to |this|.
48 void set_net_log(scoped_ptr
<NetLog
> net_log
);
49 void set_host_resolver(scoped_ptr
<HostResolver
> host_resolver
);
50 void set_cert_verifier(scoped_ptr
<CertVerifier
> cert_verifier
);
51 void set_channel_id_service(scoped_ptr
<ChannelIDService
> channel_id_service
);
52 void set_http_auth_handler_factory(
53 scoped_ptr
<HttpAuthHandlerFactory
> http_auth_handler_factory
);
54 void set_proxy_service(scoped_ptr
<ProxyService
> proxy_service
);
55 void set_ssl_config_service(SSLConfigService
* ssl_config_service
);
56 void set_network_delegate(scoped_ptr
<NetworkDelegate
> network_delegate
);
57 void set_http_server_properties(
58 scoped_ptr
<HttpServerProperties
> http_server_properties
);
59 void set_cookie_store(CookieStore
* cookie_store
);
60 void set_transport_security_state(
61 scoped_ptr
<TransportSecurityState
> transport_security_state
);
62 void set_http_transaction_factory(
63 scoped_ptr
<HttpTransactionFactory
> http_transaction_factory
);
64 void set_job_factory(scoped_ptr
<URLRequestJobFactory
> job_factory
);
65 void set_throttler_manager(
66 scoped_ptr
<URLRequestThrottlerManager
> throttler_manager
);
67 void set_backoff_manager(
68 scoped_ptr
<URLRequestBackoffManager
> backoff_manager
);
69 void set_http_user_agent_settings(
70 scoped_ptr
<HttpUserAgentSettings
> http_user_agent_settings
);
71 void set_sdch_manager(scoped_ptr
<SdchManager
> sdch_manager
);
74 // We use a raw pointer to prevent reference cycles, since
75 // URLRequestContextStorage can often be contained within a URLRequestContext
77 URLRequestContext
* const context_
;
80 scoped_ptr
<NetLog
> net_log_
;
81 scoped_ptr
<HostResolver
> host_resolver_
;
82 scoped_ptr
<CertVerifier
> cert_verifier_
;
83 // The ChannelIDService must outlive the HttpTransactionFactory.
84 scoped_ptr
<ChannelIDService
> channel_id_service_
;
85 scoped_ptr
<HttpAuthHandlerFactory
> http_auth_handler_factory_
;
86 scoped_ptr
<ProxyService
> proxy_service_
;
87 // TODO(willchan): Remove refcounting on these members.
88 scoped_refptr
<SSLConfigService
> ssl_config_service_
;
89 scoped_ptr
<NetworkDelegate
> network_delegate_
;
90 scoped_ptr
<HttpServerProperties
> http_server_properties_
;
91 scoped_ptr
<HttpUserAgentSettings
> http_user_agent_settings_
;
92 scoped_refptr
<CookieStore
> cookie_store_
;
93 scoped_ptr
<TransportSecurityState
> transport_security_state_
;
95 scoped_ptr
<HttpTransactionFactory
> http_transaction_factory_
;
96 scoped_ptr
<URLRequestJobFactory
> job_factory_
;
97 scoped_ptr
<URLRequestThrottlerManager
> throttler_manager_
;
98 scoped_ptr
<URLRequestBackoffManager
> backoff_manager_
;
99 scoped_ptr
<SdchManager
> sdch_manager_
;
101 DISALLOW_COPY_AND_ASSIGN(URLRequestContextStorage
);
106 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_STORAGE_H_