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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 10857037: Make FaviconService a ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Override Shutdown() in FaviconService to NULL the profile_ pointer. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 17 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/content_settings/host_content_settings_map.h" 20 #include "chrome/browser/content_settings/host_content_settings_map.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_special_storage_policy.h" 22 #include "chrome/browser/extensions/extension_special_storage_policy.h"
23 #include "chrome/browser/extensions/extension_system.h" 23 #include "chrome/browser/extensions/extension_system.h"
24 #include "chrome/browser/extensions/extension_system_factory.h" 24 #include "chrome/browser/extensions/extension_system_factory.h"
25 #include "chrome/browser/extensions/test_extension_system.h" 25 #include "chrome/browser/extensions/test_extension_system.h"
26 #include "chrome/browser/favicon/favicon_service.h" 26 #include "chrome/browser/favicon/favicon_service.h"
27 #include "chrome/browser/favicon/favicon_service_factory.h"
27 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 28 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
28 #include "chrome/browser/history/history.h" 29 #include "chrome/browser/history/history.h"
29 #include "chrome/browser/history/history_backend.h" 30 #include "chrome/browser/history/history_backend.h"
30 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
31 #include "chrome/browser/history/shortcuts_backend.h" 32 #include "chrome/browser/history/shortcuts_backend.h"
32 #include "chrome/browser/history/shortcuts_backend_factory.h" 33 #include "chrome/browser/history/shortcuts_backend_factory.h"
33 #include "chrome/browser/history/top_sites.h" 34 #include "chrome/browser/history/top_sites.h"
34 #include "chrome/browser/net/proxy_service_factory.h" 35 #include "chrome/browser/net/proxy_service_factory.h"
35 #include "chrome/browser/notifications/desktop_notification_service.h" 36 #include "chrome/browser/notifications/desktop_notification_service.h"
36 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 37 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 TestingProfile::~TestingProfile() { 251 TestingProfile::~TestingProfile() {
251 MaybeSendDestroyedNotification(); 252 MaybeSendDestroyedNotification();
252 253
253 profile_dependency_manager_->DestroyProfileServices(this); 254 profile_dependency_manager_->DestroyProfileServices(this);
254 255
255 if (host_content_settings_map_) 256 if (host_content_settings_map_)
256 host_content_settings_map_->ShutdownOnUIThread(); 257 host_content_settings_map_->ShutdownOnUIThread();
257 258
258 DestroyTopSites(); 259 DestroyTopSites();
259 DestroyFaviconService();
260 260
261 if (pref_proxy_config_tracker_.get()) 261 if (pref_proxy_config_tracker_.get())
262 pref_proxy_config_tracker_->DetachFromPrefService(); 262 pref_proxy_config_tracker_->DetachFromPrefService();
263 } 263 }
264 264
265 void TestingProfile::CreateFaviconService() { 265 void TestingProfile::CreateFaviconService() {
266 favicon_service_.reset(new FaviconService(this)); 266 FaviconServiceFactory::GetInstance();
267 } 267 }
268 268
269 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService( 269 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService(
270 Profile* profile) { 270 Profile* profile) {
271 return new HistoryService(profile); 271 return new HistoryService(profile);
272 } 272 }
273 273
274 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 274 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
275 DestroyHistoryService(); 275 DestroyHistoryService();
276 if (delete_file) { 276 if (delete_file) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 top_sites_->Shutdown(); 324 top_sites_->Shutdown();
325 top_sites_ = NULL; 325 top_sites_ = NULL;
326 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need 326 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need
327 // to be run to properly shutdown. Run all pending tasks now. This is 327 // to be run to properly shutdown. Run all pending tasks now. This is
328 // normally handled by browser_process shutdown. 328 // normally handled by browser_process shutdown.
329 if (MessageLoop::current()) 329 if (MessageLoop::current())
330 MessageLoop::current()->RunAllPending(); 330 MessageLoop::current()->RunAllPending();
331 } 331 }
332 } 332 }
333 333
334 void TestingProfile::DestroyFaviconService() {
335 favicon_service_.reset();
336 }
337
338 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) { 334 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) {
339 BookmarkModel* bookmark_model = new BookmarkModel(profile); 335 BookmarkModel* bookmark_model = new BookmarkModel(profile);
340 bookmark_model->Load(); 336 bookmark_model->Load();
341 return bookmark_model; 337 return bookmark_model;
342 } 338 }
343 339
344 340
345 void TestingProfile::CreateBookmarkModel(bool delete_file) { 341 void TestingProfile::CreateBookmarkModel(bool delete_file) {
346 342
347 if (delete_file) { 343 if (delete_file) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 465 }
470 466
471 ExtensionSpecialStoragePolicy* 467 ExtensionSpecialStoragePolicy*
472 TestingProfile::GetExtensionSpecialStoragePolicy() { 468 TestingProfile::GetExtensionSpecialStoragePolicy() {
473 if (!extension_special_storage_policy_.get()) 469 if (!extension_special_storage_policy_.get())
474 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); 470 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL);
475 return extension_special_storage_policy_.get(); 471 return extension_special_storage_policy_.get();
476 } 472 }
477 473
478 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) { 474 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) {
479 return favicon_service_.get(); 475 return FaviconServiceFactory::GetForProfile(this);
480 } 476 }
481 477
482 HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) { 478 HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) {
483 return HistoryServiceFactory::GetForProfileIfExists(this, access); 479 return HistoryServiceFactory::GetForProfileIfExists(this, access);
484 } 480 }
485 481
486 HistoryService* TestingProfile::GetHistoryServiceWithoutCreating() { 482 HistoryService* TestingProfile::GetHistoryServiceWithoutCreating() {
487 return HistoryServiceFactory::GetForProfileWithoutCreating(this); 483 return HistoryServiceFactory::GetForProfileWithoutCreating(this);
488 } 484 }
489 485
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 721 }
726 722
727 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { 723 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) {
728 return true; 724 return true;
729 } 725 }
730 726
731 base::Callback<ChromeURLDataManagerBackend*(void)> 727 base::Callback<ChromeURLDataManagerBackend*(void)>
732 TestingProfile::GetChromeURLDataManagerBackendGetter() const { 728 TestingProfile::GetChromeURLDataManagerBackendGetter() const {
733 return base::Callback<ChromeURLDataManagerBackend*(void)>(); 729 return base::Callback<ChromeURLDataManagerBackend*(void)>();
734 } 730 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698