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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 1092223006: [chrome/browser/profiles] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 } // namespace 106 } // namespace
107 107
108 using content::BrowserThread; 108 using content::BrowserThread;
109 109
110 ProfileImplIOData::Handle::Handle(Profile* profile) 110 ProfileImplIOData::Handle::Handle(Profile* profile)
111 : io_data_(new ProfileImplIOData), 111 : io_data_(new ProfileImplIOData),
112 profile_(profile), 112 profile_(profile),
113 initialized_(false) { 113 initialized_(false) {
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 114 DCHECK_CURRENTLY_ON(BrowserThread::UI);
115 DCHECK(profile); 115 DCHECK(profile);
116 } 116 }
117 117
118 ProfileImplIOData::Handle::~Handle() { 118 ProfileImplIOData::Handle::~Handle() {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 119 DCHECK_CURRENTLY_ON(BrowserThread::UI);
120 if (io_data_->predictor_ != NULL) { 120 if (io_data_->predictor_ != NULL) {
121 // io_data_->predictor_ might be NULL if Init() was never called 121 // io_data_->predictor_ might be NULL if Init() was never called
122 // (i.e. we shut down before ProfileImpl::DoFinalInit() got called). 122 // (i.e. we shut down before ProfileImpl::DoFinalInit() got called).
123 bool save_prefs = true; 123 bool save_prefs = true;
124 #if defined(OS_CHROMEOS) 124 #if defined(OS_CHROMEOS)
125 save_prefs = !chromeos::ProfileHelper::IsSigninProfile(profile_); 125 save_prefs = !chromeos::ProfileHelper::IsSigninProfile(profile_);
126 #endif 126 #endif
127 if (save_prefs) 127 if (save_prefs)
128 io_data_->predictor_->SaveStateForNextStartupAndTrim(); 128 io_data_->predictor_->SaveStateForNextStartupAndTrim();
129 io_data_->predictor_->ShutdownOnUIThread(); 129 io_data_->predictor_->ShutdownOnUIThread();
(...skipping 17 matching lines...) Expand all
147 int cache_max_size, 147 int cache_max_size,
148 const base::FilePath& media_cache_path, 148 const base::FilePath& media_cache_path,
149 int media_cache_max_size, 149 int media_cache_max_size,
150 const base::FilePath& extensions_cookie_path, 150 const base::FilePath& extensions_cookie_path,
151 const base::FilePath& profile_path, 151 const base::FilePath& profile_path,
152 chrome_browser_net::Predictor* predictor, 152 chrome_browser_net::Predictor* predictor,
153 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, 153 content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
154 storage::SpecialStoragePolicy* special_storage_policy, 154 storage::SpecialStoragePolicy* special_storage_policy,
155 scoped_ptr<domain_reliability::DomainReliabilityMonitor> 155 scoped_ptr<domain_reliability::DomainReliabilityMonitor>
156 domain_reliability_monitor) { 156 domain_reliability_monitor) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 157 DCHECK_CURRENTLY_ON(BrowserThread::UI);
158 DCHECK(!io_data_->lazy_params_); 158 DCHECK(!io_data_->lazy_params_);
159 DCHECK(predictor); 159 DCHECK(predictor);
160 160
161 LazyParams* lazy_params = new LazyParams(); 161 LazyParams* lazy_params = new LazyParams();
162 162
163 lazy_params->cookie_path = cookie_path; 163 lazy_params->cookie_path = cookie_path;
164 lazy_params->channel_id_path = channel_id_path; 164 lazy_params->channel_id_path = channel_id_path;
165 lazy_params->cache_path = cache_path; 165 lazy_params->cache_path = cache_path;
166 lazy_params->cache_max_size = cache_max_size; 166 lazy_params->cache_max_size = cache_max_size;
167 lazy_params->media_cache_path = media_cache_path; 167 lazy_params->media_cache_path = media_cache_path;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_)-> 201 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_)->
202 InitDataReductionProxySettings( 202 InitDataReductionProxySettings(
203 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), 203 io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(),
204 profile_->GetRequestContext(), 204 profile_->GetRequestContext(),
205 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)); 205 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI));
206 } 206 }
207 207
208 content::ResourceContext* 208 content::ResourceContext*
209 ProfileImplIOData::Handle::GetResourceContext() const { 209 ProfileImplIOData::Handle::GetResourceContext() const {
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 210 DCHECK_CURRENTLY_ON(BrowserThread::UI);
211 LazyInitialize(); 211 LazyInitialize();
212 return GetResourceContextNoInit(); 212 return GetResourceContextNoInit();
213 } 213 }
214 214
215 content::ResourceContext* 215 content::ResourceContext*
216 ProfileImplIOData::Handle::GetResourceContextNoInit() const { 216 ProfileImplIOData::Handle::GetResourceContextNoInit() const {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 217 DCHECK_CURRENTLY_ON(BrowserThread::UI);
218 // Don't call LazyInitialize here, since the resource context is created at 218 // Don't call LazyInitialize here, since the resource context is created at
219 // the beginning of initalization and is used by some members while they're 219 // the beginning of initalization and is used by some members while they're
220 // being initialized (i.e. AppCacheService). 220 // being initialized (i.e. AppCacheService).
221 return io_data_->GetResourceContext(); 221 return io_data_->GetResourceContext();
222 } 222 }
223 223
224 scoped_refptr<ChromeURLRequestContextGetter> 224 scoped_refptr<ChromeURLRequestContextGetter>
225 ProfileImplIOData::Handle::CreateMainRequestContextGetter( 225 ProfileImplIOData::Handle::CreateMainRequestContextGetter(
226 content::ProtocolHandlerMap* protocol_handlers, 226 content::ProtocolHandlerMap* protocol_handlers,
227 content::URLRequestInterceptorScopedVector request_interceptors, 227 content::URLRequestInterceptorScopedVector request_interceptors,
228 PrefService* local_state, 228 PrefService* local_state,
229 IOThread* io_thread) const { 229 IOThread* io_thread) const {
230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
231 LazyInitialize(); 231 LazyInitialize();
232 DCHECK(!main_request_context_getter_.get()); 232 DCHECK(!main_request_context_getter_.get());
233 main_request_context_getter_ = ChromeURLRequestContextGetter::Create( 233 main_request_context_getter_ = ChromeURLRequestContextGetter::Create(
234 profile_, io_data_, protocol_handlers, request_interceptors.Pass()); 234 profile_, io_data_, protocol_handlers, request_interceptors.Pass());
235 235
236 io_data_->predictor_ 236 io_data_->predictor_
237 ->InitNetworkPredictor(profile_->GetPrefs(), 237 ->InitNetworkPredictor(profile_->GetPrefs(),
238 local_state, 238 local_state,
239 io_thread, 239 io_thread,
240 main_request_context_getter_.get(), 240 main_request_context_getter_.get(),
241 io_data_); 241 io_data_);
242 242
243 content::NotificationService::current()->Notify( 243 content::NotificationService::current()->Notify(
244 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, 244 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
245 content::Source<Profile>(profile_), 245 content::Source<Profile>(profile_),
246 content::NotificationService::NoDetails()); 246 content::NotificationService::NoDetails());
247 return main_request_context_getter_; 247 return main_request_context_getter_;
248 } 248 }
249 249
250 scoped_refptr<ChromeURLRequestContextGetter> 250 scoped_refptr<ChromeURLRequestContextGetter>
251 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const { 251 ProfileImplIOData::Handle::GetMediaRequestContextGetter() const {
252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 252 DCHECK_CURRENTLY_ON(BrowserThread::UI);
253 LazyInitialize(); 253 LazyInitialize();
254 if (!media_request_context_getter_.get()) { 254 if (!media_request_context_getter_.get()) {
255 media_request_context_getter_ = 255 media_request_context_getter_ =
256 ChromeURLRequestContextGetter::CreateForMedia(profile_, io_data_); 256 ChromeURLRequestContextGetter::CreateForMedia(profile_, io_data_);
257 } 257 }
258 return media_request_context_getter_; 258 return media_request_context_getter_;
259 } 259 }
260 260
261 scoped_refptr<ChromeURLRequestContextGetter> 261 scoped_refptr<ChromeURLRequestContextGetter>
262 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const { 262 ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const {
263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 263 DCHECK_CURRENTLY_ON(BrowserThread::UI);
264 LazyInitialize(); 264 LazyInitialize();
265 if (!extensions_request_context_getter_.get()) { 265 if (!extensions_request_context_getter_.get()) {
266 extensions_request_context_getter_ = 266 extensions_request_context_getter_ =
267 ChromeURLRequestContextGetter::CreateForExtensions(profile_, io_data_); 267 ChromeURLRequestContextGetter::CreateForExtensions(profile_, io_data_);
268 } 268 }
269 return extensions_request_context_getter_; 269 return extensions_request_context_getter_;
270 } 270 }
271 271
272 scoped_refptr<ChromeURLRequestContextGetter> 272 scoped_refptr<ChromeURLRequestContextGetter>
273 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( 273 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter(
274 const base::FilePath& partition_path, 274 const base::FilePath& partition_path,
275 bool in_memory, 275 bool in_memory,
276 content::ProtocolHandlerMap* protocol_handlers, 276 content::ProtocolHandlerMap* protocol_handlers,
277 content::URLRequestInterceptorScopedVector request_interceptors) const { 277 content::URLRequestInterceptorScopedVector request_interceptors) const {
278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 278 DCHECK_CURRENTLY_ON(BrowserThread::UI);
279 // Check that the partition_path is not the same as the base profile path. We 279 // Check that the partition_path is not the same as the base profile path. We
280 // expect isolated partition, which will never go to the default profile path. 280 // expect isolated partition, which will never go to the default profile path.
281 CHECK(partition_path != profile_->GetPath()); 281 CHECK(partition_path != profile_->GetPath());
282 LazyInitialize(); 282 LazyInitialize();
283 283
284 // Keep a map of request context getters, one per requested storage partition. 284 // Keep a map of request context getters, one per requested storage partition.
285 StoragePartitionDescriptor descriptor(partition_path, in_memory); 285 StoragePartitionDescriptor descriptor(partition_path, in_memory);
286 ChromeURLRequestContextGetterMap::iterator iter = 286 ChromeURLRequestContextGetterMap::iterator iter =
287 app_request_context_getter_map_.find(descriptor); 287 app_request_context_getter_map_.find(descriptor);
288 if (iter != app_request_context_getter_map_.end()) 288 if (iter != app_request_context_getter_map_.end())
(...skipping 13 matching lines...) Expand all
302 request_interceptors.Pass()); 302 request_interceptors.Pass());
303 app_request_context_getter_map_[descriptor] = context; 303 app_request_context_getter_map_[descriptor] = context;
304 304
305 return context; 305 return context;
306 } 306 }
307 307
308 scoped_refptr<ChromeURLRequestContextGetter> 308 scoped_refptr<ChromeURLRequestContextGetter>
309 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( 309 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter(
310 const base::FilePath& partition_path, 310 const base::FilePath& partition_path,
311 bool in_memory) const { 311 bool in_memory) const {
312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 312 DCHECK_CURRENTLY_ON(BrowserThread::UI);
313 // We must have a non-default path, or this will act like the default media 313 // We must have a non-default path, or this will act like the default media
314 // context. 314 // context.
315 CHECK(partition_path != profile_->GetPath()); 315 CHECK(partition_path != profile_->GetPath());
316 LazyInitialize(); 316 LazyInitialize();
317 317
318 // Keep a map of request context getters, one per requested storage partition. 318 // Keep a map of request context getters, one per requested storage partition.
319 StoragePartitionDescriptor descriptor(partition_path, in_memory); 319 StoragePartitionDescriptor descriptor(partition_path, in_memory);
320 ChromeURLRequestContextGetterMap::iterator iter = 320 ChromeURLRequestContextGetterMap::iterator iter =
321 isolated_media_request_context_getter_map_.find(descriptor); 321 isolated_media_request_context_getter_map_.find(descriptor);
322 if (iter != isolated_media_request_context_getter_map_.end()) 322 if (iter != isolated_media_request_context_getter_map_.end())
323 return iter->second; 323 return iter->second;
324 324
325 // Get the app context as the starting point for the media context, so that 325 // Get the app context as the starting point for the media context, so that
326 // it uses the app's cookie store. 326 // it uses the app's cookie store.
327 ChromeURLRequestContextGetterMap::const_iterator app_iter = 327 ChromeURLRequestContextGetterMap::const_iterator app_iter =
328 app_request_context_getter_map_.find(descriptor); 328 app_request_context_getter_map_.find(descriptor);
329 DCHECK(app_iter != app_request_context_getter_map_.end()); 329 DCHECK(app_iter != app_request_context_getter_map_.end());
330 ChromeURLRequestContextGetter* app_context = app_iter->second.get(); 330 ChromeURLRequestContextGetter* app_context = app_iter->second.get();
331 ChromeURLRequestContextGetter* context = 331 ChromeURLRequestContextGetter* context =
332 ChromeURLRequestContextGetter::CreateForIsolatedMedia( 332 ChromeURLRequestContextGetter::CreateForIsolatedMedia(
333 profile_, app_context, io_data_, descriptor); 333 profile_, app_context, io_data_, descriptor);
334 isolated_media_request_context_getter_map_[descriptor] = context; 334 isolated_media_request_context_getter_map_[descriptor] = context;
335 335
336 return context; 336 return context;
337 } 337 }
338 338
339 DevToolsNetworkController* 339 DevToolsNetworkController*
340 ProfileImplIOData::Handle::GetDevToolsNetworkController() const { 340 ProfileImplIOData::Handle::GetDevToolsNetworkController() const {
341 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 341 DCHECK_CURRENTLY_ON(BrowserThread::UI);
342 return io_data_->network_controller(); 342 return io_data_->network_controller();
343 } 343 }
344 344
345 void ProfileImplIOData::Handle::ClearNetworkingHistorySince( 345 void ProfileImplIOData::Handle::ClearNetworkingHistorySince(
346 base::Time time, 346 base::Time time,
347 const base::Closure& completion) { 347 const base::Closure& completion) {
348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 348 DCHECK_CURRENTLY_ON(BrowserThread::UI);
349 LazyInitialize(); 349 LazyInitialize();
350 350
351 BrowserThread::PostTask( 351 BrowserThread::PostTask(
352 BrowserThread::IO, FROM_HERE, 352 BrowserThread::IO, FROM_HERE,
353 base::Bind( 353 base::Bind(
354 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread, 354 &ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread,
355 base::Unretained(io_data_), 355 base::Unretained(io_data_),
356 time, 356 time,
357 completion)); 357 completion));
358 } 358 }
359 359
360 void ProfileImplIOData::Handle::LazyInitialize() const { 360 void ProfileImplIOData::Handle::LazyInitialize() const {
361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 361 DCHECK_CURRENTLY_ON(BrowserThread::UI);
362 if (initialized_) 362 if (initialized_)
363 return; 363 return;
364 364
365 // Set initialized_ to true at the beginning in case any of the objects 365 // Set initialized_ to true at the beginning in case any of the objects
366 // below try to get the ResourceContext pointer. 366 // below try to get the ResourceContext pointer.
367 initialized_ = true; 367 initialized_ = true;
368 PrefService* pref_service = profile_->GetPrefs(); 368 PrefService* pref_service = profile_->GetPrefs();
369 io_data_->http_server_properties_manager_ = 369 io_data_->http_server_properties_manager_ =
370 chrome_browser_net::HttpServerPropertiesManagerFactory::CreateManager( 370 chrome_browser_net::HttpServerPropertiesManagerFactory::CreateManager(
371 pref_service); 371 pref_service);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 // We create per-app media contexts on demand, unlike the others above. 800 // We create per-app media contexts on demand, unlike the others above.
801 net::URLRequestContext* media_request_context = 801 net::URLRequestContext* media_request_context =
802 InitializeMediaRequestContext(app_context, partition_descriptor); 802 InitializeMediaRequestContext(app_context, partition_descriptor);
803 DCHECK(media_request_context); 803 DCHECK(media_request_context);
804 return media_request_context; 804 return media_request_context;
805 } 805 }
806 806
807 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread( 807 void ProfileImplIOData::ClearNetworkingHistorySinceOnIOThread(
808 base::Time time, 808 base::Time time,
809 const base::Closure& completion) { 809 const base::Closure& completion) {
810 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 810 DCHECK_CURRENTLY_ON(BrowserThread::IO);
811 DCHECK(initialized()); 811 DCHECK(initialized());
812 812
813 DCHECK(transport_security_state()); 813 DCHECK(transport_security_state());
814 // Completes synchronously. 814 // Completes synchronously.
815 transport_security_state()->DeleteAllDynamicDataSince(time); 815 transport_security_state()->DeleteAllDynamicDataSince(time);
816 DCHECK(http_server_properties_manager_); 816 DCHECK(http_server_properties_manager_);
817 http_server_properties_manager_->Clear(completion); 817 http_server_properties_manager_->Clear(completion);
818 } 818 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_downloader.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698