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

Unified Diff: chrome/test/base/testing_profile.cc

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finish renaming profile -> context Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index ad46abcb4cc3512f48d02cd7a9057e5045ba9d8c..0497fbd5fbdcac93f58e04c5433e75b1bd3f2a32 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -101,6 +101,7 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "extensions/browser/event_router_factory.h"
+#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_system.h"
#endif
@@ -179,65 +180,68 @@ class TestExtensionURLRequestContextGetter
};
#if defined(ENABLE_NOTIFICATIONS)
-KeyedService* CreateTestDesktopNotificationService(
+scoped_ptr<KeyedService> CreateTestDesktopNotificationService(
content::BrowserContext* profile) {
- return new DesktopNotificationService(static_cast<Profile*>(profile));
+ return make_scoped_ptr(
+ new DesktopNotificationService(static_cast<Profile*>(profile)));
}
#endif
-KeyedService* BuildFaviconService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildFaviconService(content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- return new favicon::FaviconService(
+ return make_scoped_ptr(new favicon::FaviconService(
ChromeFaviconClientFactory::GetForProfile(profile),
- HistoryServiceFactory::GetForProfile(profile,
- ServiceAccessType::EXPLICIT_ACCESS));
+ HistoryServiceFactory::GetForProfile(
+ profile, ServiceAccessType::EXPLICIT_ACCESS)));
}
-KeyedService* BuildHistoryService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildHistoryService(content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- history::HistoryService* history_service = new history::HistoryService(
+ return make_scoped_ptr(new history::HistoryService(
ChromeHistoryClientFactory::GetForProfile(profile),
scoped_ptr<history::VisitDelegate>(
- new history::ContentVisitDelegate(profile)));
- return history_service;
+ new history::ContentVisitDelegate(profile))));
}
-KeyedService* BuildInMemoryURLIndex(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildInMemoryURLIndex(
+ content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- InMemoryURLIndex* in_memory_url_index = new InMemoryURLIndex(
+ scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex(
BookmarkModelFactory::GetForProfile(profile),
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::IMPLICIT_ACCESS),
profile->GetPath(),
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages)));
in_memory_url_index->Init();
- return in_memory_url_index;
+ return in_memory_url_index.Pass();
}
-KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
ChromeBookmarkClient* bookmark_client =
ChromeBookmarkClientFactory::GetForProfile(profile);
- BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client);
- bookmark_client->Init(bookmark_model);
+ scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(bookmark_client));
+ bookmark_client->Init(bookmark_model.get());
bookmark_model->Load(profile->GetPrefs(),
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
profile->GetPath(),
profile->GetIOTaskRunner(),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI));
- return bookmark_model;
+ return bookmark_model.Pass();
}
-KeyedService* BuildChromeBookmarkClient(
+scoped_ptr<KeyedService> BuildChromeBookmarkClient(
content::BrowserContext* context) {
- return new ChromeBookmarkClient(static_cast<Profile*>(context));
+ return make_scoped_ptr(
+ new ChromeBookmarkClient(static_cast<Profile*>(context)));
}
-KeyedService* BuildChromeHistoryClient(
+scoped_ptr<KeyedService> BuildChromeHistoryClient(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile));
+ return make_scoped_ptr(
+ new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile)));
}
void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
@@ -245,14 +249,14 @@ void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
NOTREACHED();
}
-KeyedService* BuildWebDataService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildWebDataService(content::BrowserContext* context) {
const base::FilePath& context_path = context->GetPath();
- return new WebDataServiceWrapper(
+ return make_scoped_ptr(new WebDataServiceWrapper(
context_path, g_browser_process->GetApplicationLocale(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
sync_start_util::GetFlareForSyncableService(context_path),
- &TestProfileErrorCallback);
+ &TestProfileErrorCallback));
}
} // namespace
@@ -452,11 +456,11 @@ void TestingProfile::Init() {
extensions::TestExtensionSystem* test_extension_system =
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(this));
- extensions::ExtensionPrefs* extension_prefs =
+ scoped_ptr<extensions::ExtensionPrefs> extension_prefs =
test_extension_system->CreateExtensionPrefs(
base::CommandLine::ForCurrentProcess(), extensions_path_);
extensions::ExtensionPrefsFactory::GetInstance()->SetInstanceForTesting(
- this, extension_prefs);
+ this, extension_prefs.Pass());
extensions::EventRouterFactory::GetInstance()->SetTestingFactory(this,
nullptr);
« no previous file with comments | « chrome/test/base/chrome_render_view_host_test_harness.cc ('k') | components/feedback/feedback_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698