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

Side by Side Diff: ios/chrome/browser/browser_state/chrome_browser_state_io_data.h

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add header Created 4 years, 8 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ 5 #ifndef IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_
6 #define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ 6 #define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "components/content_settings/core/common/content_settings_types.h" 18 #include "components/content_settings/core/common/content_settings_types.h"
19 #include "components/prefs/pref_member.h" 19 #include "components/prefs/pref_member.h"
20 #include "ios/chrome/browser/ios_chrome_io_thread.h" 20 #include "ios/chrome/browser/ios_chrome_io_thread.h"
21 #include "ios/chrome/browser/net/net_types.h" 21 #include "ios/chrome/browser/net/net_types.h"
22 #include "net/cert/ct_verifier.h" 22 #include "net/cert/ct_verifier.h"
23 #include "net/cookies/cookie_monster.h" 23 #include "net/cookies/cookie_monster.h"
24 #include "net/http/http_cache.h" 24 #include "net/http/http_cache.h"
25 #include "net/http/http_network_session.h" 25 #include "net/http/http_network_session.h"
26 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // methods other than GetResouceContext or GetMetricsEnabledStateOnIOThread. 86 // methods other than GetResouceContext or GetMetricsEnabledStateOnIOThread.
87 void Init(ProtocolHandlerMap* protocol_handlers) const; 87 void Init(ProtocolHandlerMap* protocol_handlers) const;
88 88
89 net::URLRequestContext* GetMainRequestContext() const; 89 net::URLRequestContext* GetMainRequestContext() const;
90 net::URLRequestContext* GetIsolatedAppRequestContext( 90 net::URLRequestContext* GetIsolatedAppRequestContext(
91 net::URLRequestContext* main_context, 91 net::URLRequestContext* main_context,
92 const base::FilePath& partition_path) const; 92 const base::FilePath& partition_path) const;
93 93
94 // Sets the cookie store associated with a partition path. 94 // Sets the cookie store associated with a partition path.
95 // The path must exist. If there is already a cookie store, it is deleted. 95 // The path must exist. If there is already a cookie store, it is deleted.
96 void SetCookieStoreForPartitionPath(scoped_ptr<net::CookieStore> cookie_store, 96 void SetCookieStoreForPartitionPath(
97 const base::FilePath& partition_path); 97 std::unique_ptr<net::CookieStore> cookie_store,
98 const base::FilePath& partition_path);
98 99
99 // These are useful when the Chrome layer is called from the content layer 100 // These are useful when the Chrome layer is called from the content layer
100 // with a content::ResourceContext, and they want access to Chrome data for 101 // with a content::ResourceContext, and they want access to Chrome data for
101 // that browser state. 102 // that browser state.
102 content_settings::CookieSettings* GetCookieSettings() const; 103 content_settings::CookieSettings* GetCookieSettings() const;
103 HostContentSettingsMap* GetHostContentSettingsMap() const; 104 HostContentSettingsMap* GetHostContentSettingsMap() const;
104 105
105 StringPrefMember* google_services_account_id() const { 106 StringPrefMember* google_services_account_id() const {
106 return &google_services_user_account_id_; 107 return &google_services_user_account_id_;
107 } 108 }
(...skipping 21 matching lines...) Expand all
129 // thread, and should only be called from there. 130 // thread, and should only be called from there.
130 bool GetMetricsEnabledStateOnIOThread() const; 131 bool GetMetricsEnabledStateOnIOThread() const;
131 132
132 protected: 133 protected:
133 // A URLRequestContext for apps that owns its cookie store and HTTP factory, 134 // A URLRequestContext for apps that owns its cookie store and HTTP factory,
134 // to ensure they are deleted. 135 // to ensure they are deleted.
135 class AppRequestContext : public net::URLRequestContext { 136 class AppRequestContext : public net::URLRequestContext {
136 public: 137 public:
137 AppRequestContext(); 138 AppRequestContext();
138 139
139 void SetCookieStore(scoped_ptr<net::CookieStore> cookie_store); 140 void SetCookieStore(std::unique_ptr<net::CookieStore> cookie_store);
140 void SetHttpTransactionFactory( 141 void SetHttpTransactionFactory(
141 scoped_ptr<net::HttpTransactionFactory> http_factory); 142 std::unique_ptr<net::HttpTransactionFactory> http_factory);
142 void SetJobFactory(scoped_ptr<net::URLRequestJobFactory> job_factory); 143 void SetJobFactory(std::unique_ptr<net::URLRequestJobFactory> job_factory);
143 144
144 ~AppRequestContext() override; 145 ~AppRequestContext() override;
145 146
146 private: 147 private:
147 scoped_ptr<net::CookieStore> cookie_store_; 148 std::unique_ptr<net::CookieStore> cookie_store_;
148 scoped_ptr<net::HttpTransactionFactory> http_factory_; 149 std::unique_ptr<net::HttpTransactionFactory> http_factory_;
149 scoped_ptr<net::URLRequestJobFactory> job_factory_; 150 std::unique_ptr<net::URLRequestJobFactory> job_factory_;
150 }; 151 };
151 152
152 // Created on the UI thread, read on the IO thread during 153 // Created on the UI thread, read on the IO thread during
153 // ChromeBrowserStateIOData lazy initialization. 154 // ChromeBrowserStateIOData lazy initialization.
154 struct ProfileParams { 155 struct ProfileParams {
155 ProfileParams(); 156 ProfileParams();
156 ~ProfileParams(); 157 ~ProfileParams();
157 158
158 base::FilePath path; 159 base::FilePath path;
159 IOSChromeIOThread* io_thread; 160 IOSChromeIOThread* io_thread;
160 scoped_refptr<content_settings::CookieSettings> cookie_settings; 161 scoped_refptr<content_settings::CookieSettings> cookie_settings;
161 scoped_refptr<HostContentSettingsMap> host_content_settings_map; 162 scoped_refptr<HostContentSettingsMap> host_content_settings_map;
162 scoped_refptr<net::SSLConfigService> ssl_config_service; 163 scoped_refptr<net::SSLConfigService> ssl_config_service;
163 scoped_refptr<net::CookieMonsterDelegate> cookie_monster_delegate; 164 scoped_refptr<net::CookieMonsterDelegate> cookie_monster_delegate;
164 165
165 // We need to initialize the ProxyConfigService from the UI thread 166 // We need to initialize the ProxyConfigService from the UI thread
166 // because on linux it relies on initializing things through gconf, 167 // because on linux it relies on initializing things through gconf,
167 // and needs to be on the main thread. 168 // and needs to be on the main thread.
168 scoped_ptr<net::ProxyConfigService> proxy_config_service; 169 std::unique_ptr<net::ProxyConfigService> proxy_config_service;
169 170
170 // The browser state this struct was populated from. It's passed as a void* 171 // The browser state this struct was populated from. It's passed as a void*
171 // to ensure it's not accidently used on the IO thread. 172 // to ensure it's not accidently used on the IO thread.
172 void* browser_state; 173 void* browser_state;
173 }; 174 };
174 175
175 explicit ChromeBrowserStateIOData( 176 explicit ChromeBrowserStateIOData(
176 ios::ChromeBrowserStateType browser_state_type); 177 ios::ChromeBrowserStateType browser_state_type);
177 178
178 void InitializeOnUIThread(ios::ChromeBrowserState* browser_state); 179 void InitializeOnUIThread(ios::ChromeBrowserState* browser_state);
179 void ApplyProfileParamsToContext(net::URLRequestContext* context) const; 180 void ApplyProfileParamsToContext(net::URLRequestContext* context) const;
180 181
181 scoped_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults( 182 std::unique_ptr<net::URLRequestJobFactory> SetUpJobFactoryDefaults(
182 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory, 183 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
183 URLRequestInterceptorScopedVector request_interceptors, 184 URLRequestInterceptorScopedVector request_interceptors,
184 net::NetworkDelegate* network_delegate) const; 185 net::NetworkDelegate* network_delegate) const;
185 186
186 // Called when the ChromeBrowserState is destroyed. |context_getters| must 187 // Called when the ChromeBrowserState is destroyed. |context_getters| must
187 // include all URLRequestContextGetters that refer to the 188 // include all URLRequestContextGetters that refer to the
188 // ChromeBrowserStateIOData's URLRequestContexts. Triggers destruction of the 189 // ChromeBrowserStateIOData's URLRequestContexts. Triggers destruction of the
189 // ChromeBrowserStateIOData and shuts down |context_getters| safely on the IO 190 // ChromeBrowserStateIOData and shuts down |context_getters| safely on the IO
190 // thread. 191 // thread.
191 // TODO(mmenke): Passing all those URLRequestContextGetters around like this 192 // TODO(mmenke): Passing all those URLRequestContextGetters around like this
192 // is really silly. Can we do something cleaner? 193 // is really silly. Can we do something cleaner?
193 void ShutdownOnUIThread( 194 void ShutdownOnUIThread(
194 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters); 195 std::unique_ptr<IOSChromeURLRequestContextGetterVector> context_getters);
195 196
196 // A ChannelIDService object is created by a derived class of 197 // A ChannelIDService object is created by a derived class of
197 // ChromeBrowserStateIOData, and the derived class calls this method to set 198 // ChromeBrowserStateIOData, and the derived class calls this method to set
198 // the channel_id_service_ member and transfers ownership to the base class. 199 // the channel_id_service_ member and transfers ownership to the base class.
199 void set_channel_id_service(net::ChannelIDService* channel_id_service) const; 200 void set_channel_id_service(net::ChannelIDService* channel_id_service) const;
200 201
201 net::ProxyService* proxy_service() const { return proxy_service_.get(); } 202 net::ProxyService* proxy_service() const { return proxy_service_.get(); }
202 203
203 base::WeakPtr<net::HttpServerProperties> http_server_properties() const; 204 base::WeakPtr<net::HttpServerProperties> http_server_properties() const;
204 205
205 void set_http_server_properties( 206 void set_http_server_properties(
206 scoped_ptr<net::HttpServerProperties> http_server_properties) const; 207 std::unique_ptr<net::HttpServerProperties> http_server_properties) const;
207 208
208 net::URLRequestContext* main_request_context() const { 209 net::URLRequestContext* main_request_context() const {
209 return main_request_context_.get(); 210 return main_request_context_.get();
210 } 211 }
211 212
212 bool initialized() const { return initialized_; } 213 bool initialized() const { return initialized_; }
213 214
214 scoped_ptr<net::HttpNetworkSession> CreateHttpNetworkSession( 215 std::unique_ptr<net::HttpNetworkSession> CreateHttpNetworkSession(
215 const ProfileParams& profile_params) const; 216 const ProfileParams& profile_params) const;
216 217
217 // Creates main network transaction factory. 218 // Creates main network transaction factory.
218 scoped_ptr<net::HttpCache> CreateMainHttpFactory( 219 std::unique_ptr<net::HttpCache> CreateMainHttpFactory(
219 net::HttpNetworkSession* session, 220 net::HttpNetworkSession* session,
220 scoped_ptr<net::HttpCache::BackendFactory> main_backend) const; 221 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const;
221 222
222 // Creates network transaction factory. 223 // Creates network transaction factory.
223 scoped_ptr<net::HttpCache> CreateHttpFactory( 224 std::unique_ptr<net::HttpCache> CreateHttpFactory(
224 net::HttpNetworkSession* shared_session, 225 net::HttpNetworkSession* shared_session,
225 scoped_ptr<net::HttpCache::BackendFactory> backend) const; 226 std::unique_ptr<net::HttpCache::BackendFactory> backend) const;
226 227
227 private: 228 private:
228 typedef std::map<base::FilePath, AppRequestContext*> URLRequestContextMap; 229 typedef std::map<base::FilePath, AppRequestContext*> URLRequestContextMap;
229 230
230 // -------------------------------------------- 231 // --------------------------------------------
231 // Virtual interface for subtypes to implement: 232 // Virtual interface for subtypes to implement:
232 // -------------------------------------------- 233 // --------------------------------------------
233 234
234 // Does the actual initialization of the ChromeBrowserStateIOData subtype. 235 // Does the actual initialization of the ChromeBrowserStateIOData subtype.
235 // Subtypes should use the static helper functions above to implement this. 236 // Subtypes should use the static helper functions above to implement this.
236 virtual void InitializeInternal( 237 virtual void InitializeInternal(
237 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, 238 std::unique_ptr<IOSChromeNetworkDelegate> chrome_network_delegate,
238 ProfileParams* profile_params, 239 ProfileParams* profile_params,
239 ProtocolHandlerMap* protocol_handlers) const = 0; 240 ProtocolHandlerMap* protocol_handlers) const = 0;
240 241
241 // Does an on-demand initialization of a RequestContext for the given 242 // Does an on-demand initialization of a RequestContext for the given
242 // isolated app. 243 // isolated app.
243 virtual AppRequestContext* InitializeAppRequestContext( 244 virtual AppRequestContext* InitializeAppRequestContext(
244 net::URLRequestContext* main_context) const = 0; 245 net::URLRequestContext* main_context) const = 0;
245 246
246 // These functions are used to transfer ownership of the lazily initialized 247 // These functions are used to transfer ownership of the lazily initialized
247 // context from ChromeBrowserStateIOData to the URLRequestContextGetter. 248 // context from ChromeBrowserStateIOData to the URLRequestContextGetter.
(...skipping 11 matching lines...) Expand all
259 // * Therefore, ResourceContext should be listed last, and then the 260 // * Therefore, ResourceContext should be listed last, and then the
260 // URLRequestContexts, and then the URLRequestContext members. 261 // URLRequestContexts, and then the URLRequestContext members.
261 // * Note that URLRequestContext members have a directed dependency graph 262 // * Note that URLRequestContext members have a directed dependency graph
262 // too, so they must themselves be ordered correctly. 263 // too, so they must themselves be ordered correctly.
263 264
264 // Tracks whether or not we've been lazily initialized. 265 // Tracks whether or not we've been lazily initialized.
265 mutable bool initialized_; 266 mutable bool initialized_;
266 267
267 // Data from the UI thread from the ChromeBrowserState, used to initialize 268 // Data from the UI thread from the ChromeBrowserState, used to initialize
268 // ChromeBrowserStateIOData. Deleted after lazy initialization. 269 // ChromeBrowserStateIOData. Deleted after lazy initialization.
269 mutable scoped_ptr<ProfileParams> profile_params_; 270 mutable std::unique_ptr<ProfileParams> profile_params_;
270 271
271 mutable StringPrefMember google_services_user_account_id_; 272 mutable StringPrefMember google_services_user_account_id_;
272 273
273 // Member variables which are pointed to by the various context objects. 274 // Member variables which are pointed to by the various context objects.
274 mutable BooleanPrefMember enable_referrers_; 275 mutable BooleanPrefMember enable_referrers_;
275 mutable BooleanPrefMember enable_do_not_track_; 276 mutable BooleanPrefMember enable_do_not_track_;
276 mutable BooleanPrefMember safe_browsing_enabled_; 277 mutable BooleanPrefMember safe_browsing_enabled_;
277 mutable BooleanPrefMember sync_disabled_; 278 mutable BooleanPrefMember sync_disabled_;
278 mutable BooleanPrefMember signin_allowed_; 279 mutable BooleanPrefMember signin_allowed_;
279 280
280 BooleanPrefMember enable_metrics_; 281 BooleanPrefMember enable_metrics_;
281 282
282 // Pointed to by URLRequestContext. 283 // Pointed to by URLRequestContext.
283 mutable scoped_ptr<net::ChannelIDService> channel_id_service_; 284 mutable std::unique_ptr<net::ChannelIDService> channel_id_service_;
284 285
285 mutable scoped_ptr<net::ProxyService> proxy_service_; 286 mutable std::unique_ptr<net::ProxyService> proxy_service_;
286 mutable scoped_ptr<net::TransportSecurityState> transport_security_state_; 287 mutable std::unique_ptr<net::TransportSecurityState>
287 mutable scoped_ptr<net::CTVerifier> cert_transparency_verifier_; 288 transport_security_state_;
288 mutable scoped_ptr<net::HttpServerProperties> http_server_properties_; 289 mutable std::unique_ptr<net::CTVerifier> cert_transparency_verifier_;
289 mutable scoped_ptr<net::TransportSecurityPersister> 290 mutable std::unique_ptr<net::HttpServerProperties> http_server_properties_;
291 mutable std::unique_ptr<net::TransportSecurityPersister>
290 transport_security_persister_; 292 transport_security_persister_;
291 mutable scoped_ptr<net::CertificateReportSender> certificate_report_sender_; 293 mutable std::unique_ptr<net::CertificateReportSender>
294 certificate_report_sender_;
292 295
293 // These are only valid in between LazyInitialize() and their accessor being 296 // These are only valid in between LazyInitialize() and their accessor being
294 // called. 297 // called.
295 mutable scoped_ptr<net::URLRequestContext> main_request_context_; 298 mutable std::unique_ptr<net::URLRequestContext> main_request_context_;
296 // One URLRequestContext per isolated app for main and media requests. 299 // One URLRequestContext per isolated app for main and media requests.
297 mutable URLRequestContextMap app_request_context_map_; 300 mutable URLRequestContextMap app_request_context_map_;
298 301
299 mutable scoped_refptr<content_settings::CookieSettings> cookie_settings_; 302 mutable scoped_refptr<content_settings::CookieSettings> cookie_settings_;
300 303
301 mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 304 mutable scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
302 305
303 mutable scoped_ptr<IOSChromeHttpUserAgentSettings> 306 mutable std::unique_ptr<IOSChromeHttpUserAgentSettings>
304 chrome_http_user_agent_settings_; 307 chrome_http_user_agent_settings_;
305 308
306 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. 309 // TODO(jhawkins): Remove once crbug.com/102004 is fixed.
307 bool initialized_on_UI_thread_; 310 bool initialized_on_UI_thread_;
308 311
309 const ios::ChromeBrowserStateType browser_state_type_; 312 const ios::ChromeBrowserStateType browser_state_type_;
310 313
311 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserStateIOData); 314 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserStateIOData);
312 }; 315 };
313 316
314 #endif // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_ 317 #endif // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698