| OLD | NEW |
| 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.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/download/download_service_factory.h" | 33 #include "chrome/browser/download/download_service_factory.h" |
| 34 #include "chrome/browser/extensions/event_router.h" | 34 #include "chrome/browser/extensions/event_router.h" |
| 35 #include "chrome/browser/extensions/extension_pref_store.h" | 35 #include "chrome/browser/extensions/extension_pref_store.h" |
| 36 #include "chrome/browser/extensions/extension_pref_value_map.h" | 36 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 37 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" | 37 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" |
| 38 #include "chrome/browser/extensions/extension_process_manager.h" | 38 #include "chrome/browser/extensions/extension_process_manager.h" |
| 39 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
| 40 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 40 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 41 #include "chrome/browser/extensions/extension_system.h" | 41 #include "chrome/browser/extensions/extension_system.h" |
| 42 #include "chrome/browser/extensions/user_script_master.h" | 42 #include "chrome/browser/extensions/user_script_master.h" |
| 43 #include "chrome/browser/favicon/favicon_service.h" | 43 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
| 45 #include "chrome/browser/history/history.h" | 45 #include "chrome/browser/history/history.h" |
| 46 #include "chrome/browser/history/history_service_factory.h" | 46 #include "chrome/browser/history/history_service_factory.h" |
| 47 #include "chrome/browser/history/shortcuts_backend.h" | 47 #include "chrome/browser/history/shortcuts_backend.h" |
| 48 #include "chrome/browser/history/top_sites.h" | 48 #include "chrome/browser/history/top_sites.h" |
| 49 #include "chrome/browser/instant/instant_controller.h" | 49 #include "chrome/browser/instant/instant_controller.h" |
| 50 #include "chrome/browser/metrics/metrics_service.h" | 50 #include "chrome/browser/metrics/metrics_service.h" |
| 51 #include "chrome/browser/net/chrome_url_request_context.h" | 51 #include "chrome/browser/net/chrome_url_request_context.h" |
| 52 #include "chrome/browser/net/net_pref_observer.h" | 52 #include "chrome/browser/net/net_pref_observer.h" |
| 53 #include "chrome/browser/net/predictor.h" | 53 #include "chrome/browser/net/predictor.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 ProfileImpl::ProfileImpl(const FilePath& path, | 257 ProfileImpl::ProfileImpl(const FilePath& path, |
| 258 Delegate* delegate, | 258 Delegate* delegate, |
| 259 CreateMode create_mode) | 259 CreateMode create_mode) |
| 260 : path_(path), | 260 : path_(path), |
| 261 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( | 261 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( |
| 262 new VisitedLinkEventListener(this))), | 262 new VisitedLinkEventListener(this))), |
| 263 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 263 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 264 host_content_settings_map_(NULL), | 264 host_content_settings_map_(NULL), |
| 265 favicon_service_created_(false), | |
| 266 start_time_(Time::Now()), | 265 start_time_(Time::Now()), |
| 267 delegate_(delegate), | 266 delegate_(delegate), |
| 268 predictor_(NULL), | 267 predictor_(NULL), |
| 269 session_restore_enabled_(false) { | 268 session_restore_enabled_(false) { |
| 270 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 269 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 271 "profile files to the root directory!"; | 270 "profile files to the root directory!"; |
| 272 | 271 |
| 273 #if defined(ENABLE_SESSION_SERVICE) | 272 #if defined(ENABLE_SESSION_SERVICE) |
| 274 create_session_service_timer_.Start(FROM_HERE, | 273 create_session_service_timer_.Start(FROM_HERE, |
| 275 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 274 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // The HistoryService maintains threads for background processing. Its | 508 // The HistoryService maintains threads for background processing. Its |
| 510 // possible each thread still has tasks on it that have increased the ref | 509 // possible each thread still has tasks on it that have increased the ref |
| 511 // count of the service. In such a situation, when we decrement the refcount, | 510 // count of the service. In such a situation, when we decrement the refcount, |
| 512 // it won't be 0, and the threads/databases aren't properly shut down. By | 511 // it won't be 0, and the threads/databases aren't properly shut down. By |
| 513 // explicitly calling Cleanup/Shutdown we ensure the databases are properly | 512 // explicitly calling Cleanup/Shutdown we ensure the databases are properly |
| 514 // closed. | 513 // closed. |
| 515 | 514 |
| 516 if (top_sites_.get()) | 515 if (top_sites_.get()) |
| 517 top_sites_->Shutdown(); | 516 top_sites_->Shutdown(); |
| 518 | 517 |
| 519 // FaviconService depends on HistoryServce so make sure we delete | |
| 520 // HistoryService first. | |
| 521 favicon_service_.reset(); | |
| 522 | |
| 523 if (pref_proxy_config_tracker_.get()) | 518 if (pref_proxy_config_tracker_.get()) |
| 524 pref_proxy_config_tracker_->DetachFromPrefService(); | 519 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 525 | 520 |
| 526 if (host_content_settings_map_) | 521 if (host_content_settings_map_) |
| 527 host_content_settings_map_->ShutdownOnUIThread(); | 522 host_content_settings_map_->ShutdownOnUIThread(); |
| 528 | 523 |
| 529 // This causes the Preferences file to be written to disk. | 524 // This causes the Preferences file to be written to disk. |
| 530 if (prefs_loaded) | 525 if (prefs_loaded) |
| 531 MarkAsCleanShutdown(); | 526 MarkAsCleanShutdown(); |
| 532 } | 527 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 | 704 |
| 710 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { | 705 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() { |
| 711 return io_data_.GetMediaRequestContextGetter(); | 706 return io_data_.GetMediaRequestContextGetter(); |
| 712 } | 707 } |
| 713 | 708 |
| 714 content::ResourceContext* ProfileImpl::GetResourceContext() { | 709 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 715 return io_data_.GetResourceContext(); | 710 return io_data_.GetResourceContext(); |
| 716 } | 711 } |
| 717 | 712 |
| 718 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { | 713 FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) { |
| 719 if (!favicon_service_created_) { | 714 return FaviconServiceFactory::GetForProfile(this); |
| 720 favicon_service_created_ = true; | |
| 721 favicon_service_.reset(new FaviconService(this)); | |
| 722 } | |
| 723 return favicon_service_.get(); | |
| 724 } | 715 } |
| 725 | 716 |
| 726 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 717 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 727 return io_data_.GetExtensionsRequestContextGetter(); | 718 return io_data_.GetExtensionsRequestContextGetter(); |
| 728 } | 719 } |
| 729 | 720 |
| 730 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp( | 721 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp( |
| 731 const std::string& app_id) { | 722 const std::string& app_id) { |
| 732 return io_data_.GetIsolatedAppRequestContextGetter(app_id); | 723 return io_data_.GetIsolatedAppRequestContextGetter(app_id); |
| 733 } | 724 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 if (!path.empty()) | 1082 if (!path.empty()) |
| 1092 *cache_path = path; | 1083 *cache_path = path; |
| 1093 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1084 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
| 1094 prefs_->GetInteger(prefs::kDiskCacheSize); | 1085 prefs_->GetInteger(prefs::kDiskCacheSize); |
| 1095 } | 1086 } |
| 1096 | 1087 |
| 1097 base::Callback<ChromeURLDataManagerBackend*(void)> | 1088 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 1098 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { | 1089 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { |
| 1099 return io_data_.GetChromeURLDataManagerBackendGetter(); | 1090 return io_data_.GetChromeURLDataManagerBackendGetter(); |
| 1100 } | 1091 } |
| OLD | NEW |