OLD | NEW |
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 #include "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 initialized_on_UI_thread_(false) { | 289 initialized_on_UI_thread_(false) { |
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
291 } | 291 } |
292 | 292 |
293 ProfileIOData::~ProfileIOData() { | 293 ProfileIOData::~ProfileIOData() { |
294 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 294 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
296 } | 296 } |
297 | 297 |
298 // static | 298 // static |
| 299 ProfileIOData* ProfileIOData::FromResourceContext( |
| 300 content::ResourceContext* rc) { |
| 301 return (static_cast<ResourceContext*>(rc))->io_data_; |
| 302 } |
| 303 |
| 304 // static |
299 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { | 305 bool ProfileIOData::IsHandledProtocol(const std::string& scheme) { |
300 DCHECK_EQ(scheme, StringToLowerASCII(scheme)); | 306 DCHECK_EQ(scheme, StringToLowerASCII(scheme)); |
301 static const char* const kProtocolList[] = { | 307 static const char* const kProtocolList[] = { |
302 chrome::kExtensionScheme, | 308 chrome::kExtensionScheme, |
303 chrome::kChromeUIScheme, | 309 chrome::kChromeUIScheme, |
304 chrome::kChromeDevToolsScheme, | 310 chrome::kChromeDevToolsScheme, |
305 #if defined(OS_CHROMEOS) | 311 #if defined(OS_CHROMEOS) |
306 chrome::kMetadataScheme, | 312 chrome::kMetadataScheme, |
307 #endif // defined(OS_CHROMEOS) | 313 #endif // defined(OS_CHROMEOS) |
308 chrome::kBlobScheme, | 314 chrome::kBlobScheme, |
309 chrome::kFileSystemScheme, | 315 chrome::kFileSystemScheme, |
310 }; | 316 }; |
311 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { | 317 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
312 if (scheme == kProtocolList[i]) | 318 if (scheme == kProtocolList[i]) |
313 return true; | 319 return true; |
314 } | 320 } |
315 return net::URLRequest::IsHandledProtocol(scheme); | 321 return net::URLRequest::IsHandledProtocol(scheme); |
316 } | 322 } |
317 | 323 |
318 bool ProfileIOData::IsHandledURL(const GURL& url) { | 324 bool ProfileIOData::IsHandledURL(const GURL& url) { |
319 if (!url.is_valid()) { | 325 if (!url.is_valid()) { |
320 // We handle error cases. | 326 // We handle error cases. |
321 return true; | 327 return true; |
322 } | 328 } |
323 | 329 |
324 return IsHandledProtocol(url.scheme()); | 330 return IsHandledProtocol(url.scheme()); |
325 } | 331 } |
326 | 332 |
327 const content::ResourceContext& ProfileIOData::GetResourceContext() const { | 333 content::ResourceContext* ProfileIOData::GetResourceContext() const { |
328 return resource_context_; | 334 return &resource_context_; |
329 } | 335 } |
330 | 336 |
331 ChromeURLDataManagerBackend* | 337 ChromeURLDataManagerBackend* |
332 ProfileIOData::GetChromeURLDataManagerBackend() const { | 338 ProfileIOData::GetChromeURLDataManagerBackend() const { |
333 LazyInitialize(); | 339 LazyInitialize(); |
334 return chrome_url_data_manager_backend_.get(); | 340 return chrome_url_data_manager_backend_.get(); |
335 } | 341 } |
336 | 342 |
337 scoped_refptr<ChromeURLRequestContext> | 343 scoped_refptr<ChromeURLRequestContext> |
338 ProfileIOData::GetMainRequestContext() const { | 344 ProfileIOData::GetMainRequestContext() const { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 } | 386 } |
381 | 387 |
382 CookieSettings* ProfileIOData::GetCookieSettings() const { | 388 CookieSettings* ProfileIOData::GetCookieSettings() const { |
383 return cookie_settings_; | 389 return cookie_settings_; |
384 } | 390 } |
385 | 391 |
386 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | 392 DesktopNotificationService* ProfileIOData::GetNotificationService() const { |
387 return notification_service_; | 393 return notification_service_; |
388 } | 394 } |
389 | 395 |
390 ProfileIOData::ResourceContext::ResourceContext(const ProfileIOData* io_data) | 396 ProfileIOData::ResourceContext::ResourceContext(ProfileIOData* io_data) |
391 : io_data_(io_data) { | 397 : io_data_(io_data) { |
392 DCHECK(io_data); | 398 DCHECK(io_data); |
393 } | 399 } |
394 | 400 |
395 ProfileIOData::ResourceContext::~ResourceContext() {} | 401 ProfileIOData::ResourceContext::~ResourceContext() {} |
396 | 402 |
397 void ProfileIOData::ResourceContext::EnsureInitialized() const { | 403 void ProfileIOData::ResourceContext::EnsureInitialized() { |
398 io_data_->LazyInitialize(); | 404 io_data_->LazyInitialize(); |
399 } | 405 } |
400 | 406 |
| 407 net::HostResolver* ProfileIOData::ResourceContext::GetHostResolver() { |
| 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 409 EnsureInitialized(); |
| 410 return host_resolver_; |
| 411 } |
| 412 |
| 413 net::URLRequestContext* ProfileIOData::ResourceContext::GetRequestContext() { |
| 414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 415 EnsureInitialized(); |
| 416 return request_context_; |
| 417 } |
| 418 |
| 419 ChromeAppCacheService* ProfileIOData::ResourceContext::GetAppCacheService() { |
| 420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 421 EnsureInitialized(); |
| 422 return appcache_service_; |
| 423 } |
| 424 |
| 425 webkit_database::DatabaseTracker* |
| 426 ProfileIOData::ResourceContext::GetDatabaseTracker() { |
| 427 EnsureInitialized(); |
| 428 return database_tracker_; |
| 429 } |
| 430 |
| 431 fileapi::FileSystemContext* |
| 432 ProfileIOData::ResourceContext::GetFileSystemContext() { |
| 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 434 EnsureInitialized(); |
| 435 return file_system_context_; |
| 436 } |
| 437 |
| 438 ChromeBlobStorageContext* |
| 439 ProfileIOData::ResourceContext::GetBlobStorageContext() { |
| 440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 441 EnsureInitialized(); |
| 442 return blob_storage_context_; |
| 443 } |
| 444 |
| 445 quota::QuotaManager* ProfileIOData::ResourceContext::GetQuotaManager() { |
| 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 447 EnsureInitialized(); |
| 448 return quota_manager_; |
| 449 } |
| 450 |
| 451 content::HostZoomMap* ProfileIOData::ResourceContext::GetHostZoomMap() { |
| 452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 453 EnsureInitialized(); |
| 454 return host_zoom_map_; |
| 455 } |
| 456 |
| 457 MediaObserver* ProfileIOData::ResourceContext::GetMediaObserver() { |
| 458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 459 EnsureInitialized(); |
| 460 return media_observer_; |
| 461 } |
| 462 |
| 463 media_stream::MediaStreamManager* |
| 464 ProfileIOData::ResourceContext::GetMediaStreamManager() { |
| 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 466 EnsureInitialized(); |
| 467 return media_stream_manager_; |
| 468 } |
| 469 |
| 470 AudioManager* ProfileIOData::ResourceContext::GetAudioManager() { |
| 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 472 EnsureInitialized(); |
| 473 return audio_manager_; |
| 474 } |
| 475 |
401 void ProfileIOData::LazyInitialize() const { | 476 void ProfileIOData::LazyInitialize() const { |
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
403 if (initialized_) | 478 if (initialized_) |
404 return; | 479 return; |
405 | 480 |
406 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. | 481 // TODO(jhawkins): Remove once crbug.com/102004 is fixed. |
407 CHECK(initialized_on_UI_thread_); | 482 CHECK(initialized_on_UI_thread_); |
408 | 483 |
409 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. | 484 // TODO(jhawkins): Return to DCHECK once crbug.com/102004 is fixed. |
410 CHECK(profile_params_.get()); | 485 CHECK(profile_params_.get()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 appcache_service_ = profile_params_->appcache_service; | 573 appcache_service_ = profile_params_->appcache_service; |
499 blob_storage_context_ = profile_params_->blob_storage_context; | 574 blob_storage_context_ = profile_params_->blob_storage_context; |
500 file_system_context_ = profile_params_->file_system_context; | 575 file_system_context_ = profile_params_->file_system_context; |
501 quota_manager_ = profile_params_->quota_manager; | 576 quota_manager_ = profile_params_->quota_manager; |
502 host_zoom_map_ = profile_params_->host_zoom_map; | 577 host_zoom_map_ = profile_params_->host_zoom_map; |
503 host_content_settings_map_ = profile_params_->host_content_settings_map; | 578 host_content_settings_map_ = profile_params_->host_content_settings_map; |
504 cookie_settings_ = profile_params_->cookie_settings; | 579 cookie_settings_ = profile_params_->cookie_settings; |
505 notification_service_ = profile_params_->notification_service; | 580 notification_service_ = profile_params_->notification_service; |
506 extension_info_map_ = profile_params_->extension_info_map; | 581 extension_info_map_ = profile_params_->extension_info_map; |
507 | 582 |
508 resource_context_.set_host_resolver(io_thread_globals->host_resolver.get()); | 583 resource_context_.host_resolver_ = io_thread_globals->host_resolver.get(); |
509 resource_context_.set_request_context(main_request_context_); | 584 resource_context_.request_context_ = main_request_context_; |
510 resource_context_.set_database_tracker(database_tracker_); | 585 resource_context_.database_tracker_ = database_tracker_; |
511 resource_context_.set_appcache_service(appcache_service_); | 586 resource_context_.appcache_service_ = appcache_service_; |
512 resource_context_.set_blob_storage_context(blob_storage_context_); | 587 resource_context_.blob_storage_context_ = blob_storage_context_; |
513 resource_context_.set_file_system_context(file_system_context_); | 588 resource_context_.file_system_context_ = file_system_context_; |
514 resource_context_.set_quota_manager(quota_manager_); | 589 resource_context_.quota_manager_ = quota_manager_; |
515 resource_context_.set_host_zoom_map(host_zoom_map_); | 590 resource_context_.host_zoom_map_ = host_zoom_map_; |
516 resource_context_.SetUserData(NULL, const_cast<ProfileIOData*>(this)); | 591 resource_context_.media_observer_ = |
517 resource_context_.set_media_observer( | 592 io_thread_globals->media.media_internals.get(); |
518 io_thread_globals->media.media_internals.get()); | 593 resource_context_.media_stream_manager_ = media_stream_manager_.get(); |
519 resource_context_.set_media_stream_manager(media_stream_manager_.get()); | 594 resource_context_.audio_manager_ = profile_params_->audio_manager; |
520 resource_context_.set_audio_manager(profile_params_->audio_manager); | |
521 | 595 |
522 LazyInitializeInternal(profile_params_.get()); | 596 LazyInitializeInternal(profile_params_.get()); |
523 | 597 |
524 profile_params_.reset(); | 598 profile_params_.reset(); |
525 initialized_ = true; | 599 initialized_ = true; |
526 } | 600 } |
527 | 601 |
528 void ProfileIOData::ApplyProfileParamsToContext( | 602 void ProfileIOData::ApplyProfileParamsToContext( |
529 ChromeURLRequestContext* context) const { | 603 ChromeURLRequestContext* context) const { |
530 context->set_is_incognito(profile_params_->is_incognito); | 604 context->set_is_incognito(profile_params_->is_incognito); |
(...skipping 20 matching lines...) Expand all Loading... |
551 &resource_context_)); | 625 &resource_context_)); |
552 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 626 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
553 if (!posted) | 627 if (!posted) |
554 delete this; | 628 delete this; |
555 } | 629 } |
556 | 630 |
557 void ProfileIOData::set_origin_bound_cert_service( | 631 void ProfileIOData::set_origin_bound_cert_service( |
558 net::OriginBoundCertService* origin_bound_cert_service) const { | 632 net::OriginBoundCertService* origin_bound_cert_service) const { |
559 origin_bound_cert_service_.reset(origin_bound_cert_service); | 633 origin_bound_cert_service_.reset(origin_bound_cert_service); |
560 } | 634 } |
OLD | NEW |