summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman <isherman@chromium.org>2015-06-09 16:32:10 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-09 23:32:41 +0000
commit30fa851a798084bd26792079ecf5fd1e317dde2d (patch)
tree3f996685fade20e5e0d8f5264d99366cab7ff886
parent24e573c5b6f3091767dc9c6dc1cf6376d8010cdc (diff)
downloadchromium_src-30fa851a798084bd26792079ecf5fd1e317dde2d.zip
chromium_src-30fa851a798084bd26792079ecf5fd1e317dde2d.tar.gz
chromium_src-30fa851a798084bd26792079ecf5fd1e317dde2d.tar.bz2
[Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions.
Along the way, clean up some tests' usage of SetTestingFactory(). BUG=NONE TEST=git cl try Review URL: https://codereview.chromium.org/1165913002 Cr-Commit-Position: refs/heads/master@{#333605}
-rw-r--r--chrome/browser/autocomplete/autocomplete_classifier_factory.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete_classifier_factory.h4
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc6
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc7
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover_unittest.cc4
-rw-r--r--chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader_unittest.cc14
-rw-r--r--chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc14
-rw-r--r--chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util_unittest.cc14
-rw-r--r--chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc14
-rw-r--r--chrome/browser/chromeos/file_system_provider/service_factory.cc5
-rw-r--r--chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc8
-rw-r--r--chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc7
-rw-r--r--chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc18
-rw-r--r--chrome/browser/download/download_shelf_unittest.cc8
-rw-r--r--chrome/browser/download/download_ui_controller_unittest.cc8
-rw-r--r--chrome/browser/extensions/active_script_controller_unittest.cc10
-rw-r--r--chrome/browser/extensions/api/audio_modem/audio_modem_api_unittest.cc11
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc10
-rw-r--r--chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc20
-rw-r--r--chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc6
-rw-r--r--chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc6
-rw-r--r--chrome/browser/extensions/api/instance_id/instance_id_apitest.cc10
-rw-r--r--chrome/browser/extensions/api/management/management_api_unittest.cc10
-rw-r--r--chrome/browser/extensions/api/mdns/mdns_api_unittest.cc28
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_apitest.cc5
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc8
-rw-r--r--chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc9
-rw-r--r--chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc6
-rw-r--r--chrome/browser/extensions/api/reading_list_private/reading_list_private_apitest.cc14
-rw-r--r--chrome/browser/extensions/api/sessions/sessions_apitest.cc16
-rw-r--r--chrome/browser/extensions/api/settings_private/settings_private_apitest.cc1
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc8
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc10
-rw-r--r--chrome/browser/extensions/api/socket/socket_api_unittest.cc4
-rw-r--r--chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc5
-rw-r--r--chrome/browser/extensions/api/storage/settings_sync_unittest.cc12
-rw-r--r--chrome/browser/extensions/extension_action_test_util.cc7
-rw-r--r--chrome/browser/extensions/extension_garbage_collector_factory.cc8
-rw-r--r--chrome/browser/extensions/extension_garbage_collector_factory.h3
-rw-r--r--chrome/browser/extensions/extension_gcm_app_handler_unittest.cc7
-rw-r--r--chrome/browser/extensions/menu_manager_factory.cc4
-rw-r--r--chrome/browser/extensions/menu_manager_factory.h2
-rw-r--r--chrome/browser/extensions/menu_manager_unittest.cc6
-rw-r--r--chrome/browser/extensions/test_extension_system.cc12
-rw-r--r--chrome/browser/extensions/test_extension_system.h8
-rw-r--r--chrome/browser/history/web_history_service_unittest.cc7
-rw-r--r--chrome/browser/invalidation/profile_invalidation_provider_factory.cc2
-rw-r--r--chrome/browser/media/router/media_router_mojo_impl_unittest.cc4
-rw-r--r--chrome/browser/password_manager/mock_password_store_service.cc4
-rw-r--r--chrome/browser/password_manager/mock_password_store_service.h3
-rw-r--r--chrome/browser/password_manager/test_password_store_service.cc4
-rw-r--r--chrome/browser/password_manager/test_password_store_service.h3
-rw-r--r--chrome/browser/policy/cloud/cloud_policy_browsertest.cc6
-rw-r--r--chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc6
-rw-r--r--chrome/browser/profile_resetter/profile_resetter_unittest.cc9
-rw-r--r--chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc17
-rw-r--r--chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector_unittest.cc16
-rw-r--r--chrome/browser/search/hotword_installer_browsertest.cc7
-rw-r--r--chrome/browser/search/hotword_service_unittest.cc6
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.cc9
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.h4
-rw-r--r--chrome/browser/services/gcm/fake_gcm_profile_service.cc9
-rw-r--r--chrome/browser/services/gcm/fake_gcm_profile_service.h3
-rw-r--r--chrome/browser/services/gcm/gcm_profile_service_unittest.cc9
-rw-r--r--chrome/browser/sessions/persistent_tab_restore_service_unittest.cc5
-rw-r--r--chrome/browser/sessions/session_service_factory.h5
-rw-r--r--chrome/browser/signin/account_reconcilor_unittest.cc11
-rw-r--r--chrome/browser/signin/easy_unlock_app_manager_unittest.cc13
-rw-r--r--chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc14
-rw-r--r--chrome/browser/signin/fake_account_tracker_service.cc4
-rw-r--r--chrome/browser/signin/fake_account_tracker_service.h3
-rw-r--r--chrome/browser/signin/fake_gaia_cookie_manager_service.cc7
-rw-r--r--chrome/browser/signin/fake_gaia_cookie_manager_service.h3
-rw-r--r--chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc17
-rw-r--r--chrome/browser/signin/fake_profile_oauth2_token_service_builder.h6
-rw-r--r--chrome/browser/signin/fake_signin_manager.cc13
-rw-r--r--chrome/browser/signin/fake_signin_manager.h3
-rw-r--r--chrome/browser/signin/signin_manager_unittest.cc10
-rw-r--r--chrome/browser/signin/test_signin_client_builder.cc13
-rw-r--r--chrome/browser/signin/test_signin_client_builder.h5
-rw-r--r--chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc6
-rw-r--r--chrome/browser/spellchecker/spellcheck_service_unittest.cc6
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc5
-rw-r--r--chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc26
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc12
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.cc5
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h3
-rw-r--r--chrome/browser/sync/profile_sync_service_startup_unittest.cc25
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc11
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc6
-rw-r--r--chrome/browser/sync/startup_controller_unittest.cc2
-rw-r--r--chrome/browser/sync/sync_error_notifier_ash_unittest.cc4
-rw-r--r--chrome/browser/sync/sync_global_error_unittest.cc6
-rw-r--r--chrome/browser/sync/test/integration/sync_test.cc18
-rw-r--r--chrome/browser/sync/test_profile_sync_service.cc10
-rw-r--r--chrome/browser/sync/test_profile_sync_service.h3
-rw-r--r--chrome/browser/themes/theme_syncable_service_unittest.cc5
-rw-r--r--chrome/browser/ui/app_list/app_list_prefs_factory.cc4
-rw-r--r--chrome/browser/ui/app_list/app_list_prefs_factory.h2
-rw-r--r--chrome/browser/ui/app_list/app_list_syncable_service_factory.cc8
-rw-r--r--chrome/browser/ui/app_list/app_list_syncable_service_factory.h3
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc9
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_unittest.cc7
-rw-r--r--chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc4
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc10
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc6
-rw-r--r--chrome/browser/ui/tabs/pinned_tab_service_unittest.cc6
-rw-r--r--chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc11
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc7
-rw-r--r--chrome/browser/ui/views/frame/test_with_browser_view.cc15
-rw-r--r--chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc5
-rw-r--r--chrome/test/base/chrome_render_view_host_test_harness.cc35
-rw-r--r--chrome/test/base/testing_profile.cc58
-rw-r--r--components/feedback/feedback_data_unittest.cc15
-rw-r--r--components/feedback/feedback_uploader_unittest.cc6
-rw-r--r--components/keyed_service/content/browser_context_keyed_service_factory.cc9
-rw-r--r--components/keyed_service/content/browser_context_keyed_service_factory.h4
-rw-r--r--components/keyed_service/core/keyed_service_factory.cc10
-rw-r--r--components/keyed_service/core/keyed_service_factory.h8
-rw-r--r--components/keyed_service/ios/browser_state_keyed_service_factory.cc8
-rw-r--r--components/keyed_service/ios/browser_state_keyed_service_factory.h6
-rw-r--r--extensions/browser/api/api_resource_manager.h8
-rw-r--r--extensions/browser/api/idle/idle_api_unittest.cc6
-rw-r--r--extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc3
-rw-r--r--extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc3
-rw-r--r--extensions/browser/api/storage/storage_api_unittest.cc7
-rw-r--r--extensions/browser/api/storage/storage_frontend.cc4
-rw-r--r--extensions/browser/api/storage/storage_frontend.h4
-rw-r--r--extensions/browser/api/storage/storage_frontend_unittest.cc4
-rw-r--r--extensions/browser/extension_prefs_factory.cc5
-rw-r--r--extensions/browser/extension_prefs_factory.h4
-rw-r--r--extensions/browser/lazy_background_task_queue_unittest.cc5
132 files changed, 581 insertions, 546 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_classifier_factory.cc b/chrome/browser/autocomplete/autocomplete_classifier_factory.cc
index 28c7601..d6458e9 100644
--- a/chrome/browser/autocomplete/autocomplete_classifier_factory.cc
+++ b/chrome/browser/autocomplete/autocomplete_classifier_factory.cc
@@ -32,15 +32,15 @@ AutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() {
}
// static
-KeyedService* AutocompleteClassifierFactory::BuildInstanceFor(
+scoped_ptr<KeyedService> AutocompleteClassifierFactory::BuildInstanceFor(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new AutocompleteClassifier(
+ return make_scoped_ptr(new AutocompleteClassifier(
make_scoped_ptr(new AutocompleteController(
profile, TemplateURLServiceFactory::GetForProfile(profile), NULL,
AutocompleteClassifier::kDefaultOmniboxProviders)),
scoped_ptr<AutocompleteSchemeClassifier>(
- new ChromeAutocompleteSchemeClassifier(profile)));
+ new ChromeAutocompleteSchemeClassifier(profile))));
}
AutocompleteClassifierFactory::AutocompleteClassifierFactory()
@@ -72,5 +72,5 @@ bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const {
KeyedService* AutocompleteClassifierFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
- return BuildInstanceFor(static_cast<Profile*>(profile));
+ return BuildInstanceFor(static_cast<Profile*>(profile)).release();
}
diff --git a/chrome/browser/autocomplete/autocomplete_classifier_factory.h b/chrome/browser/autocomplete/autocomplete_classifier_factory.h
index 84ef185..bfacf21 100644
--- a/chrome/browser/autocomplete/autocomplete_classifier_factory.h
+++ b/chrome/browser/autocomplete/autocomplete_classifier_factory.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_FACTORY_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -21,7 +22,8 @@ class AutocompleteClassifierFactory : public BrowserContextKeyedServiceFactory {
static AutocompleteClassifierFactory* GetInstance();
- static KeyedService* BuildInstanceFor(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> BuildInstanceFor(
+ content::BrowserContext* context);
private:
friend struct DefaultSingletonTraits<AutocompleteClassifierFactory>;
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index 0cb203b..eedeb29 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -169,15 +169,15 @@ class HistoryQuickProviderTest : public testing::Test {
std::set<std::string> matches_;
};
- static KeyedService* CreateTemplateURLService(
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL,
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
- NULL, NULL, base::Closure());
+ NULL, NULL, base::Closure()));
}
void SetUp() override;
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index d111f25..a5bd316 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
@@ -170,15 +171,15 @@ class HistoryURLProviderTest : public testing::Test,
void OnProviderUpdate(bool updated_matches) override;
protected:
- static KeyedService* CreateTemplateURLService(
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL,
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
- NULL, NULL, base::Closure());
+ NULL, NULL, base::Closure()));
}
// testing::Test
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 0531d87..e6d7c9a 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -744,7 +744,7 @@ struct TestingDomainReliabilityServiceFactoryUserData
const void* TestingDomainReliabilityServiceFactoryUserData::kKey =
&TestingDomainReliabilityServiceFactoryUserData::kKey;
-KeyedService* TestingDomainReliabilityServiceFactoryFunction(
+scoped_ptr<KeyedService> TestingDomainReliabilityServiceFactoryFunction(
content::BrowserContext* context) {
const void* kKey = TestingDomainReliabilityServiceFactoryUserData::kKey;
@@ -756,7 +756,7 @@ KeyedService* TestingDomainReliabilityServiceFactoryFunction(
EXPECT_FALSE(data->attached);
data->attached = true;
- return data->service;
+ return make_scoped_ptr(data->service);
}
class ClearDomainReliabilityTester {
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader_unittest.cc b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader_unittest.cc
index 2b25c32..2213239 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_reader_unittest.cc
@@ -71,13 +71,6 @@ storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name,
base::FilePath::FromUTF8Unsafe(mount_point_name).Append(file_path));
}
-// Creates a Service instance. Used to be able to destroy the service in
-// TearDown().
-KeyedService* CreateService(content::BrowserContext* context) {
- return new Service(Profile::FromBrowserContext(context),
- extensions::ExtensionRegistry::Get(context));
-}
-
} // namespace
class FileSystemProviderFileStreamReader : public testing::Test {
@@ -92,7 +85,6 @@ class FileSystemProviderFileStreamReader : public testing::Test {
ASSERT_TRUE(profile_manager_->SetUp());
profile_ = profile_manager_->CreateTestingProfile("testing-profile");
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService);
Service* service = Service::Get(profile_); // Owned by its factory.
service->SetFileSystemFactoryForTesting(
base::Bind(&FakeProvidedFileSystem::Create));
@@ -120,12 +112,6 @@ class FileSystemProviderFileStreamReader : public testing::Test {
ASSERT_TRUE(wrong_file_url_.is_valid());
}
- void TearDown() override {
- // Setting the testing factory to NULL will destroy the created service
- // associated with the testing profile.
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL);
- }
-
content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir data_dir_;
scoped_ptr<TestingProfileManager> profile_manager_;
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc
index 187e8c5..10df3e7 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc
@@ -54,13 +54,6 @@ storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name,
base::FilePath::FromUTF8Unsafe(mount_point_name).Append(file_path));
}
-// Creates a Service instance. Used to be able to destroy the service in
-// TearDown().
-KeyedService* CreateService(content::BrowserContext* context) {
- return new Service(Profile::FromBrowserContext(context),
- extensions::ExtensionRegistry::Get(context));
-}
-
} // namespace
class FileSystemProviderFileStreamWriter : public testing::Test {
@@ -75,7 +68,6 @@ class FileSystemProviderFileStreamWriter : public testing::Test {
ASSERT_TRUE(profile_manager_->SetUp());
profile_ = profile_manager_->CreateTestingProfile("testing-profile");
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService);
Service* service = Service::Get(profile_); // Owned by its factory.
service->SetFileSystemFactoryForTesting(
base::Bind(&FakeProvidedFileSystem::Create));
@@ -99,12 +91,6 @@ class FileSystemProviderFileStreamWriter : public testing::Test {
ASSERT_TRUE(wrong_file_url_.is_valid());
}
- void TearDown() override {
- // Setting the testing factory to NULL will destroy the created service
- // associated with the testing profile.
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL);
- }
-
content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir data_dir_;
scoped_ptr<TestingProfileManager> profile_manager_;
diff --git a/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util_unittest.cc b/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util_unittest.cc
index f3789cf..ea4180a 100644
--- a/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util_unittest.cc
@@ -100,13 +100,6 @@ storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name,
base::FilePath::FromUTF8Unsafe(mount_point_name).Append(file_path));
}
-// Creates a Service instance. Used to be able to destroy the service in
-// TearDown().
-KeyedService* CreateService(content::BrowserContext* context) {
- return new Service(Profile::FromBrowserContext(context),
- extensions::ExtensionRegistry::Get(context));
-}
-
} // namespace
// Tests in this file are very lightweight and just test integration between
@@ -130,7 +123,6 @@ class FileSystemProviderProviderAsyncFileUtilTest : public testing::Test {
file_system_context_ =
content::CreateFileSystemContextForTesting(NULL, data_dir_.path());
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService);
Service* service = Service::Get(profile_); // Owned by its factory.
service->SetFileSystemFactoryForTesting(
base::Bind(&FakeProvidedFileSystem::Create));
@@ -155,12 +147,6 @@ class FileSystemProviderProviderAsyncFileUtilTest : public testing::Test {
ASSERT_TRUE(root_url_.is_valid());
}
- void TearDown() override {
- // Setting the testing factory to NULL will destroy the created service
- // associated with the testing profile.
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL);
- }
-
scoped_ptr<storage::FileSystemOperationContext> CreateOperationContext() {
return make_scoped_ptr(
new storage::FileSystemOperationContext(file_system_context_.get()));
diff --git a/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc b/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc
index 7c5ee2d..570f0b9 100644
--- a/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc
@@ -56,13 +56,6 @@ storage::FileSystemURL CreateFileSystemURL(
base::FilePath(mount_path.BaseName().Append(relative_path)));
}
-// Creates a Service instance. Used to be able to destroy the service in
-// TearDown().
-KeyedService* CreateService(content::BrowserContext* context) {
- return new Service(Profile::FromBrowserContext(context),
- extensions::ExtensionRegistry::Get(context));
-}
-
} // namespace
class FileSystemProviderMountPathUtilTest : public testing::Test {
@@ -78,18 +71,11 @@ class FileSystemProviderMountPathUtilTest : public testing::Test {
user_manager_ = new FakeChromeUserManager();
user_manager_enabler_.reset(new ScopedUserManagerEnabler(user_manager_));
user_manager_->AddUser(profile_->GetProfileUserName());
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService);
file_system_provider_service_ = Service::Get(profile_);
file_system_provider_service_->SetFileSystemFactoryForTesting(
base::Bind(&FakeProvidedFileSystem::Create));
}
- void TearDown() override {
- // Setting the testing factory to NULL will destroy the created service
- // associated with the testing profile.
- ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL);
- }
-
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<TestingProfileManager> profile_manager_;
TestingProfile* profile_; // Owned by TestingProfileManager.
diff --git a/chrome/browser/chromeos/file_system_provider/service_factory.cc b/chrome/browser/chromeos/file_system_provider/service_factory.cc
index 7322376..b54a11e 100644
--- a/chrome/browser/chromeos/file_system_provider/service_factory.cc
+++ b/chrome/browser/chromeos/file_system_provider/service_factory.cc
@@ -42,9 +42,8 @@ ServiceFactory::~ServiceFactory() {}
KeyedService* ServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
- return new Service(
- Profile::FromBrowserContext(profile),
- extensions::ExtensionRegistry::Get(Profile::FromBrowserContext(profile)));
+ return new Service(Profile::FromBrowserContext(profile),
+ extensions::ExtensionRegistry::Get(profile));
}
bool ServiceFactory::ServiceIsCreatedWithBrowserContext() const { return true; }
diff --git a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
index 3c180c2..f5701af 100644
--- a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
+++ b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc
@@ -100,11 +100,11 @@ const BehaviorTestCase kBehaviorTestCases[] = {
// we've ensured the profile has been shut down.
policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL;
-KeyedService* TestPolicyCertServiceFactory(content::BrowserContext* context) {
+scoped_ptr<KeyedService> TestPolicyCertServiceFactory(
+ content::BrowserContext* context) {
return policy::PolicyCertService::CreateForTesting(
- kUsers[0],
- g_policy_cert_verifier_for_factory,
- user_manager::UserManager::Get()).release();
+ kUsers[0], g_policy_cert_verifier_for_factory,
+ user_manager::UserManager::Get());
}
} // namespace
diff --git a/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc b/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
index dedc6b4..5918728e 100644
--- a/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
+++ b/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
@@ -41,14 +42,14 @@ const char kAffiliatedUserID1[] = "test_1@example.com";
const char kAffiliatedUserID2[] = "test_2@example.com";
const char kUnaffiliatedUserID[] = "test@other_domain.test";
-KeyedService* BuildProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildProfileInvalidationProvider(
content::BrowserContext* context) {
scoped_ptr<invalidation::FakeInvalidationService> invalidation_service(
new invalidation::FakeInvalidationService);
invalidation_service->SetInvalidatorState(
syncer::TRANSIENT_INVALIDATION_ERROR);
- return new invalidation::ProfileInvalidationProvider(
- invalidation_service.Pass());
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
+ invalidation_service.Pass()));
}
} // namespace
diff --git a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
index 7bdf935..942eddb 100644
--- a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
+++ b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/guid.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -93,22 +94,19 @@ class DomDistillerViewerSourceBrowserTest : public InProcessBrowserTest {
command_line->AppendSwitch(switches::kEnableDomDistiller);
}
- static KeyedService* Build(content::BrowserContext* context) {
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context) {
FakeDB<ArticleEntry>* fake_db = new FakeDB<ArticleEntry>(database_model_);
distiller_factory_ = new MockDistillerFactory();
MockDistillerPageFactory* distiller_page_factory_ =
new MockDistillerPageFactory();
- DomDistillerContextKeyedService* service =
+ scoped_ptr<DomDistillerContextKeyedService> service(
new DomDistillerContextKeyedService(
- scoped_ptr<DomDistillerStoreInterface>(
- CreateStoreWithFakeDB(fake_db,
- FakeDB<ArticleEntry>::EntryMap())),
+ scoped_ptr<DomDistillerStoreInterface>(CreateStoreWithFakeDB(
+ fake_db, FakeDB<ArticleEntry>::EntryMap())),
scoped_ptr<DistillerFactory>(distiller_factory_),
scoped_ptr<DistillerPageFactory>(distiller_page_factory_),
- scoped_ptr<DistilledPagePrefs>(
- new DistilledPagePrefs(
- Profile::FromBrowserContext(
- context)->GetPrefs())));
+ scoped_ptr<DistilledPagePrefs>(new DistilledPagePrefs(
+ Profile::FromBrowserContext(context)->GetPrefs()))));
fake_db->InitCallback(true);
fake_db->LoadCallback(true);
if (expect_distillation_) {
@@ -123,7 +121,7 @@ class DomDistillerViewerSourceBrowserTest : public InProcessBrowserTest {
EXPECT_CALL(*distiller_page_factory_, CreateDistillerPageImpl())
.WillOnce(testing::Return(distiller_page));
}
- return service;
+ return service.Pass();
}
void ViewSingleDistilledPage(const GURL& url,
diff --git a/chrome/browser/download/download_shelf_unittest.cc b/chrome/browser/download/download_shelf_unittest.cc
index 6311536..257cf2c 100644
--- a/chrome/browser/download/download_shelf_unittest.cc
+++ b/chrome/browser/download/download_shelf_unittest.cc
@@ -28,10 +28,6 @@ using content::DownloadItem;
namespace {
-KeyedService* CreateDownloadService(content::BrowserContext* context) {
- return new DownloadService(Profile::FromBrowserContext(context));
-}
-
class DownloadShelfTest : public testing::Test {
public:
DownloadShelfTest();
@@ -49,13 +45,9 @@ class DownloadShelfTest : public testing::Test {
Profile* profile() { return profile_.get(); }
void SetUp() override {
- DownloadServiceFactory::GetInstance()->SetTestingFactory(
- profile(), &CreateDownloadService);
}
void TearDown() override {
- DownloadServiceFactory::GetInstance()->SetTestingFactory(
- profile(), NULL);
}
private:
diff --git a/chrome/browser/download/download_ui_controller_unittest.cc b/chrome/browser/download/download_ui_controller_unittest.cc
index d29878d..015f93a 100644
--- a/chrome/browser/download/download_ui_controller_unittest.cc
+++ b/chrome/browser/download/download_ui_controller_unittest.cc
@@ -135,7 +135,7 @@ class DownloadUIControllerTest : public ChromeRenderViewHostTestHarness {
};
// Constructs and returns a TestDownloadService.
- static KeyedService* TestingDownloadServiceFactory(
+ static scoped_ptr<KeyedService> TestingDownloadServiceFactory(
content::BrowserContext* browser_context);
scoped_ptr<MockDownloadManager> manager_;
@@ -148,9 +148,11 @@ class DownloadUIControllerTest : public ChromeRenderViewHostTestHarness {
};
// static
-KeyedService* DownloadUIControllerTest::TestingDownloadServiceFactory(
+scoped_ptr<KeyedService>
+DownloadUIControllerTest::TestingDownloadServiceFactory(
content::BrowserContext* browser_context) {
- return new TestDownloadService(Profile::FromBrowserContext(browser_context));
+ return make_scoped_ptr(
+ new TestDownloadService(Profile::FromBrowserContext(browser_context)));
}
DownloadUIControllerTest::DownloadUIControllerTest()
diff --git a/chrome/browser/extensions/active_script_controller_unittest.cc b/chrome/browser/extensions/active_script_controller_unittest.cc
index 3f191ad..497077d 100644
--- a/chrome/browser/extensions/active_script_controller_unittest.cc
+++ b/chrome/browser/extensions/active_script_controller_unittest.cc
@@ -32,11 +32,6 @@ namespace {
const char kAllHostsPermission[] = "*://*/*";
-// We skip syncing for testing purposes.
-KeyedService* BuildSyncService(content::BrowserContext* context) {
- return nullptr;
-}
-
} // namespace
// Unittests for the ActiveScriptController mostly test the internal logic
@@ -169,8 +164,9 @@ void ActiveScriptControllerUnitTest::IncrementExecutionCount(
void ActiveScriptControllerUnitTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
- ExtensionSyncServiceFactory::GetInstance()->SetTestingFactory(
- profile(), &BuildSyncService);
+ // Skip syncing for testing purposes.
+ ExtensionSyncServiceFactory::GetInstance()->SetTestingFactory(profile(),
+ nullptr);
TabHelper::CreateForWebContents(web_contents());
TabHelper* tab_helper = TabHelper::FromWebContents(web_contents());
diff --git a/chrome/browser/extensions/api/audio_modem/audio_modem_api_unittest.cc b/chrome/browser/extensions/api/audio_modem/audio_modem_api_unittest.cc
index 3728e67..f2cd614 100644
--- a/chrome/browser/extensions/api/audio_modem/audio_modem_api_unittest.cc
+++ b/chrome/browser/extensions/api/audio_modem/audio_modem_api_unittest.cc
@@ -47,13 +47,13 @@ namespace {
std::map<BrowserContext*, StubModem*> g_modems;
// Create a test AudioModemAPI and store the modem it uses.
-KeyedService* ApiFactoryFunction(BrowserContext* context) {
+scoped_ptr<KeyedService> ApiFactoryFunction(BrowserContext* context) {
StubModem* modem = new StubModem;
g_modems[context] = modem;
- return new AudioModemAPI(
+ return make_scoped_ptr(new AudioModemAPI(
context,
make_scoped_ptr<audio_modem::WhispernetClient>(new StubWhispernetClient),
- make_scoped_ptr<audio_modem::Modem>(modem));
+ make_scoped_ptr<audio_modem::Modem>(modem)));
}
DictionaryValue* CreateParams(const std::string& audio_band) {
@@ -131,8 +131,9 @@ class StubEventRouter : public EventRouter {
};
// StubEventRouter factory function
-KeyedService* StubEventRouterFactoryFunction(content::BrowserContext* context) {
- return new StubEventRouter(context);
+scoped_ptr<KeyedService> StubEventRouterFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new StubEventRouter(context));
}
} // namespace
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
index 97ac5c2..2b13587 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/files/file_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/api/developer_private/developer_private_api.h"
#include "chrome/browser/extensions/error_console/error_console.h"
@@ -38,12 +39,13 @@ namespace extensions {
namespace {
-KeyedService* BuildAPI(content::BrowserContext* context) {
- return new DeveloperPrivateAPI(context);
+scoped_ptr<KeyedService> BuildAPI(content::BrowserContext* context) {
+ return make_scoped_ptr(new DeveloperPrivateAPI(context));
}
-KeyedService* BuildEventRouter(content::BrowserContext* profile) {
- return new EventRouter(profile, ExtensionPrefs::Get(profile));
+scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new EventRouter(profile, ExtensionPrefs::Get(profile)));
}
} // namespace
diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
index 6a3de13..ab24ca2 100644
--- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
+++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
@@ -5,6 +5,7 @@
#include <string>
#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/thread_task_runner_handle.h"
#include "base/values.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/test_extension_prefs.h"
#include "chrome/browser/extensions/test_extension_system.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/easy_unlock_app_manager.h"
#include "chrome/browser/signin/easy_unlock_service_factory.h"
#include "chrome/browser/signin/easy_unlock_service_regular.h"
@@ -419,13 +421,14 @@ struct AutoPairingResult {
};
// Test factory to register EasyUnlockService.
-KeyedService* BuildTestEasyUnlockService(content::BrowserContext* context) {
- EasyUnlockService* service =
- new EasyUnlockServiceRegular(static_cast<Profile*>(context));
+scoped_ptr<KeyedService> BuildTestEasyUnlockService(
+ content::BrowserContext* context) {
+ scoped_ptr<EasyUnlockServiceRegular> service(
+ new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)));
service->Initialize(
EasyUnlockAppManager::Create(extensions::ExtensionSystem::Get(context),
- -1 /* manifest id*/, base::FilePath()));
- return service;
+ -1 /* manifest id */, base::FilePath()));
+ return service.Pass();
}
// A fake EventRouter that logs event it dispatches for testing.
@@ -456,11 +459,12 @@ class FakeEventRouter : public extensions::EventRouter {
};
// FakeEventRouter factory function
-KeyedService* FakeEventRouterFactoryFunction(content::BrowserContext* profile) {
+scoped_ptr<KeyedService> FakeEventRouterFactoryFunction(
+ content::BrowserContext* profile) {
scoped_ptr<extensions::TestExtensionPrefs> extension_prefs(
new extensions::TestExtensionPrefs(base::ThreadTaskRunnerHandle::Get()));
- return new FakeEventRouter(static_cast<Profile*>(profile),
- extension_prefs.Pass());
+ return make_scoped_ptr(new FakeEventRouter(static_cast<Profile*>(profile),
+ extension_prefs.Pass()));
}
TEST_F(EasyUnlockPrivateApiTest, AutoPairing) {
diff --git a/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc b/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
index 1dbf356..a6c63bf 100644
--- a/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
+++ b/chrome/browser/extensions/api/hotword_private/hotword_private_apitest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -98,8 +99,9 @@ class MockHotwordService : public HotwordService {
service_available_ = available;
}
- static KeyedService* Build(content::BrowserContext* profile) {
- return new MockHotwordService(static_cast<Profile*>(profile));
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new MockHotwordService(static_cast<Profile*>(profile)));
}
LaunchMode GetHotwordAudioVerificationLaunchMode() override {
diff --git a/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc b/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc
index bec81903..da5fa74 100644
--- a/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc
+++ b/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
#include "chrome/browser/extensions/api/image_writer_private/operation_manager.h"
#include "chrome/browser/extensions/api/image_writer_private/test_utils.h"
@@ -35,8 +36,9 @@ class FakeEventRouter : public extensions::EventRouter {
};
// FakeEventRouter factory function
-KeyedService* FakeEventRouterFactoryFunction(content::BrowserContext* context) {
- return new FakeEventRouter(static_cast<Profile*>(context));
+scoped_ptr<KeyedService> FakeEventRouterFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new FakeEventRouter(static_cast<Profile*>(context)));
}
namespace {
diff --git a/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc b/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc
index 4a1b08a..bc32d81 100644
--- a/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc
+++ b/chrome/browser/extensions/api/instance_id/instance_id_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/extensions/api/instance_id/instance_id_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -22,11 +23,12 @@ namespace extensions {
namespace {
-KeyedService* BuildFakeGCMProfileService(content::BrowserContext* context) {
- gcm::FakeGCMProfileService* service =
- new gcm::FakeGCMProfileService(Profile::FromBrowserContext(context));
+scoped_ptr<KeyedService> BuildFakeGCMProfileService(
+ content::BrowserContext* context) {
+ scoped_ptr<gcm::FakeGCMProfileService> service(
+ new gcm::FakeGCMProfileService(Profile::FromBrowserContext(context)));
service->SetDriverForTesting(new instance_id::FakeGCMDriverForInstanceID());
- return service;
+ return service.Pass();
}
} // namespace
diff --git a/chrome/browser/extensions/api/management/management_api_unittest.cc b/chrome/browser/extensions/api/management/management_api_unittest.cc
index a4845ba..e783a7f 100644
--- a/chrome/browser/extensions/api/management/management_api_unittest.cc
+++ b/chrome/browser/extensions/api/management/management_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
@@ -26,12 +27,13 @@ namespace extensions {
namespace {
-KeyedService* BuildManagementApi(content::BrowserContext* context) {
- return new ManagementAPI(context);
+scoped_ptr<KeyedService> BuildManagementApi(content::BrowserContext* context) {
+ return make_scoped_ptr(new ManagementAPI(context));
}
-KeyedService* BuildEventRouter(content::BrowserContext* profile) {
- return new extensions::EventRouter(profile, ExtensionPrefs::Get(profile));
+scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new extensions::EventRouter(profile, ExtensionPrefs::Get(profile)));
}
} // namespace
diff --git a/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc b/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
index 84e1f08..7c8a190 100644
--- a/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
+++ b/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/mdns/mdns_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
@@ -10,7 +11,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/test/mock_render_process_host.h"
#include "extensions/browser/event_router_factory.h"
-#include "extensions/browser/extension_prefs_factory.h"
+#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -20,14 +21,14 @@ namespace extensions {
namespace {
-KeyedService* MDnsAPITestingFactoryFunction(content::BrowserContext* context) {
- return new MDnsAPI(context);
+scoped_ptr<KeyedService> MDnsAPITestingFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new MDnsAPI(context));
}
-KeyedService* BuildEventRouter(content::BrowserContext* profile) {
- return new extensions::EventRouter(
- profile,
- ExtensionPrefsFactory::GetInstance()->GetForBrowserContext((profile)));
+scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new extensions::EventRouter(context, ExtensionPrefs::Get(context)));
}
// For ExtensionService interface when it requires a path that is not used.
@@ -93,11 +94,6 @@ class MDnsAPITest : public extensions::ExtensionServiceTestBase {
.Times(1);
render_process_host_.reset();
extensions::ExtensionServiceTestBase::TearDown();
- MDnsAPI::GetFactoryInstance()->SetTestingFactory(
- browser_context(),
- nullptr);
-
- registry_ = nullptr;
}
virtual MockDnsSdRegistry* dns_sd_registry() {
@@ -226,10 +222,10 @@ class MockEventRouter : public EventRouter {
MOCK_METHOD1(BroadcastEventPtr, void(Event* event));
};
-KeyedService* MockEventRouterFactoryFunction(content::BrowserContext* profile) {
- return new MockEventRouter(
- profile,
- ExtensionPrefsFactory::GetInstance()->GetForBrowserContext((profile)));
+scoped_ptr<KeyedService> MockEventRouterFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new MockEventRouter(context, ExtensionPrefs::Get(context)));
}
class MDnsAPIMaxServicesTest : public MDnsAPITest {
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
index 6a3a503..7bc876a 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/onc/onc_constants.h"
@@ -276,10 +277,10 @@ class NetworkingPrivateApiTest : public ExtensionApiTest {
}
}
- static KeyedService* GetNetworkingPrivateDelegate(
+ static scoped_ptr<KeyedService> GetNetworkingPrivateDelegate(
content::BrowserContext* profile) {
CHECK(s_test_delegate_);
- return s_test_delegate_;
+ return make_scoped_ptr(s_test_delegate_);
}
void SetUpCommandLine(base::CommandLine* command_line) override {
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
index 89a201f..17f9050 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
@@ -6,6 +6,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
@@ -229,10 +230,11 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
state, true /* add_to_visible */);
}
- static KeyedService* CreateNetworkingPrivateServiceClient(
- content::BrowserContext* profile) {
+ static scoped_ptr<KeyedService> CreateNetworkingPrivateServiceClient(
+ content::BrowserContext* context) {
scoped_ptr<CryptoVerifyStub> crypto_verify(new CryptoVerifyStub);
- return new NetworkingPrivateChromeOS(profile, crypto_verify.Pass());
+ return make_scoped_ptr(
+ new NetworkingPrivateChromeOS(context, crypto_verify.Pass()));
}
void SetUpOnMainThread() override {
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
index 6de03c9..eafc1e5 100644
--- a/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
+++ b/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
@@ -6,6 +6,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/networking_private/networking_private_credentials_getter.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -83,12 +84,12 @@ class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest {
"epcifkihnkjgphfkloaaleeakhpmgdmn");
}
- static KeyedService* CreateNetworkingPrivateServiceClient(
- content::BrowserContext* profile) {
+ static scoped_ptr<KeyedService> CreateNetworkingPrivateServiceClient(
+ content::BrowserContext* context) {
scoped_ptr<wifi::FakeWiFiService> wifi_service(new wifi::FakeWiFiService());
scoped_ptr<CryptoVerifyStub> crypto_verify(new CryptoVerifyStub);
- return new NetworkingPrivateServiceClient(wifi_service.Pass(),
- crypto_verify.Pass());
+ return scoped_ptr<KeyedService>(new NetworkingPrivateServiceClient(
+ wifi_service.Pass(), crypto_verify.Pass()));
}
void SetUpOnMainThread() override {
diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc
index 89bc5e8..a7582de 100644
--- a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc
+++ b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/values.h"
@@ -54,9 +55,10 @@ class FakeProfileSyncService : public ProfileSyncService {
~FakeProfileSyncService() override {}
- static KeyedService* BuildFakeProfileSyncService(
+ static scoped_ptr<KeyedService> BuildFakeProfileSyncService(
content::BrowserContext* context) {
- return new FakeProfileSyncService(static_cast<Profile*>(context));
+ return make_scoped_ptr(
+ new FakeProfileSyncService(static_cast<Profile*>(context)));
}
void set_sync_initialized(bool sync_initialized) {
diff --git a/chrome/browser/extensions/api/reading_list_private/reading_list_private_apitest.cc b/chrome/browser/extensions/api/reading_list_private/reading_list_private_apitest.cc
index 375ff99..1a5bea5 100644
--- a/chrome/browser/extensions/api/reading_list_private/reading_list_private_apitest.cc
+++ b/chrome/browser/extensions/api/reading_list_private/reading_list_private_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
#include "chrome/browser/extensions/api/reading_list_private/reading_list_private_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -31,7 +32,7 @@ using leveldb_proto::test::FakeDB;
class ReadingListPrivateApiTest : public ExtensionApiTest {
public:
- static KeyedService* Build(content::BrowserContext* context) {
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context) {
FakeDB<ArticleEntry>* fake_db =
new FakeDB<ArticleEntry>(new FakeDB<ArticleEntry>::EntryMap);
FakeDistiller* distiller = new FakeDistiller(true);
@@ -46,22 +47,21 @@ class ReadingListPrivateApiTest : public ExtensionApiTest {
dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(
pref_service->registry());
- DomDistillerContextKeyedService* service =
+ scoped_ptr<DomDistillerContextKeyedService> service(
new DomDistillerContextKeyedService(
- scoped_ptr<DomDistillerStoreInterface>(
- CreateStoreWithFakeDB(fake_db,
- FakeDB<ArticleEntry>::EntryMap())),
+ scoped_ptr<DomDistillerStoreInterface>(CreateStoreWithFakeDB(
+ fake_db, FakeDB<ArticleEntry>::EntryMap())),
scoped_ptr<DistillerFactory>(distiller_factory),
scoped_ptr<DistillerPageFactory>(distiller_page_factory),
scoped_ptr<dom_distiller::DistilledPagePrefs>(
- new dom_distiller::DistilledPagePrefs(pref_service)));
+ new dom_distiller::DistilledPagePrefs(pref_service))));
fake_db->InitCallback(true);
fake_db->LoadCallback(true);
EXPECT_CALL(*distiller_factory, CreateDistillerImpl())
.WillOnce(testing::Return(distiller));
EXPECT_CALL(*distiller_page_factory, CreateDistillerPageImpl())
.WillOnce(testing::Return(distiller_page));
- return service;
+ return service.Pass();
}
};
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index 36c02d5..f85f479 100644
--- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -90,7 +90,7 @@ class ExtensionSessionsTest : public InProcessBrowserTest {
void SetUpOnMainThread() override;
protected:
- static KeyedService* BuildProfileSyncService(
+ static scoped_ptr<KeyedService> BuildProfileSyncService(
content::BrowserContext* profile);
void CreateTestProfileSyncService();
@@ -121,11 +121,10 @@ void ExtensionSessionsTest::SetUpOnMainThread() {
CreateTestExtension();
}
-KeyedService* ExtensionSessionsTest::BuildProfileSyncService(
- content::BrowserContext* profile) {
-
- ProfileSyncComponentsFactoryMock* factory =
- new ProfileSyncComponentsFactoryMock();
+scoped_ptr<KeyedService> ExtensionSessionsTest::BuildProfileSyncService(
+ content::BrowserContext* context) {
+ scoped_ptr<ProfileSyncComponentsFactoryMock> factory(
+ new ProfileSyncComponentsFactoryMock());
factory->SetLocalDeviceInfoProvider(
scoped_ptr<sync_driver::LocalDeviceInfoProvider>(
@@ -137,9 +136,8 @@ KeyedService* ExtensionSessionsTest::BuildProfileSyncService(
sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
"device_id")));
- return new ProfileSyncServiceMock(
- scoped_ptr<ProfileSyncComponentsFactory>(factory),
- static_cast<Profile*>(profile));
+ return make_scoped_ptr(new ProfileSyncServiceMock(
+ factory.Pass(), static_cast<Profile*>(context)));
}
void ExtensionSessionsTest::CreateTestProfileSyncService() {
diff --git a/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc b/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
index d2e48cf..4941a23 100644
--- a/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
+++ b/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/settings_private/settings_private_delegate.h"
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
index 1cb5733..34ad282 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/guid.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/thread_task_runner_handle.h"
#include "base/values.h"
@@ -144,9 +145,10 @@ class ProfileSyncServiceMockForExtensionTests:
MOCK_CONST_METHOD0(GetDeviceInfoTracker, DeviceInfoTracker*());
};
-KeyedService* CreateProfileSyncServiceMock(content::BrowserContext* profile) {
- return new ProfileSyncServiceMockForExtensionTests(
- Profile::FromBrowserContext(profile));
+scoped_ptr<KeyedService> CreateProfileSyncServiceMock(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new ProfileSyncServiceMockForExtensionTests(
+ Profile::FromBrowserContext(context)));
}
class ExtensionSignedInDevicesTest : public ExtensionApiUnittest {
diff --git a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
index 322ef96..b044515 100644
--- a/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager_unittest.cc
@@ -19,20 +19,14 @@
namespace extensions {
-namespace {
-KeyedService* CreateProfileSyncServiceMock(content::BrowserContext* profile) {
- return NULL;
-}
-} // namespace
-
// Adds a listener and removes it.
TEST(SignedInDevicesManager, UpdateListener) {
content::TestBrowserThreadBundle thread_bundle;
scoped_ptr<TestingProfile> profile(new TestingProfile());
SigninManagerFactory::GetForProfile(profile.get())->
SetAuthenticatedAccountInfo("gaia_id", "foo");
- ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
- profile.get(), CreateProfileSyncServiceMock);
+ ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile.get(),
+ nullptr);
SignedInDevicesManager manager(profile.get());
EventListenerInfo info(api::signed_in_devices::OnDeviceInfoChange::kEventName,
diff --git a/chrome/browser/extensions/api/socket/socket_api_unittest.cc b/chrome/browser/extensions/api/socket/socket_api_unittest.cc
index 7634f1e..00447a8 100644
--- a/chrome/browser/extensions/api/socket/socket_api_unittest.cc
+++ b/chrome/browser/extensions/api/socket/socket_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/extensions/extension_api_unittest.h"
@@ -16,7 +17,8 @@
namespace extensions {
-KeyedService* ApiResourceManagerTestFactory(content::BrowserContext* context) {
+scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
+ content::BrowserContext* context) {
content::BrowserThread::ID id;
CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
return ApiResourceManager<Socket>::CreateApiResourceManagerForTest(context,
diff --git a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
index 1a31f09..a18abba 100644
--- a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
+++ b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/extensions/extension_api_unittest.h"
@@ -18,7 +19,7 @@
namespace extensions {
namespace core_api {
-static KeyedService* ApiResourceManagerTestFactory(
+static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
content::BrowserContext* context) {
content::BrowserThread::ID id;
CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
@@ -26,7 +27,7 @@ static KeyedService* ApiResourceManagerTestFactory(
ResumableTCPSocket>::CreateApiResourceManagerForTest(context, id);
}
-static KeyedService* ApiResourceManagerTestServerFactory(
+static scoped_ptr<KeyedService> ApiResourceManagerTestServerFactory(
content::BrowserContext* context) {
content::BrowserThread::ID id;
CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
diff --git a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
index 100303e..c0f7656 100644
--- a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
+++ b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
@@ -195,13 +195,13 @@ class TestingValueStoreFactory : public SettingsStorageFactory {
std::map<std::string, TestingValueStore*> created_;
};
-KeyedService* MockExtensionSystemFactoryFunction(
+scoped_ptr<KeyedService> MockExtensionSystemFactoryFunction(
content::BrowserContext* context) {
- return new MockExtensionSystem(context);
+ return make_scoped_ptr(new MockExtensionSystem(context));
}
-KeyedService* BuildEventRouter(content::BrowserContext* profile) {
- return new extensions::EventRouter(profile, nullptr);
+scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* profile) {
+ return make_scoped_ptr(new extensions::EventRouter(profile, nullptr));
}
} // namespace
@@ -220,8 +220,8 @@ class ExtensionSettingsSyncTest : public testing::Test {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
profile_.reset(new TestingProfile(temp_dir_.path()));
storage_factory_->Reset(new LeveldbSettingsStorageFactory());
- frontend_.reset(
- StorageFrontend::CreateForTesting(storage_factory_, profile_.get()));
+ frontend_ = StorageFrontend::CreateForTesting(storage_factory_,
+ profile_.get()).Pass();
ExtensionsBrowserClient::Get()
->GetExtensionSystemFactory()
diff --git a/chrome/browser/extensions/extension_action_test_util.cc b/chrome/browser/extensions/extension_action_test_util.cc
index da6756e..6a6eddc 100644
--- a/chrome/browser/extensions/extension_action_test_util.cc
+++ b/chrome/browser/extensions/extension_action_test_util.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/extension_action_test_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
@@ -69,10 +70,10 @@ size_t GetPageActionCount(content::WebContents* web_contents,
}
// Creates a new ExtensionToolbarModel for the given |context|.
-KeyedService* BuildToolbarModel(content::BrowserContext* context) {
- return new extensions::ExtensionToolbarModel(
+scoped_ptr<KeyedService> BuildToolbarModel(content::BrowserContext* context) {
+ return make_scoped_ptr(new extensions::ExtensionToolbarModel(
Profile::FromBrowserContext(context),
- extensions::ExtensionPrefs::Get(context));
+ extensions::ExtensionPrefs::Get(context)));
}
// Creates a new ExtensionToolbarModel for the given profile, optionally
diff --git a/chrome/browser/extensions/extension_garbage_collector_factory.cc b/chrome/browser/extensions/extension_garbage_collector_factory.cc
index ea93370..debcaf0 100644
--- a/chrome/browser/extensions/extension_garbage_collector_factory.cc
+++ b/chrome/browser/extensions/extension_garbage_collector_factory.cc
@@ -42,18 +42,18 @@ ExtensionGarbageCollectorFactory::ExtensionGarbageCollectorFactory()
ExtensionGarbageCollectorFactory::~ExtensionGarbageCollectorFactory() {}
// static
-KeyedService* ExtensionGarbageCollectorFactory::BuildInstanceFor(
+scoped_ptr<KeyedService> ExtensionGarbageCollectorFactory::BuildInstanceFor(
content::BrowserContext* context) {
#if defined(OS_CHROMEOS)
- return new ExtensionGarbageCollectorChromeOS(context);
+ return make_scoped_ptr(new ExtensionGarbageCollectorChromeOS(context));
#else
- return new ExtensionGarbageCollector(context);
+ return make_scoped_ptr(new ExtensionGarbageCollector(context));
#endif
}
KeyedService* ExtensionGarbageCollectorFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
- return BuildInstanceFor(context);
+ return BuildInstanceFor(context).release();
}
bool ExtensionGarbageCollectorFactory::ServiceIsCreatedWithBrowserContext()
diff --git a/chrome/browser/extensions/extension_garbage_collector_factory.h b/chrome/browser/extensions/extension_garbage_collector_factory.h
index 2f4f5d1..5e5852c 100644
--- a/chrome/browser/extensions/extension_garbage_collector_factory.h
+++ b/chrome/browser/extensions/extension_garbage_collector_factory.h
@@ -24,7 +24,8 @@ class ExtensionGarbageCollectorFactory
static ExtensionGarbageCollectorFactory* GetInstance();
- static KeyedService* BuildInstanceFor(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> BuildInstanceFor(
+ content::BrowserContext* context);
private:
friend struct DefaultSingletonTraits<ExtensionGarbageCollectorFactory>;
diff --git a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
index 1daefc7..cf3feb4 100644
--- a/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
+++ b/chrome/browser/extensions/extension_gcm_app_handler_unittest.cc
@@ -15,6 +15,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/run_loop.h"
@@ -187,15 +188,15 @@ class FakeExtensionGCMAppHandler : public ExtensionGCMAppHandler {
class ExtensionGCMAppHandlerTest : public testing::Test {
public:
- static KeyedService* BuildGCMProfileService(
+ static scoped_ptr<KeyedService> BuildGCMProfileService(
content::BrowserContext* context) {
- return new gcm::GCMProfileService(
+ return make_scoped_ptr(new gcm::GCMProfileService(
Profile::FromBrowserContext(context),
scoped_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::IO))));
+ content::BrowserThread::IO)))));
}
ExtensionGCMAppHandlerTest()
diff --git a/chrome/browser/extensions/menu_manager_factory.cc b/chrome/browser/extensions/menu_manager_factory.cc
index 1d2aa74..2bfd3cb 100644
--- a/chrome/browser/extensions/menu_manager_factory.cc
+++ b/chrome/browser/extensions/menu_manager_factory.cc
@@ -26,9 +26,9 @@ MenuManagerFactory* MenuManagerFactory::GetInstance() {
}
// static
-KeyedService* MenuManagerFactory::BuildServiceInstanceForTesting(
+scoped_ptr<KeyedService> MenuManagerFactory::BuildServiceInstanceForTesting(
content::BrowserContext* context) {
- return GetInstance()->BuildServiceInstanceFor(context);
+ return make_scoped_ptr(GetInstance()->BuildServiceInstanceFor(context));
}
MenuManagerFactory::MenuManagerFactory()
diff --git a/chrome/browser/extensions/menu_manager_factory.h b/chrome/browser/extensions/menu_manager_factory.h
index ae1693e..5e71738 100644
--- a/chrome/browser/extensions/menu_manager_factory.h
+++ b/chrome/browser/extensions/menu_manager_factory.h
@@ -22,7 +22,7 @@ class MenuManagerFactory : public BrowserContextKeyedServiceFactory {
static MenuManagerFactory* GetInstance();
- static KeyedService* BuildServiceInstanceForTesting(
+ static scoped_ptr<KeyedService> BuildServiceInstanceForTesting(
content::BrowserContext* context);
private:
diff --git a/chrome/browser/extensions/menu_manager_unittest.cc b/chrome/browser/extensions/menu_manager_unittest.cc
index 8b1ec7d..d058f00 100644
--- a/chrome/browser/extensions/menu_manager_unittest.cc
+++ b/chrome/browser/extensions/menu_manager_unittest.cc
@@ -6,6 +6,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_reader.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_service.h"
@@ -483,8 +484,9 @@ class MockEventRouter : public EventRouter {
};
// MockEventRouter factory function
-KeyedService* MockEventRouterFactoryFunction(content::BrowserContext* profile) {
- return new MockEventRouter(static_cast<Profile*>(profile));
+scoped_ptr<KeyedService> MockEventRouterFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new MockEventRouter(static_cast<Profile*>(context)));
}
} // namespace
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
index 14835f1..4ba5e95 100644
--- a/chrome/browser/extensions/test_extension_system.cc
+++ b/chrome/browser/extensions/test_extension_system.cc
@@ -44,7 +44,7 @@ void TestExtensionSystem::Shutdown() {
extension_service_->Shutdown();
}
-ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs(
+scoped_ptr<ExtensionPrefs> TestExtensionSystem::CreateExtensionPrefs(
const base::CommandLine* command_line,
const base::FilePath& install_directory) {
bool extensions_disabled =
@@ -55,11 +55,11 @@ ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs(
// are not reflected in the pref service. One would need to
// inject a new ExtensionPrefStore(extension_pref_value_map, false).
- return ExtensionPrefs::Create(
+ return make_scoped_ptr(ExtensionPrefs::Create(
profile_->GetPrefs(), install_directory,
ExtensionPrefValueMapFactory::GetForBrowserContext(profile_),
ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(),
- extensions_disabled, std::vector<ExtensionPrefsObserver*>());
+ extensions_disabled, std::vector<ExtensionPrefsObserver*>()));
}
ExtensionService* TestExtensionSystem::CreateExtensionService(
@@ -137,8 +137,10 @@ scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions(
}
// static
-KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) {
- return new TestExtensionSystem(static_cast<Profile*>(profile));
+scoped_ptr<KeyedService> TestExtensionSystem::Build(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new TestExtensionSystem(static_cast<Profile*>(profile)));
}
} // namespace extensions
diff --git a/chrome/browser/extensions/test_extension_system.h b/chrome/browser/extensions/test_extension_system.h
index 7efd930..3605626 100644
--- a/chrome/browser/extensions/test_extension_system.h
+++ b/chrome/browser/extensions/test_extension_system.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
#define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
+#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h"
@@ -41,8 +42,9 @@ class TestExtensionSystem : public ExtensionSystem {
// Creates an ExtensionPrefs with the testing profile and returns it.
// Useful for tests that need to modify prefs before creating the
// ExtensionService.
- ExtensionPrefs* CreateExtensionPrefs(const base::CommandLine* command_line,
- const base::FilePath& install_directory);
+ scoped_ptr<ExtensionPrefs> CreateExtensionPrefs(
+ const base::CommandLine* command_line,
+ const base::FilePath& install_directory);
// Creates an ExtensionService initialized with the testing profile and
// returns it, and creates ExtensionPrefs if it hasn't been created yet.
@@ -74,7 +76,7 @@ class TestExtensionSystem : public ExtensionSystem {
void SetReady() { ready_.Signal(); }
// Factory method for tests to use with SetTestingProfile.
- static KeyedService* Build(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile);
protected:
Profile* profile_;
diff --git a/chrome/browser/history/web_history_service_unittest.cc b/chrome/browser/history/web_history_service_unittest.cc
index 6bbb54a..3d20a89 100644
--- a/chrome/browser/history/web_history_service_unittest.cc
+++ b/chrome/browser/history/web_history_service_unittest.cc
@@ -195,12 +195,13 @@ std::string TestingWebHistoryService::GetExpectedAudioHistoryValue() {
return "false";
}
-static KeyedService* BuildWebHistoryService(content::BrowserContext* context) {
+static scoped_ptr<KeyedService> BuildWebHistoryService(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new TestingWebHistoryService(
+ return make_scoped_ptr(new TestingWebHistoryService(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
- profile->GetRequestContext());
+ profile->GetRequestContext()));
}
} // namespace
diff --git a/chrome/browser/invalidation/profile_invalidation_provider_factory.cc b/chrome/browser/invalidation/profile_invalidation_provider_factory.cc
index 39b401a..4bc6171 100644
--- a/chrome/browser/invalidation/profile_invalidation_provider_factory.cc
+++ b/chrome/browser/invalidation/profile_invalidation_provider_factory.cc
@@ -95,7 +95,7 @@ void ProfileInvalidationProviderFactory::RegisterTestingFactory(
KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
if (testing_factory_)
- return testing_factory_(context);
+ return testing_factory_(context).release();
#if defined(OS_ANDROID)
return new ProfileInvalidationProvider(scoped_ptr<InvalidationService>(
diff --git a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
index 810bdb7..09e2572 100644
--- a/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
+++ b/chrome/browser/media/router/media_router_mojo_impl_unittest.cc
@@ -83,8 +83,8 @@ class TestProcessManager : public extensions::ProcessManager {
extensions::ExtensionRegistry::Get(context)) {}
~TestProcessManager() override {}
- static KeyedService* Create(content::BrowserContext* context) {
- return new TestProcessManager(context);
+ static scoped_ptr<KeyedService> Create(content::BrowserContext* context) {
+ return make_scoped_ptr(new TestProcessManager(context));
}
MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& ext_id));
diff --git a/chrome/browser/password_manager/mock_password_store_service.cc b/chrome/browser/password_manager/mock_password_store_service.cc
index f3acb90..e33ea04 100644
--- a/chrome/browser/password_manager/mock_password_store_service.cc
+++ b/chrome/browser/password_manager/mock_password_store_service.cc
@@ -7,13 +7,13 @@
#include "components/password_manager/core/browser/mock_password_store.h"
// static
-KeyedService* MockPasswordStoreService::Build(
+scoped_ptr<KeyedService> MockPasswordStoreService::Build(
content::BrowserContext* /*profile*/) {
scoped_refptr<password_manager::PasswordStore> store(
new password_manager::MockPasswordStore);
if (!store.get() || !store->Init(syncer::SyncableService::StartSyncFlare()))
return nullptr;
- return new MockPasswordStoreService(store);
+ return scoped_ptr<KeyedService>(new MockPasswordStoreService(store));
}
MockPasswordStoreService::MockPasswordStoreService(
diff --git a/chrome/browser/password_manager/mock_password_store_service.h b/chrome/browser/password_manager/mock_password_store_service.h
index bad233e..9b335bd 100644
--- a/chrome/browser/password_manager/mock_password_store_service.h
+++ b/chrome/browser/password_manager/mock_password_store_service.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_PASSWORD_MANAGER_MOCK_PASSWORD_STORE_SERVICE_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_MOCK_PASSWORD_STORE_SERVICE_H_
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/password_manager/password_store_factory.h"
namespace content {
@@ -17,7 +18,7 @@ class PasswordStore;
class MockPasswordStoreService : public PasswordStoreService {
public:
- static KeyedService* Build(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile);
private:
explicit MockPasswordStoreService(
diff --git a/chrome/browser/password_manager/test_password_store_service.cc b/chrome/browser/password_manager/test_password_store_service.cc
index af96bc3..ef5ad24 100644
--- a/chrome/browser/password_manager/test_password_store_service.cc
+++ b/chrome/browser/password_manager/test_password_store_service.cc
@@ -7,13 +7,13 @@
#include "components/password_manager/core/browser/test_password_store.h"
// static
-KeyedService* TestPasswordStoreService::Build(
+scoped_ptr<KeyedService> TestPasswordStoreService::Build(
content::BrowserContext* /*profile*/) {
scoped_refptr<password_manager::PasswordStore> store(
new password_manager::TestPasswordStore);
if (!store.get() || !store->Init(syncer::SyncableService::StartSyncFlare()))
return nullptr;
- return new TestPasswordStoreService(store);
+ return scoped_ptr<KeyedService>(new TestPasswordStoreService(store));
}
TestPasswordStoreService::TestPasswordStoreService(
diff --git a/chrome/browser/password_manager/test_password_store_service.h b/chrome/browser/password_manager/test_password_store_service.h
index 9e28cc7..3660f25 100644
--- a/chrome/browser/password_manager/test_password_store_service.h
+++ b/chrome/browser/password_manager/test_password_store_service.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_PASSWORD_MANAGER_TEST_PASSWORD_STORE_SERVICE_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_TEST_PASSWORD_STORE_SERVICE_H_
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/password_manager/password_store_factory.h"
namespace content {
@@ -17,7 +18,7 @@ class PasswordStore;
class TestPasswordStoreService : public PasswordStoreService {
public:
- static KeyedService* Build(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile);
private:
explicit TestPasswordStoreService(
diff --git a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
index ebce294..8958e7b 100644
--- a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
@@ -77,11 +77,11 @@ namespace policy {
namespace {
-KeyedService* BuildFakeProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildFakeProfileInvalidationProvider(
content::BrowserContext* context) {
- return new invalidation::ProfileInvalidationProvider(
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
scoped_ptr<invalidation::InvalidationService>(
- new invalidation::FakeInvalidationService));
+ new invalidation::FakeInvalidationService)));
}
#if !defined(OS_CHROMEOS)
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
index 047dcd9..af496a0 100644
--- a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
+++ b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/files/file_path.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/run_loop.h"
#include "base/thread_task_runner_handle.h"
@@ -95,8 +96,9 @@ class SigninManagerFake : public FakeSigninManager {
SignOut(signin_metrics::SIGNOUT_TEST);
}
- static KeyedService* Build(content::BrowserContext* profile) {
- return new SigninManagerFake(static_cast<Profile*>(profile));
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new SigninManagerFake(static_cast<Profile*>(profile)));
}
};
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index cb56e11..6d255a5 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/profile_resetter/profile_resetter.h"
#include "base/json/json_string_value_serializer.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_path_override.h"
@@ -107,7 +108,7 @@ class ProfileResetterTest : public extensions::ExtensionServiceTestBase,
TestingProfile* profile() { return profile_.get(); }
- static KeyedService* CreateTemplateURLService(
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
content::BrowserContext* context);
private:
@@ -144,15 +145,15 @@ void ProfileResetterTest::SetUp() {
}
// static
-KeyedService* ProfileResetterTest::CreateTemplateURLService(
+scoped_ptr<KeyedService> ProfileResetterTest::CreateTemplateURLService(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
profile->GetPrefs(),
scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
WebDataServiceFactory::GetKeywordWebDataForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS),
- scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure());
+ scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()));
}
diff --git a/chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc
index c9d2f8a..e128511 100644
--- a/chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -42,7 +43,7 @@ namespace {
// A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a
// HistoryService for a TestingProfile.
-KeyedService* BuildHistoryService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildHistoryService(content::BrowserContext* context) {
TestingProfile* profile = static_cast<TestingProfile*>(context);
// Delete the file before creating the service.
@@ -52,21 +53,21 @@ KeyedService* BuildHistoryService(content::BrowserContext* context) {
base::PathExists(history_path)) {
ADD_FAILURE() << "failed to delete history db file "
<< history_path.value();
- return NULL;
+ return nullptr;
}
- history::HistoryService* history_service = new history::HistoryService(
- ChromeHistoryClientFactory::GetForProfile(profile),
- scoped_ptr<history::VisitDelegate>());
+ scoped_ptr<history::HistoryService> history_service(
+ new history::HistoryService(
+ ChromeHistoryClientFactory::GetForProfile(profile),
+ scoped_ptr<history::VisitDelegate>()));
if (history_service->Init(
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
history::HistoryDatabaseParamsForPath(profile->GetPath()))) {
- return history_service;
+ return history_service.Pass();
}
ADD_FAILURE() << "failed to initialize history service";
- delete history_service;
- return NULL;
+ return nullptr;
}
} // namespace
diff --git a/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector_unittest.cc
index 22d7cf8..862a657 100644
--- a/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector_unittest.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_detector_unittest.cc
@@ -56,7 +56,7 @@ const int kFakeRenderProcessId = 123;
// A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a
// HistoryService for a TestingProfile.
-KeyedService* BuildHistoryService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildHistoryService(content::BrowserContext* context) {
TestingProfile* profile = static_cast<TestingProfile*>(context);
// Delete the file before creating the service.
@@ -66,21 +66,21 @@ KeyedService* BuildHistoryService(content::BrowserContext* context) {
base::PathExists(history_path)) {
ADD_FAILURE() << "failed to delete history db file "
<< history_path.value();
- return NULL;
+ return nullptr;
}
- history::HistoryService* history_service = new history::HistoryService(
- ChromeHistoryClientFactory::GetForProfile(profile),
- scoped_ptr<history::VisitDelegate>());
+ scoped_ptr<history::HistoryService> history_service(
+ new history::HistoryService(
+ ChromeHistoryClientFactory::GetForProfile(profile),
+ scoped_ptr<history::VisitDelegate>()));
if (history_service->Init(
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
history::HistoryDatabaseParamsForPath(profile->GetPath()))) {
- return history_service;
+ return history_service.Pass();
}
ADD_FAILURE() << "failed to initialize history service";
- delete history_service;
- return NULL;
+ return nullptr;
}
} // namespace
diff --git a/chrome/browser/search/hotword_installer_browsertest.cc b/chrome/browser/search/hotword_installer_browsertest.cc
index 44d818c..3293bf2 100644
--- a/chrome/browser/search/hotword_installer_browsertest.cc
+++ b/chrome/browser/search/hotword_installer_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/webstore_startup_installer.h"
#include "chrome/browser/profiles/profile.h"
@@ -67,8 +68,10 @@ class MockHotwordService : public HotwordService {
base::WeakPtrFactory<MockHotwordService> weak_factory_;
};
-KeyedService* BuildMockHotwordService(content::BrowserContext* context) {
- return new MockHotwordService(static_cast<Profile*>(context));
+scoped_ptr<KeyedService> BuildMockHotwordService(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new MockHotwordService(static_cast<Profile*>(context)));
}
} // namespace
diff --git a/chrome/browser/search/hotword_service_unittest.cc b/chrome/browser/search/hotword_service_unittest.cc
index 8444446..9d53410 100644
--- a/chrome/browser/search/hotword_service_unittest.cc
+++ b/chrome/browser/search/hotword_service_unittest.cc
@@ -109,8 +109,10 @@ class MockHotwordService : public HotwordService {
std::string extension_id_;
};
-KeyedService* BuildMockHotwordService(content::BrowserContext* context) {
- return new MockHotwordService(static_cast<Profile*>(context));
+scoped_ptr<KeyedService> BuildMockHotwordService(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new MockHotwordService(static_cast<Profile*>(context)));
}
} // namespace
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc
index c4229d3..4d6709a 100644
--- a/chrome/browser/search_engines/template_url_service_factory.cc
+++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -35,7 +35,7 @@ TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() {
}
// static
-KeyedService* TemplateURLServiceFactory::BuildInstanceFor(
+scoped_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor(
content::BrowserContext* context) {
base::Closure dsp_change_callback;
#if defined(ENABLE_RLZ)
@@ -46,7 +46,7 @@ KeyedService* TemplateURLServiceFactory::BuildInstanceFor(
rlz_lib::SET_TO_GOOGLE);
#endif
Profile* profile = static_cast<Profile*>(context);
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
profile->GetPrefs(),
scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
WebDataServiceFactory::GetKeywordWebDataForProfile(
@@ -55,8 +55,7 @@ KeyedService* TemplateURLServiceFactory::BuildInstanceFor(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
GoogleURLTrackerFactory::GetForProfile(profile),
- g_browser_process->rappor_service(),
- dsp_change_callback);
+ g_browser_process->rappor_service(), dsp_change_callback));
}
TemplateURLServiceFactory::TemplateURLServiceFactory()
@@ -72,7 +71,7 @@ TemplateURLServiceFactory::~TemplateURLServiceFactory() {}
KeyedService* TemplateURLServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
- return BuildInstanceFor(static_cast<Profile*>(profile));
+ return BuildInstanceFor(static_cast<Profile*>(profile)).release();
}
void TemplateURLServiceFactory::RegisterProfilePrefs(
diff --git a/chrome/browser/search_engines/template_url_service_factory.h b/chrome/browser/search_engines/template_url_service_factory.h
index 9939278..db900b0 100644
--- a/chrome/browser/search_engines/template_url_service_factory.h
+++ b/chrome/browser/search_engines/template_url_service_factory.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_H_
#define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_H_
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -19,7 +20,8 @@ class TemplateURLServiceFactory : public BrowserContextKeyedServiceFactory {
static TemplateURLServiceFactory* GetInstance();
- static KeyedService* BuildInstanceFor(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> BuildInstanceFor(
+ content::BrowserContext* profile);
private:
friend struct DefaultSingletonTraits<TemplateURLServiceFactory>;
diff --git a/chrome/browser/services/gcm/fake_gcm_profile_service.cc b/chrome/browser/services/gcm/fake_gcm_profile_service.cc
index e1926a3..a1b5e3c 100644
--- a/chrome/browser/services/gcm/fake_gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/fake_gcm_profile_service.cc
@@ -105,11 +105,12 @@ void CustomFakeGCMDriver::OnSendFinished(const std::string& app_id,
} // namespace
// static
-KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) {
+scoped_ptr<KeyedService> FakeGCMProfileService::Build(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- FakeGCMProfileService* service = new FakeGCMProfileService(profile);
- service->SetDriverForTesting(new CustomFakeGCMDriver(service));
- return service;
+ scoped_ptr<FakeGCMProfileService> service(new FakeGCMProfileService(profile));
+ service->SetDriverForTesting(new CustomFakeGCMDriver(service.get()));
+ return service.Pass();
}
FakeGCMProfileService::FakeGCMProfileService(Profile* profile)
diff --git a/chrome/browser/services/gcm/fake_gcm_profile_service.h b/chrome/browser/services/gcm/fake_gcm_profile_service.h
index 58ba184..ce5907c 100644
--- a/chrome/browser/services/gcm/fake_gcm_profile_service.h
+++ b/chrome/browser/services/gcm/fake_gcm_profile_service.h
@@ -8,6 +8,7 @@
#include <list>
#include <vector>
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/services/gcm/gcm_profile_service.h"
#include "components/gcm_driver/gcm_driver.h"
@@ -24,7 +25,7 @@ class FakeGCMProfileService : public GCMProfileService {
// Helper function to be used with
// KeyedService::SetTestingFactory().
- static KeyedService* Build(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context);
explicit FakeGCMProfileService(Profile* profile);
~FakeGCMProfileService() override;
diff --git a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
index ea3ccda..8c3afb5 100644
--- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
+++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
@@ -35,14 +35,15 @@ namespace {
const char kTestAppID[] = "TestApp";
const char kUserID[] = "user";
-KeyedService* BuildGCMProfileService(content::BrowserContext* context) {
- return new GCMProfileService(
+scoped_ptr<KeyedService> BuildGCMProfileService(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new GCMProfileService(
Profile::FromBrowserContext(context),
scoped_ptr<GCMClientFactory>(new FakeGCMClientFactory(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI),
content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::IO))));
+ content::BrowserThread::IO)))));
}
} // namespace
@@ -217,7 +218,7 @@ TEST_F(GCMProfileServiceTest, Send) {
GCMClient::OutgoingMessage message;
message.id = "1";
message.data["key1"] = "value1";
- SendAndWaitForCompletion( message);
+ SendAndWaitForCompletion(message);
EXPECT_EQ(message.id, send_message_id());
EXPECT_EQ(GCMClient::SUCCESS, send_result());
diff --git a/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc b/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc
index fe4a05a..cadb88b 100644
--- a/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc
+++ b/chrome/browser/sessions/persistent_tab_restore_service_unittest.cc
@@ -146,9 +146,8 @@ class PersistentTabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
// way of AddWindowWithOneTabToSessionService. If |pinned| is true, the
// tab is marked as pinned in the session service.
void CreateSessionServiceWithOneWindow(bool pinned) {
- // The profile takes ownership of this.
- SessionService* session_service = new SessionService(profile());
- SessionServiceFactory::SetForTestProfile(profile(), session_service);
+ scoped_ptr<SessionService> session_service(new SessionService(profile()));
+ SessionServiceFactory::SetForTestProfile(profile(), session_service.Pass());
AddWindowWithOneTabToSessionService(pinned);
diff --git a/chrome/browser/sessions/session_service_factory.h b/chrome/browser/sessions/session_service_factory.h
index 2c73d57..c0db39c 100644
--- a/chrome/browser/sessions/session_service_factory.h
+++ b/chrome/browser/sessions/session_service_factory.h
@@ -44,10 +44,11 @@ class SessionServiceFactory : public BrowserContextKeyedServiceFactory {
#if defined(UNIT_TEST)
// For test use: force setting of the session service for a given profile.
// This will delete a previous session service for this profile if it exists.
- static void SetForTestProfile(Profile* profile, SessionService* service) {
+ static void SetForTestProfile(Profile* profile,
+ scoped_ptr<SessionService> service) {
GetInstance()->BrowserContextShutdown(profile);
GetInstance()->BrowserContextDestroyed(profile);
- GetInstance()->Associate(profile, service);
+ GetInstance()->Associate(profile, service.Pass());
}
#endif
diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc
index 8d91abd..2cee3f7 100644
--- a/chrome/browser/signin/account_reconcilor_unittest.cc
+++ b/chrome/browser/signin/account_reconcilor_unittest.cc
@@ -43,7 +43,7 @@ namespace {
class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
public:
- static KeyedService* Build(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context);
MockAccountReconcilor(ProfileOAuth2TokenService* token_service,
SigninManagerBase* signin_manager,
@@ -56,15 +56,16 @@ class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
};
// static
-KeyedService* MockAccountReconcilor::Build(content::BrowserContext* context) {
+scoped_ptr<KeyedService> MockAccountReconcilor::Build(
+ content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- AccountReconcilor* reconcilor = new MockAccountReconcilor(
+ scoped_ptr<AccountReconcilor> reconcilor(new MockAccountReconcilor(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
ChromeSigninClientFactory::GetForProfile(profile),
- GaiaCookieManagerServiceFactory::GetForProfile(profile));
+ GaiaCookieManagerServiceFactory::GetForProfile(profile)));
reconcilor->Initialize(false /* start_reconcile_if_tokens_available */);
- return reconcilor;
+ return reconcilor.Pass();
}
MockAccountReconcilor::MockAccountReconcilor(
diff --git a/chrome/browser/signin/easy_unlock_app_manager_unittest.cc b/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
index bab12ed..89bf24b 100644
--- a/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
+++ b/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
@@ -69,8 +69,9 @@ class TestProcessManager : public extensions::ProcessManager {
DISALLOW_COPY_AND_ASSIGN(TestProcessManager);
};
-KeyedService* CreateTestProcessManager(content::BrowserContext* context) {
- return new TestProcessManager(context);
+scoped_ptr<KeyedService> CreateTestProcessManager(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new TestProcessManager(context));
}
// Observes extension registry for unload and load events (in that order) of an
@@ -262,9 +263,11 @@ class TestEventRouter : public extensions::EventRouter {
};
// TestEventRouter factory function
-KeyedService* TestEventRouterFactoryFunction(content::BrowserContext* context) {
- return new TestEventRouter(static_cast<Profile*>(context),
- extensions::ExtensionPrefs::Get(context));
+scoped_ptr<KeyedService> TestEventRouterFactoryFunction(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new TestEventRouter(static_cast<Profile*>(context),
+ extensions::ExtensionPrefs::Get(context)));
}
class EasyUnlockAppManagerTest : public testing::Test {
diff --git a/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc b/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
index c5b3418..8c8ccaa 100644
--- a/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
+++ b/chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc
@@ -6,6 +6,7 @@
#include <string>
#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
@@ -169,21 +170,22 @@ TestAppManagerFactory* app_manager_factory = NULL;
// EasyUnlockService factory function injected into testing profiles.
// It creates an EasyUnlockService with test AppManager.
-KeyedService* CreateEasyUnlockServiceForTest(content::BrowserContext* context) {
+scoped_ptr<KeyedService> CreateEasyUnlockServiceForTest(
+ content::BrowserContext* context) {
EXPECT_TRUE(app_manager_factory);
if (!app_manager_factory)
- return NULL;
+ return nullptr;
scoped_ptr<EasyUnlockAppManager> app_manager =
app_manager_factory->Create(context);
EXPECT_TRUE(app_manager.get());
if (!app_manager.get())
- return NULL;
+ return nullptr;
- EasyUnlockService* service =
- new EasyUnlockServiceRegular(Profile::FromBrowserContext(context));
+ scoped_ptr<EasyUnlockServiceRegular> service(
+ new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)));
service->Initialize(app_manager.Pass());
- return service;
+ return service.Pass();
}
class EasyUnlockServiceTest : public testing::Test {
diff --git a/chrome/browser/signin/fake_account_tracker_service.cc b/chrome/browser/signin/fake_account_tracker_service.cc
index 5fd0fcd..b9b38ab 100644
--- a/chrome/browser/signin/fake_account_tracker_service.cc
+++ b/chrome/browser/signin/fake_account_tracker_service.cc
@@ -11,14 +11,14 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
// static
-KeyedService* FakeAccountTrackerService::Build(
+scoped_ptr<KeyedService> FakeAccountTrackerService::Build(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
FakeAccountTrackerService* service = new FakeAccountTrackerService();
service->Initialize(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
ChromeSigninClientFactory::GetForProfile(profile));
- return service;
+ return scoped_ptr<KeyedService>(service);
}
FakeAccountTrackerService::FakeAccountTrackerService() {}
diff --git a/chrome/browser/signin/fake_account_tracker_service.h b/chrome/browser/signin/fake_account_tracker_service.h
index a30f913..5008d512 100644
--- a/chrome/browser/signin/fake_account_tracker_service.h
+++ b/chrome/browser/signin/fake_account_tracker_service.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SIGNIN_FAKE_ACCOUNT_TRACKER_SERVICE_H_
#define CHROME_BROWSER_SIGNIN_FAKE_ACCOUNT_TRACKER_SERVICE_H_
+#include "base/memory/scoped_ptr.h"
#include "components/signin/core/browser/account_tracker_service.h"
class KeyedService;
@@ -18,7 +19,7 @@ class BrowserContext;
// to prevent AccountTrackerService from sending network requests.
class FakeAccountTrackerService : public AccountTrackerService {
public:
- static KeyedService* Build(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context);
void FakeUserInfoFetchSuccess(const std::string& email,
const std::string& gaia,
diff --git a/chrome/browser/signin/fake_gaia_cookie_manager_service.cc b/chrome/browser/signin/fake_gaia_cookie_manager_service.cc
index 9c33cf7..033a295 100644
--- a/chrome/browser/signin/fake_gaia_cookie_manager_service.cc
+++ b/chrome/browser/signin/fake_gaia_cookie_manager_service.cc
@@ -112,12 +112,11 @@ void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccountsWithExpiry(
}
// static
-KeyedService* FakeGaiaCookieManagerService::Build(
+scoped_ptr<KeyedService> FakeGaiaCookieManagerService::Build(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- FakeGaiaCookieManagerService* service = new FakeGaiaCookieManagerService(
+ return make_scoped_ptr(new FakeGaiaCookieManagerService(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
GaiaConstants::kChromeSource,
- ChromeSigninClientFactory::GetForProfile(profile));
- return service;
+ ChromeSigninClientFactory::GetForProfile(profile)));
}
diff --git a/chrome/browser/signin/fake_gaia_cookie_manager_service.h b/chrome/browser/signin/fake_gaia_cookie_manager_service.h
index 93d5969..662aca8 100644
--- a/chrome/browser/signin/fake_gaia_cookie_manager_service.h
+++ b/chrome/browser/signin/fake_gaia_cookie_manager_service.h
@@ -6,6 +6,7 @@
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
+#include "base/memory/scoped_ptr.h"
#include "net/url_request/test_url_fetcher_factory.h"
namespace content {
@@ -35,7 +36,7 @@ class FakeGaiaCookieManagerService : public GaiaCookieManagerService {
const char* account2, bool account2_expired);
// Helper function to be used with KeyedService::SetTestingFactory().
- static KeyedService* Build(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context);
private:
// Provide a fake response for calls to /ListAccounts.
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
index 90e9fe3..1888211 100644
--- a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
@@ -2,30 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
+
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
-#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
// TODO(blundell): Should these be namespaced?
-KeyedService* BuildFakeProfileOAuth2TokenService(
+scoped_ptr<KeyedService> BuildFakeProfileOAuth2TokenService(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService();
+ scoped_ptr<FakeProfileOAuth2TokenService> service(
+ new FakeProfileOAuth2TokenService());
service->Initialize(
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
SigninErrorControllerFactory::GetInstance()->GetForProfile(profile));
- return service;
+ return service.Pass();
}
-KeyedService* BuildAutoIssuingFakeProfileOAuth2TokenService(
+scoped_ptr<KeyedService> BuildAutoIssuingFakeProfileOAuth2TokenService(
content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService();
+ scoped_ptr<FakeProfileOAuth2TokenService> service(
+ new FakeProfileOAuth2TokenService());
service->set_auto_post_fetch_response_on_message_loop(true);
service->Initialize(
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
SigninErrorControllerFactory::GetInstance()->GetForProfile(profile));
- return service;
+ return service.Pass();
}
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h
index 21672b6..d9cd4bd 100644
--- a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_
#define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_
+#include "base/memory/scoped_ptr.h"
+
class KeyedService;
namespace content {
@@ -14,14 +16,14 @@ class BrowserContext;
// Helper function to be used with
// BrowserContextKeyedServiceFactory::SetTestingFactory() that returns a
// FakeProfileOAuth2TokenService object.
-KeyedService* BuildFakeProfileOAuth2TokenService(
+scoped_ptr<KeyedService> BuildFakeProfileOAuth2TokenService(
content::BrowserContext* context);
// Helper function to be used with
// BrowserContextKeyedServiceFactory::SetTestingFactory() that creates a
// FakeProfileOAuth2TokenService object that posts fetch responses on the
// current message loop.
-KeyedService* BuildAutoIssuingFakeProfileOAuth2TokenService(
+scoped_ptr<KeyedService> BuildAutoIssuingFakeProfileOAuth2TokenService(
content::BrowserContext* context);
#endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_
diff --git a/chrome/browser/signin/fake_signin_manager.cc b/chrome/browser/signin/fake_signin_manager.cc
index 6cc2902..f81b4b4 100644
--- a/chrome/browser/signin/fake_signin_manager.cc
+++ b/chrome/browser/signin/fake_signin_manager.cc
@@ -26,18 +26,19 @@ FakeSigninManagerBase::~FakeSigninManagerBase() {
}
// static
-KeyedService* FakeSigninManagerBase::Build(content::BrowserContext* context) {
- SigninManagerBase* manager;
+scoped_ptr<KeyedService> FakeSigninManagerBase::Build(
+ content::BrowserContext* context) {
+ scoped_ptr<SigninManagerBase> manager;
Profile* profile = static_cast<Profile*>(context);
#if defined(OS_CHROMEOS)
- manager = new FakeSigninManagerBase(profile);
+ manager.reset(new FakeSigninManagerBase(profile));
#else
- manager = new FakeSigninManager(profile);
+ manager.reset(new FakeSigninManager(profile));
#endif
manager->Initialize(NULL);
SigninManagerFactory::GetInstance()
- ->NotifyObserversOfSigninManagerCreationForTesting(manager);
- return manager;
+ ->NotifyObserversOfSigninManagerCreationForTesting(manager.get());
+ return manager.Pass();
}
#if !defined (OS_CHROMEOS)
diff --git a/chrome/browser/signin/fake_signin_manager.h b/chrome/browser/signin/fake_signin_manager.h
index 24e59c4..7128ae4 100644
--- a/chrome/browser/signin/fake_signin_manager.h
+++ b/chrome/browser/signin/fake_signin_manager.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_metrics.h"
@@ -32,7 +33,7 @@ class FakeSigninManagerBase : public SigninManagerBase {
// the API of SigninManagerFactory::GetForProfile(), returns a
// FakeSigninManagerBase* on ChromeOS, and a FakeSigninManager* on all other
// platforms. The returned instance is initialized.
- static KeyedService* Build(content::BrowserContext* context);
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* context);
};
#if !defined(OS_CHROMEOS)
diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc
index 978198b..bd5fb3e 100644
--- a/chrome/browser/signin/signin_manager_unittest.cc
+++ b/chrome/browser/signin/signin_manager_unittest.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
@@ -48,16 +49,15 @@
namespace {
-KeyedService* SigninManagerBuild(content::BrowserContext* context) {
- SigninManager* service = NULL;
+scoped_ptr<KeyedService> SigninManagerBuild(content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- service = new SigninManager(
+ scoped_ptr<SigninManager> service(new SigninManager(
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile),
- GaiaCookieManagerServiceFactory::GetForProfile(profile));
+ GaiaCookieManagerServiceFactory::GetForProfile(profile)));
service->Initialize(NULL);
- return service;
+ return service.Pass();
}
class TestSigninManagerObserver : public SigninManagerBase::Observer {
diff --git a/chrome/browser/signin/test_signin_client_builder.cc b/chrome/browser/signin/test_signin_client_builder.cc
index d846fa01..ef66af9 100644
--- a/chrome/browser/signin/test_signin_client_builder.cc
+++ b/chrome/browser/signin/test_signin_client_builder.cc
@@ -7,19 +7,12 @@
#include "chrome/browser/profiles/profile.h"
#include "components/signin/core/browser/test_signin_client.h"
-class KeyedService;
-
-namespace content {
-class BrowserContext;
-}
-
namespace signin {
-KeyedService* BuildTestSigninClient(
+scoped_ptr<KeyedService> BuildTestSigninClient(
content::BrowserContext* context) {
- TestSigninClient* test_signin_client =
- new TestSigninClient(static_cast<Profile*>(context)->GetPrefs());
- return test_signin_client;
+ return make_scoped_ptr(
+ new TestSigninClient(static_cast<Profile*>(context)->GetPrefs()));
}
} // namespace signin
diff --git a/chrome/browser/signin/test_signin_client_builder.h b/chrome/browser/signin/test_signin_client_builder.h
index 435231b..54bb6eb 100644
--- a/chrome/browser/signin/test_signin_client_builder.h
+++ b/chrome/browser/signin/test_signin_client_builder.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SIGNIN_TEST_SIGNIN_CLIENT_BUILDER_H_
#define CHROME_BROWSER_SIGNIN_TEST_SIGNIN_CLIENT_BUILDER_H_
+#include "base/memory/scoped_ptr.h"
+
class KeyedService;
namespace content {
@@ -15,7 +17,8 @@ namespace signin {
// Method to be used by the |ChromeSigninClientFactory| to create a test version
// of the SigninClient
-KeyedService* BuildTestSigninClient(content::BrowserContext* context);
+scoped_ptr<KeyedService> BuildTestSigninClient(
+ content::BrowserContext* context);
} // namespace signin
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
index 387636b..dbd4da5 100644
--- a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
+++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "base/files/file_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/string_number_conversions.h"
@@ -53,8 +54,9 @@ syncer::SyncDataList GetAllSyncDataNoLimit(
} // namespace
-static KeyedService* BuildSpellcheckService(content::BrowserContext* profile) {
- return new SpellcheckService(static_cast<Profile*>(profile));
+static scoped_ptr<KeyedService> BuildSpellcheckService(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new SpellcheckService(static_cast<Profile*>(profile)));
}
class SpellcheckCustomDictionaryTest : public testing::Test {
diff --git a/chrome/browser/spellchecker/spellcheck_service_unittest.cc b/chrome/browser/spellchecker/spellcheck_service_unittest.cc
index 7cbc67b..f2fd9f0 100644
--- a/chrome/browser/spellchecker/spellcheck_service_unittest.cc
+++ b/chrome/browser/spellchecker/spellcheck_service_unittest.cc
@@ -6,14 +6,16 @@
#include <algorithm>
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/spellchecker/feedback_sender.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
-static KeyedService* BuildSpellcheckService(content::BrowserContext* profile) {
- return new SpellcheckService(static_cast<Profile*>(profile));
+static scoped_ptr<KeyedService> BuildSpellcheckService(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new SpellcheckService(static_cast<Profile*>(profile)));
}
class SpellcheckServiceTest : public testing::Test {
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
index 972d169..d218916 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
@@ -6,6 +6,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -107,8 +108,8 @@ class FakeWebDataService : public AutofillWebDataService {
class MockWebDataServiceWrapperSyncable : public MockWebDataServiceWrapper {
public:
- static KeyedService* Build(content::BrowserContext* profile) {
- return new MockWebDataServiceWrapperSyncable();
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) {
+ return make_scoped_ptr(new MockWebDataServiceWrapperSyncable());
}
MockWebDataServiceWrapperSyncable()
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
index 340adc1..9f6c3b0 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller_unittest.cc
@@ -58,23 +58,25 @@ class HistoryMock : public history::HistoryService {
~HistoryMock() override {}
};
-KeyedService* BuildChromeBookmarkClient(content::BrowserContext* context) {
- return new ChromeBookmarkClient(static_cast<Profile*>(context));
+scoped_ptr<KeyedService> BuildChromeBookmarkClient(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(
+ new ChromeBookmarkClient(static_cast<Profile*>(context)));
}
-KeyedService* BuildBookmarkModelWithoutLoading(
+scoped_ptr<KeyedService> BuildBookmarkModelWithoutLoading(
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);
- return bookmark_model;
+ scoped_ptr<BookmarkModel> bookmark_model(new BookmarkModel(bookmark_client));
+ bookmark_client->Init(bookmark_model.get());
+ return bookmark_model.Pass();
}
-KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
- BookmarkModel* bookmark_model = static_cast<BookmarkModel*>(
- BuildBookmarkModelWithoutLoading(context));
+scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) {
+ scoped_ptr<BookmarkModel> bookmark_model(static_cast<BookmarkModel*>(
+ BuildBookmarkModelWithoutLoading(context).release()));
Profile* profile = static_cast<Profile*>(context);
bookmark_model->Load(profile->GetPrefs(),
profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
@@ -82,11 +84,11 @@ KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
profile->GetIOTaskRunner(),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI));
- return bookmark_model;
+ return bookmark_model.Pass();
}
-KeyedService* BuildHistoryService(content::BrowserContext* profile) {
- return new HistoryMock;
+scoped_ptr<KeyedService> BuildHistoryService(content::BrowserContext* profile) {
+ return scoped_ptr<KeyedService>(new HistoryMock);
}
} // namespace
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index 802bde3..6951424 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -337,10 +337,10 @@ class WebDataServiceFake : public AutofillWebDataService {
DISALLOW_COPY_AND_ASSIGN(WebDataServiceFake);
};
-KeyedService* BuildMockWebDataServiceWrapper(content::BrowserContext* profile) {
- return new MockWebDataServiceWrapper(
- new WebDataServiceFake(),
- new TokenWebDataServiceFake());
+scoped_ptr<KeyedService> BuildMockWebDataServiceWrapper(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new MockWebDataServiceWrapper(
+ new WebDataServiceFake(), new TokenWebDataServiceFake()));
}
ACTION_P(MakeAutocompleteSyncComponents, wds) {
@@ -425,8 +425,8 @@ class MockPersonalDataManager : public PersonalDataManager {
MOCK_METHOD0(LoadCreditCards, void());
MOCK_METHOD0(Refresh, void());
- static KeyedService* Build(content::BrowserContext* profile) {
- return new MockPersonalDataManager();
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) {
+ return make_scoped_ptr(new MockPersonalDataManager());
}
};
diff --git a/chrome/browser/sync/profile_sync_service_mock.cc b/chrome/browser/sync/profile_sync_service_mock.cc
index 35d12c3..bfa9b01 100644
--- a/chrome/browser/sync/profile_sync_service_mock.cc
+++ b/chrome/browser/sync/profile_sync_service_mock.cc
@@ -48,7 +48,8 @@ TestingProfile* ProfileSyncServiceMock::MakeSignedInTestingProfile() {
}
// static
-KeyedService* ProfileSyncServiceMock::BuildMockProfileSyncService(
+scoped_ptr<KeyedService> ProfileSyncServiceMock::BuildMockProfileSyncService(
content::BrowserContext* profile) {
- return new ProfileSyncServiceMock(static_cast<Profile*>(profile));
+ return make_scoped_ptr(
+ new ProfileSyncServiceMock(static_cast<Profile*>(profile)));
}
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index 1592b07..96c39ee 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -35,7 +36,7 @@ class ProfileSyncServiceMock : public ProfileSyncService {
// Helper routine to be used in conjunction with
// BrowserContextKeyedServiceFactory::SetTestingFactory().
- static KeyedService* BuildMockProfileSyncService(
+ static scoped_ptr<KeyedService> BuildMockProfileSyncService(
content::BrowserContext* profile);
MOCK_METHOD0(DisableForUser, void());
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index 7926539..12c2f7e 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -121,16 +121,16 @@ class ProfileSyncServiceStartupTest : public testing::Test {
void TearDown() override { sync_->RemoveObserver(&observer_); }
- static KeyedService* BuildService(content::BrowserContext* browser_context) {
+ static scoped_ptr<KeyedService> BuildService(
+ content::BrowserContext* browser_context) {
Profile* profile = static_cast<Profile*>(browser_context);
- return new TestProfileSyncServiceNoBackup(
+ return make_scoped_ptr(new TestProfileSyncServiceNoBackup(
scoped_ptr<ProfileSyncComponentsFactory>(
new ProfileSyncComponentsFactoryMock()),
- profile,
- make_scoped_ptr(new SupervisedUserSigninManagerWrapper(
- profile, SigninManagerFactory::GetForProfile(profile))),
+ profile, make_scoped_ptr(new SupervisedUserSigninManagerWrapper(
+ profile, SigninManagerFactory::GetForProfile(profile))),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
- browser_sync::MANUAL_START);
+ browser_sync::MANUAL_START));
}
void CreateSyncService() {
@@ -217,7 +217,8 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
sync_->AddObserver(&observer_);
}
- static KeyedService* BuildCrosService(content::BrowserContext* context) {
+ static scoped_ptr<KeyedService> BuildCrosService(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
FakeSigninManagerForTesting* signin =
static_cast<FakeSigninManagerForTesting*>(
@@ -226,14 +227,12 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
ProfileOAuth2TokenService* oauth2_token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
EXPECT_TRUE(signin->IsAuthenticated());
- return new TestProfileSyncServiceNoBackup(
+ return make_scoped_ptr(new TestProfileSyncServiceNoBackup(
scoped_ptr<ProfileSyncComponentsFactory>(
new ProfileSyncComponentsFactoryMock()),
- profile,
- make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile,
- signin)),
- oauth2_token_service,
- browser_sync::AUTO_START);
+ profile, make_scoped_ptr(
+ new SupervisedUserSigninManagerWrapper(profile, signin)),
+ oauth2_token_service, browser_sync::AUTO_START));
}
};
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 912e6f7..0334d13 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -13,6 +13,7 @@
#include "base/callback.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
@@ -157,15 +158,15 @@ class HistoryServiceMock : public history::HistoryService {
scoped_refptr<history::HistoryBackend> backend_;
};
-KeyedService* BuildFakeProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildFakeProfileInvalidationProvider(
content::BrowserContext* context) {
- return new invalidation::ProfileInvalidationProvider(
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
scoped_ptr<invalidation::InvalidationService>(
- new invalidation::FakeInvalidationService));
+ new invalidation::FakeInvalidationService)));
}
-KeyedService* BuildHistoryService(content::BrowserContext* profile) {
- return new HistoryServiceMock;
+scoped_ptr<KeyedService> BuildHistoryService(content::BrowserContext* profile) {
+ return scoped_ptr<KeyedService>(new HistoryServiceMock);
}
class TestTypedUrlModelAssociator : public TypedUrlModelAssociator {
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index d25b538..d738304 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -160,11 +160,11 @@ ACTION_P(ReturnNewMockHostCollectDeleteDirParam, delete_dir_param) {
delete_dir_param);
}
-KeyedService* BuildFakeProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildFakeProfileInvalidationProvider(
content::BrowserContext* context) {
- return new invalidation::ProfileInvalidationProvider(
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
scoped_ptr<invalidation::InvalidationService>(
- new invalidation::FakeInvalidationService));
+ new invalidation::FakeInvalidationService)));
}
// A test harness that uses a real ProfileSyncService and in most cases a
diff --git a/chrome/browser/sync/startup_controller_unittest.cc b/chrome/browser/sync/startup_controller_unittest.cc
index 334333f..663b003 100644
--- a/chrome/browser/sync/startup_controller_unittest.cc
+++ b/chrome/browser/sync/startup_controller_unittest.cc
@@ -55,7 +55,7 @@ class StartupControllerTest : public testing::Test {
profile_.reset(new TestingProfile());
sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs()));
token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>(
- BuildFakeProfileOAuth2TokenService(profile_.get())));
+ BuildFakeProfileOAuth2TokenService(profile_.get()).release()));
signin_.reset(new FakeSupervisedUserSigninManagerWrapper());
ProfileSyncServiceStartBehavior behavior =
diff --git a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc
index 6f213a5..51b20e3 100644
--- a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc
+++ b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc
@@ -82,9 +82,9 @@ class FakeLoginUI : public LoginUIService::LoginUI {
int focus_ui_call_count_;
};
-KeyedService* BuildMockLoginUIService(
+scoped_ptr<KeyedService> BuildMockLoginUIService(
content::BrowserContext* profile) {
- return new FakeLoginUIService();
+ return make_scoped_ptr(new FakeLoginUIService());
}
class SyncErrorNotifierTest : public AshTestBase {
diff --git a/chrome/browser/sync/sync_global_error_unittest.cc b/chrome/browser/sync/sync_global_error_unittest.cc
index a7193b3..585d483 100644
--- a/chrome/browser/sync/sync_global_error_unittest.cc
+++ b/chrome/browser/sync/sync_global_error_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/sync/sync_global_error.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/sync/sync_error_controller.h"
@@ -47,8 +48,9 @@ class FakeLoginUI : public LoginUIService::LoginUI {
int focus_ui_call_count_;
};
-KeyedService* BuildMockLoginUIService(content::BrowserContext* profile) {
- return new FakeLoginUIService();
+scoped_ptr<KeyedService> BuildMockLoginUIService(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new FakeLoginUIService());
}
// Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index 68d93bf..77729564 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/process/launch.h"
@@ -142,34 +143,33 @@ void SetupNetworkCallback(
done->Signal();
}
-KeyedService* BuildFakeServerProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildFakeServerProfileInvalidationProvider(
content::BrowserContext* context) {
- return new invalidation::ProfileInvalidationProvider(
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
scoped_ptr<invalidation::InvalidationService>(
- new fake_server::FakeServerInvalidationService));
+ new fake_server::FakeServerInvalidationService)));
}
-KeyedService* BuildP2PProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildP2PProfileInvalidationProvider(
content::BrowserContext* context,
syncer::P2PNotificationTarget notification_target) {
Profile* profile = static_cast<Profile*>(context);
- return new invalidation::ProfileInvalidationProvider(
+ return make_scoped_ptr(new invalidation::ProfileInvalidationProvider(
scoped_ptr<invalidation::InvalidationService>(
new invalidation::P2PInvalidationService(
scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
LoginUIServiceFactory::GetForProfile(profile))),
- profile->GetRequestContext(),
- notification_target)));
+ profile->GetRequestContext(), notification_target))));
}
-KeyedService* BuildSelfNotifyingP2PProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildSelfNotifyingP2PProfileInvalidationProvider(
content::BrowserContext* context) {
return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_ALL);
}
-KeyedService* BuildRealisticP2PProfileInvalidationProvider(
+scoped_ptr<KeyedService> BuildRealisticP2PProfileInvalidationProvider(
content::BrowserContext* context) {
return BuildP2PProfileInvalidationProvider(context, syncer::NOTIFY_OTHERS);
}
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc
index 70e89dd..4ba4035 100644
--- a/chrome/browser/sync/test_profile_sync_service.cc
+++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/sync/test_profile_sync_service.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -127,20 +128,17 @@ TestProfileSyncService::~TestProfileSyncService() {
}
// static
-KeyedService* TestProfileSyncService::TestFactoryFunction(
+scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile);
ProfileOAuth2TokenService* oauth2_token_service =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- return new TestProfileSyncService(
+ return make_scoped_ptr(new TestProfileSyncService(
scoped_ptr<ProfileSyncComponentsFactory>(
new ProfileSyncComponentsFactoryMock()),
- profile,
- signin,
- oauth2_token_service,
- browser_sync::AUTO_START);
+ profile, signin, oauth2_token_service, browser_sync::AUTO_START));
}
// static
diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h
index be4af67..890f699 100644
--- a/chrome/browser/sync/test_profile_sync_service.h
+++ b/chrome/browser/sync/test_profile_sync_service.h
@@ -97,7 +97,8 @@ class TestProfileSyncService : public ProfileSyncService {
using ProfileSyncService::NotifyObservers;
protected:
- static KeyedService* TestFactoryFunction(content::BrowserContext* profile);
+ static scoped_ptr<KeyedService> TestFactoryFunction(
+ content::BrowserContext* profile);
// Return NULL handle to use in backend initialization to avoid receiving
// js messages on UI loop when it's being destroyed, which are not deleted
diff --git a/chrome/browser/themes/theme_syncable_service_unittest.cc b/chrome/browser/themes/theme_syncable_service_unittest.cc
index ca607be..ff0fd7e 100644
--- a/chrome/browser/themes/theme_syncable_service_unittest.cc
+++ b/chrome/browser/themes/theme_syncable_service_unittest.cc
@@ -113,8 +113,9 @@ class FakeThemeService : public ThemeService {
bool is_dirty_;
};
-KeyedService* BuildMockThemeService(content::BrowserContext* profile) {
- return new FakeThemeService;
+scoped_ptr<KeyedService> BuildMockThemeService(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new FakeThemeService);
}
scoped_refptr<extensions::Extension> MakeThemeExtension(
diff --git a/chrome/browser/ui/app_list/app_list_prefs_factory.cc b/chrome/browser/ui/app_list/app_list_prefs_factory.cc
index 80d8801..fcca1f0 100644
--- a/chrome/browser/ui/app_list/app_list_prefs_factory.cc
+++ b/chrome/browser/ui/app_list/app_list_prefs_factory.cc
@@ -27,8 +27,8 @@ AppListPrefsFactory* AppListPrefsFactory::GetInstance() {
void AppListPrefsFactory::SetInstanceForTesting(
content::BrowserContext* context,
- AppListPrefs* prefs) {
- Associate(context, prefs);
+ scoped_ptr<AppListPrefs> prefs) {
+ Associate(context, prefs.Pass());
}
AppListPrefsFactory::AppListPrefsFactory()
diff --git a/chrome/browser/ui/app_list/app_list_prefs_factory.h b/chrome/browser/ui/app_list/app_list_prefs_factory.h
index f6ebc85..febbff7 100644
--- a/chrome/browser/ui/app_list/app_list_prefs_factory.h
+++ b/chrome/browser/ui/app_list/app_list_prefs_factory.h
@@ -20,7 +20,7 @@ class AppListPrefsFactory : public BrowserContextKeyedServiceFactory {
static AppListPrefsFactory* GetInstance();
void SetInstanceForTesting(content::BrowserContext* context,
- AppListPrefs* prefs);
+ scoped_ptr<AppListPrefs> prefs);
private:
friend struct DefaultSingletonTraits<AppListPrefsFactory>;
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service_factory.cc b/chrome/browser/ui/app_list/app_list_syncable_service_factory.cc
index 3ef9d92..06e73ce 100644
--- a/chrome/browser/ui/app_list/app_list_syncable_service_factory.cc
+++ b/chrome/browser/ui/app_list/app_list_syncable_service_factory.cc
@@ -35,7 +35,7 @@ AppListSyncableServiceFactory* AppListSyncableServiceFactory::GetInstance() {
}
// static
-KeyedService* AppListSyncableServiceFactory::BuildInstanceFor(
+scoped_ptr<KeyedService> AppListSyncableServiceFactory::BuildInstanceFor(
content::BrowserContext* browser_context) {
Profile* profile = static_cast<Profile*>(browser_context);
#if defined(OS_CHROMEOS)
@@ -44,8 +44,8 @@ KeyedService* AppListSyncableServiceFactory::BuildInstanceFor(
#endif
VLOG(1) << "BuildInstanceFor: " << profile->GetDebugName()
<< " (" << profile << ")";
- return new AppListSyncableService(profile,
- extensions::ExtensionSystem::Get(profile));
+ return make_scoped_ptr(new AppListSyncableService(
+ profile, extensions::ExtensionSystem::Get(profile)));
}
AppListSyncableServiceFactory::AppListSyncableServiceFactory()
@@ -70,7 +70,7 @@ AppListSyncableServiceFactory::~AppListSyncableServiceFactory() {
KeyedService* AppListSyncableServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* browser_context) const {
- return BuildInstanceFor(static_cast<Profile*>(browser_context));
+ return BuildInstanceFor(static_cast<Profile*>(browser_context)).release();
}
void AppListSyncableServiceFactory::RegisterProfilePrefs(
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service_factory.h b/chrome/browser/ui/app_list/app_list_syncable_service_factory.h
index 9caac4d..feaa743 100644
--- a/chrome/browser/ui/app_list/app_list_syncable_service_factory.h
+++ b/chrome/browser/ui/app_list/app_list_syncable_service_factory.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SYNCABLE_SERVICE_FACTORY_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -24,7 +25,7 @@ class AppListSyncableServiceFactory : public BrowserContextKeyedServiceFactory {
static AppListSyncableServiceFactory* GetInstance();
- static KeyedService* BuildInstanceFor(
+ static scoped_ptr<KeyedService> BuildInstanceFor(
content::BrowserContext* browser_context);
private:
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc
index 37da1a4..8c3b077 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
@@ -33,11 +34,11 @@ const char* kUser = "user@test.com";
// we've ensured the profile has been shut down.
policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL;
-KeyedService* CreateTestPolicyCertService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> CreateTestPolicyCertService(
+ content::BrowserContext* context) {
return policy::PolicyCertService::CreateForTesting(
- kUser,
- g_policy_cert_verifier_for_factory,
- user_manager::UserManager::Get()).release();
+ kUser, g_policy_cert_verifier_for_factory,
+ user_manager::UserManager::Get());
}
} // namespace
diff --git a/chrome/browser/ui/bookmarks/bookmark_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_unittest.cc
index 27f14c7..db20131 100644
--- a/chrome/browser/ui/bookmarks/bookmark_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
@@ -57,12 +58,12 @@ class BookmarkInstantExtendedTest : public BrowserWithTestWindowTest {
}
private:
- static KeyedService* CreateTemplateURLService(
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
content::BrowserContext* profile) {
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
static_cast<Profile*>(profile)->GetPrefs(),
make_scoped_ptr(new SearchTermsData), NULL,
- scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure());
+ scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()));
}
DISALLOW_COPY_AND_ASSIGN(BookmarkInstantExtendedTest);
diff --git a/chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc b/chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc
index d3d9c4d..1bb6a04 100644
--- a/chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc
+++ b/chrome/browser/ui/startup/session_crashed_infobar_delegate_unittest.cc
@@ -51,9 +51,9 @@ class SessionCrashedInfoBarDelegateUnitTest : public BrowserWithTestWindowTest {
TEST_F(SessionCrashedInfoBarDelegateUnitTest, DetachingTabWithCrashedInfoBar) {
SessionServiceFactory::SetForTestProfile(
browser()->profile(),
- static_cast<SessionService*>(
+ make_scoped_ptr(static_cast<SessionService*>(
SessionServiceFactory::GetInstance()->BuildServiceInstanceFor(
- browser()->profile())));
+ browser()->profile()))));
// Create a browser which we can close during the test.
Browser::CreateParams params(browser()->profile(),
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc b/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
index 6d7734b..0f24ae2 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
@@ -48,8 +49,9 @@ class OneClickTestProfileSyncService : public TestProfileSyncService {
// Helper routine to be used in conjunction with
// BrowserContextKeyedServiceFactory::SetTestingFactory().
- static KeyedService* Build(content::BrowserContext* profile) {
- return new OneClickTestProfileSyncService(static_cast<Profile*>(profile));
+ static scoped_ptr<KeyedService> Build(content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new OneClickTestProfileSyncService(static_cast<Profile*>(profile)));
}
bool FirstSetupInProgress() const override {
@@ -103,8 +105,8 @@ class TestOneClickSigninSyncObserver : public OneClickSigninSyncObserver {
};
// A trivial factory to build a null service.
-KeyedService* BuildNullService(content::BrowserContext* context) {
- return NULL;
+scoped_ptr<KeyedService> BuildNullService(content::BrowserContext* context) {
+ return nullptr;
}
} // namespace
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
index a2720e7..f5c74b9 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter_unittest.cc
@@ -94,8 +94,10 @@ class OneClickSigninSyncStarterTest : public ChromeRenderViewHostTestHarness {
int succeeded_count_;
private:
- static KeyedService* BuildSigninManager(content::BrowserContext* profile) {
- return new FakeSigninManager(static_cast<Profile*>(profile));
+ static scoped_ptr<KeyedService> BuildSigninManager(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(
+ new FakeSigninManager(static_cast<Profile*>(profile)));
}
DISALLOW_COPY_AND_ASSIGN(OneClickSigninSyncStarterTest);
diff --git a/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc b/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
index 29057b7..f5bdf11 100644
--- a/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
+++ b/chrome/browser/ui/tabs/pinned_tab_service_unittest.cc
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/pinned_tab_codec.h"
@@ -18,8 +19,9 @@
namespace {
-KeyedService* BuildPinnedTabService(content::BrowserContext* profile) {
- return new PinnedTabService(static_cast<Profile*>(profile));
+scoped_ptr<KeyedService> BuildPinnedTabService(
+ content::BrowserContext* profile) {
+ return make_scoped_ptr(new PinnedTabService(static_cast<Profile*>(profile)));
}
PinnedTabService* BuildForProfile(Profile* profile) {
diff --git a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
index b37f5fc..422d36e 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_sub_menu_model_unittest.cc
@@ -8,6 +8,7 @@
#include <vector>
#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/sessions/persistent_tab_restore_service.h"
@@ -140,11 +141,10 @@ class RecentTabsSubMenuModelTest
content::RunAllBlockingPoolTasksUntilIdle();
}
- static KeyedService* GetTabRestoreService(
+ static scoped_ptr<KeyedService> GetTabRestoreService(
content::BrowserContext* browser_context) {
- // Ownership is tranfered to the profile.
- return new PersistentTabRestoreService(
- Profile::FromBrowserContext(browser_context), NULL);
+ return make_scoped_ptr(new PersistentTabRestoreService(
+ Profile::FromBrowserContext(browser_context), NULL));
}
browser_sync::OpenTabsUIDelegate* GetOpenTabsDelegate() {
@@ -258,7 +258,8 @@ TEST_F(RecentTabsSubMenuModelTest,
// Create a SessionService for the profile (profile owns the service) and add
// a window with a tab to this session.
SessionService* session_service = new SessionService(profile());
- SessionServiceFactory::SetForTestProfile(profile(), session_service);
+ SessionServiceFactory::SetForTestProfile(profile(),
+ make_scoped_ptr(session_service));
SessionID tab_id;
SessionID window_id;
session_service->SetWindowType(window_id,
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
index f84b7ab..2ab778e 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -124,12 +125,12 @@ class BookmarkBarViewTest : public BrowserWithTestWindowTest {
scoped_ptr<BookmarkBarView> bookmark_bar_view_;
private:
- static KeyedService* CreateTemplateURLService(
+ static scoped_ptr<KeyedService> CreateTemplateURLService(
content::BrowserContext* profile) {
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
static_cast<Profile*>(profile)->GetPrefs(),
make_scoped_ptr(new SearchTermsData), NULL,
- scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure());
+ scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()));
}
scoped_ptr<ScopedTestingLocalState> local_state_;
diff --git a/chrome/browser/ui/views/frame/test_with_browser_view.cc b/chrome/browser/ui/views/frame/test_with_browser_view.cc
index 843c172..5a284b1 100644
--- a/chrome/browser/ui/views/frame/test_with_browser_view.cc
+++ b/chrome/browser/ui/views/frame/test_with_browser_view.cc
@@ -31,10 +31,10 @@
namespace {
-// Caller owns the returned service.
-KeyedService* CreateTemplateURLService(content::BrowserContext* context) {
+scoped_ptr<KeyedService> CreateTemplateURLService(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new TemplateURLService(
+ return make_scoped_ptr(new TemplateURLService(
profile->GetPrefs(),
scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
WebDataServiceFactory::GetKeywordWebDataForProfile(
@@ -42,16 +42,17 @@ KeyedService* CreateTemplateURLService(content::BrowserContext* context) {
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
- nullptr, nullptr, base::Closure());
+ nullptr, nullptr, base::Closure()));
}
-KeyedService* CreateAutocompleteClassifier(content::BrowserContext* context) {
+scoped_ptr<KeyedService> CreateAutocompleteClassifier(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new AutocompleteClassifier(
+ return make_scoped_ptr(new AutocompleteClassifier(
make_scoped_ptr(new AutocompleteController(
profile, TemplateURLServiceFactory::GetForProfile(profile), nullptr,
AutocompleteClassifier::kDefaultOmniboxProviders)),
- scoped_ptr<AutocompleteSchemeClassifier>(new TestSchemeClassifier()));
+ scoped_ptr<AutocompleteSchemeClassifier>(new TestSchemeClassifier())));
}
} // namespace
diff --git a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
index 61faba5..2b4af17 100644
--- a/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
+++ b/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
@@ -441,8 +441,9 @@ class FakePrinterProviderAPI : public PrinterProviderAPI {
DISALLOW_COPY_AND_ASSIGN(FakePrinterProviderAPI);
};
-KeyedService* BuildTestingPrinterProviderAPI(content::BrowserContext* context) {
- return new FakePrinterProviderAPI();
+scoped_ptr<KeyedService> BuildTestingPrinterProviderAPI(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new FakePrinterProviderAPI());
}
class FakeDeviceClient : public device::DeviceClient {
diff --git a/chrome/test/base/chrome_render_view_host_test_harness.cc b/chrome/test/base/chrome_render_view_host_test_harness.cc
index ca3dce9..098403e 100644
--- a/chrome/test/base/chrome_render_view_host_test_harness.cc
+++ b/chrome/test/base/chrome_render_view_host_test_harness.cc
@@ -22,31 +22,36 @@
using content::RenderViewHostTester;
using content::RenderViewHostTestHarness;
-ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness() {
-}
-
-ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
-}
+namespace {
-TestingProfile* ChromeRenderViewHostTestHarness::profile() {
- return static_cast<TestingProfile*>(browser_context());
-}
-
-static KeyedService* BuildSigninManagerFake(content::BrowserContext* context) {
+scoped_ptr<KeyedService> BuildSigninManagerFake(
+ content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
#if defined (OS_CHROMEOS)
- SigninManagerBase* signin = new SigninManagerBase(
+ scoped_ptr<SigninManagerBase> signin(new SigninManagerBase(
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
- AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile));
+ AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile)));
signin->Initialize(NULL);
- return signin;
+ return signin.Pass();
#else
- FakeSigninManager* manager = new FakeSigninManager(profile);
+ scoped_ptr<FakeSigninManager> manager(new FakeSigninManager(profile));
manager->Initialize(g_browser_process->local_state());
- return manager;
+ return manager.Pass();
#endif
}
+} // namespace
+
+ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness() {
+}
+
+ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
+}
+
+TestingProfile* ChromeRenderViewHostTestHarness::profile() {
+ return static_cast<TestingProfile*>(browser_context());
+}
+
void ChromeRenderViewHostTestHarness::TearDown() {
RenderViewHostTestHarness::TearDown();
#if defined(USE_ASH)
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index ad46abc..0497fbd 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);
diff --git a/components/feedback/feedback_data_unittest.cc b/components/feedback/feedback_data_unittest.cc
index 141c174..e10bc2f 100644
--- a/components/feedback/feedback_data_unittest.cc
+++ b/components/feedback/feedback_data_unittest.cc
@@ -6,6 +6,7 @@
#include <set>
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
@@ -38,13 +39,11 @@ class MockUploader : public feedback::FeedbackUploader, public KeyedService {
MOCK_METHOD1(DispatchReport, void(const std::string&));
};
-MockUploader *g_uploader;
-
-KeyedService* CreateFeedbackUploaderService(content::BrowserContext* context) {
- if (!g_uploader)
- g_uploader = new MockUploader(context);
- EXPECT_CALL(*g_uploader, DispatchReport(testing::_)).Times(1);
- return g_uploader;
+scoped_ptr<KeyedService> CreateFeedbackUploaderService(
+ content::BrowserContext* context) {
+ scoped_ptr<MockUploader> uploader(new MockUploader(context));
+ EXPECT_CALL(*uploader, DispatchReport(testing::_)).Times(1);
+ return uploader.Pass();
}
scoped_ptr<std::string> MakeScoped(const char* str) {
@@ -108,8 +107,6 @@ TEST_F(FeedbackDataTest, ReportSending) {
Send();
RunMessageLoop();
EXPECT_TRUE(data_->IsDataComplete());
- delete g_uploader;
- g_uploader = NULL;
}
} // namespace feedback
diff --git a/components/feedback/feedback_uploader_unittest.cc b/components/feedback/feedback_uploader_unittest.cc
index 4985129..bd74485 100644
--- a/components/feedback/feedback_uploader_unittest.cc
+++ b/components/feedback/feedback_uploader_unittest.cc
@@ -7,6 +7,7 @@
#include <set>
#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
@@ -30,8 +31,9 @@ const char kReportFive[] = "five";
const base::TimeDelta kRetryDelayForTest =
base::TimeDelta::FromMilliseconds(100);
-KeyedService* CreateFeedbackUploaderService(content::BrowserContext* context) {
- return new feedback::FeedbackUploaderChrome(context);
+scoped_ptr<KeyedService> CreateFeedbackUploaderService(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new feedback::FeedbackUploaderChrome(context));
}
} // namespace
diff --git a/components/keyed_service/content/browser_context_keyed_service_factory.cc b/components/keyed_service/content/browser_context_keyed_service_factory.cc
index d7edb8e..db69459 100644
--- a/components/keyed_service/content/browser_context_keyed_service_factory.cc
+++ b/components/keyed_service/content/browser_context_keyed_service_factory.cc
@@ -85,10 +85,13 @@ void BrowserContextKeyedServiceFactory::BrowserContextDestroyed(
KeyedServiceFactory::ContextDestroyed(context);
}
-KeyedService* BrowserContextKeyedServiceFactory::BuildServiceInstanceFor(
+scoped_ptr<KeyedService>
+BrowserContextKeyedServiceFactory::BuildServiceInstanceFor(
base::SupportsUserData* context) const {
- return BuildServiceInstanceFor(
- static_cast<content::BrowserContext*>(context));
+ // TODO(isherman): The wrapped BuildServiceInstanceFor() should return a
+ // scoped_ptr as well.
+ return make_scoped_ptr(
+ BuildServiceInstanceFor(static_cast<content::BrowserContext*>(context)));
}
bool BrowserContextKeyedServiceFactory::IsOffTheRecord(
diff --git a/components/keyed_service/content/browser_context_keyed_service_factory.h b/components/keyed_service/content/browser_context_keyed_service_factory.h
index 24c3467..5543bbd 100644
--- a/components/keyed_service/content/browser_context_keyed_service_factory.h
+++ b/components/keyed_service/content/browser_context_keyed_service_factory.h
@@ -40,7 +40,7 @@ class KEYED_SERVICE_EXPORT BrowserContextKeyedServiceFactory
// A function that supplies the instance of a KeyedService for a given
// BrowserContext. This is used primarily for testing, where we want to feed
// a specific mock into the BCKSF system.
- typedef KeyedService* (*TestingFactoryFunction)(
+ typedef scoped_ptr<KeyedService>(*TestingFactoryFunction)(
content::BrowserContext* context);
// Associates |factory| with |context| so that |factory| is used to create
@@ -130,7 +130,7 @@ class KEYED_SERVICE_EXPORT BrowserContextKeyedServiceFactory
user_prefs::PrefRegistrySyncable* registry) {}
// KeyedServiceFactory:
- KeyedService* BuildServiceInstanceFor(
+ scoped_ptr<KeyedService> BuildServiceInstanceFor(
base::SupportsUserData* context) const final;
bool IsOffTheRecord(base::SupportsUserData* context) const final;
diff --git a/components/keyed_service/core/keyed_service_factory.cc b/components/keyed_service/core/keyed_service_factory.cc
index 1417bab..efc61f9 100644
--- a/components/keyed_service/core/keyed_service_factory.cc
+++ b/components/keyed_service/core/keyed_service_factory.cc
@@ -77,7 +77,7 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
// Create new object.
// Check to see if we have a per-context testing factory that we should use
// instead of default behavior.
- KeyedService* service = nullptr;
+ scoped_ptr<KeyedService> service;
const auto& jt = testing_factories_.find(context);
if (jt != testing_factories_.end()) {
if (jt->second) {
@@ -89,14 +89,14 @@ KeyedService* KeyedServiceFactory::GetServiceForContext(
service = BuildServiceInstanceFor(context);
}
- Associate(context, service);
- return service;
+ Associate(context, service.Pass());
+ return mapping_[context];
}
void KeyedServiceFactory::Associate(base::SupportsUserData* context,
- KeyedService* service) {
+ scoped_ptr<KeyedService> service) {
DCHECK(!ContainsKey(mapping_, context));
- mapping_.insert(std::make_pair(context, service));
+ mapping_.insert(std::make_pair(context, service.release()));
}
void KeyedServiceFactory::Disassociate(base::SupportsUserData* context) {
diff --git a/components/keyed_service/core/keyed_service_factory.h b/components/keyed_service/core/keyed_service_factory.h
index 9cc965b..e2ef4b8 100644
--- a/components/keyed_service/core/keyed_service_factory.h
+++ b/components/keyed_service/core/keyed_service_factory.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "components/keyed_service/core/keyed_service_base_factory.h"
#include "components/keyed_service/core/keyed_service_export.h"
@@ -32,7 +33,7 @@ class KEYED_SERVICE_EXPORT KeyedServiceFactory
// A function that supplies the instance of a KeyedService for a given
// |context|. This is used primarily for testing, where we want to feed
// a specific mock into the KeyedServiceFactory system.
- typedef KeyedService* (*TestingFactoryFunction)(
+ typedef scoped_ptr<KeyedService>(*TestingFactoryFunction)(
base::SupportsUserData* context);
// Associates |factory| with |context| so that |factory| is used to create
@@ -56,13 +57,14 @@ class KEYED_SERVICE_EXPORT KeyedServiceFactory
bool create);
// Maps |context| to |service| with debug checks to prevent duplication.
- void Associate(base::SupportsUserData* context, KeyedService* service);
+ void Associate(base::SupportsUserData* context,
+ scoped_ptr<KeyedService> service);
// Removes the mapping from |context| to a service.
void Disassociate(base::SupportsUserData* context);
// Returns a new KeyedService that will be associated with |context|.
- virtual KeyedService* BuildServiceInstanceFor(
+ virtual scoped_ptr<KeyedService> BuildServiceInstanceFor(
base::SupportsUserData* context) const = 0;
// Returns whether the |context| is off-the-record or not.
diff --git a/components/keyed_service/ios/browser_state_keyed_service_factory.cc b/components/keyed_service/ios/browser_state_keyed_service_factory.cc
index c527991..7c75278 100644
--- a/components/keyed_service/ios/browser_state_keyed_service_factory.cc
+++ b/components/keyed_service/ios/browser_state_keyed_service_factory.cc
@@ -74,9 +74,13 @@ void BrowserStateKeyedServiceFactory::BrowserStateDestroyed(
KeyedServiceFactory::ContextDestroyed(context);
}
-KeyedService* BrowserStateKeyedServiceFactory::BuildServiceInstanceFor(
+scoped_ptr<KeyedService>
+BrowserStateKeyedServiceFactory::BuildServiceInstanceFor(
base::SupportsUserData* context) const {
- return BuildServiceInstanceFor(static_cast<web::BrowserState*>(context));
+ // TODO(isherman): The wrapped BuildServiceInstanceFor() should return a
+ // scoped_ptr as well.
+ return make_scoped_ptr(
+ BuildServiceInstanceFor(static_cast<web::BrowserState*>(context)));
}
bool BrowserStateKeyedServiceFactory::IsOffTheRecord(
diff --git a/components/keyed_service/ios/browser_state_keyed_service_factory.h b/components/keyed_service/ios/browser_state_keyed_service_factory.h
index 7341aa1..69f28fd 100644
--- a/components/keyed_service/ios/browser_state_keyed_service_factory.h
+++ b/components/keyed_service/ios/browser_state_keyed_service_factory.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "components/keyed_service/core/keyed_service_export.h"
#include "components/keyed_service/core/keyed_service_factory.h"
@@ -30,7 +31,8 @@ class KEYED_SERVICE_EXPORT BrowserStateKeyedServiceFactory
// A function that supplies the instance of a KeyedService for a given
// BrowserState. This is used primarily for testing, where we want to feed
// a specific mock into the BSKSF system.
- typedef KeyedService* (*TestingFactoryFunction)(web::BrowserState* context);
+ typedef scoped_ptr<KeyedService>(*TestingFactoryFunction)(
+ web::BrowserState* context);
// Associates |factory| with |context| so that |factory| is used to create
// the KeyedService when requested. |factory| can be NULL to signal that
@@ -114,7 +116,7 @@ class KEYED_SERVICE_EXPORT BrowserStateKeyedServiceFactory
user_prefs::PrefRegistrySyncable* registry) {}
// KeyedServiceFactory:
- KeyedService* BuildServiceInstanceFor(
+ scoped_ptr<KeyedService> BuildServiceInstanceFor(
base::SupportsUserData* context) const final;
bool IsOffTheRecord(base::SupportsUserData* context) const final;
diff --git a/extensions/browser/api/api_resource_manager.h b/extensions/browser/api/api_resource_manager.h
index e90cb33c..29040d0 100644
--- a/extensions/browser/api/api_resource_manager.h
+++ b/extensions/browser/api/api_resource_manager.h
@@ -10,6 +10,7 @@
#include "base/containers/hash_tables.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/threading/non_thread_safe.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -119,13 +120,12 @@ class ApiResourceManager : public BrowserContextKeyedAPI,
process_manager_observer_.Add(ProcessManager::Get(context));
}
// For Testing.
- static ApiResourceManager<T, TestThreadTraits<T> >*
+ static scoped_ptr<ApiResourceManager<T, TestThreadTraits<T>>>
CreateApiResourceManagerForTest(content::BrowserContext* context,
content::BrowserThread::ID thread_id) {
TestThreadTraits<T>::thread_id_ = thread_id;
- ApiResourceManager<T, TestThreadTraits<T> >* manager =
- new ApiResourceManager<T, TestThreadTraits<T> >(context);
- return manager;
+ return make_scoped_ptr(
+ new ApiResourceManager<T, TestThreadTraits<T>>(context));
}
virtual ~ApiResourceManager() {
diff --git a/extensions/browser/api/idle/idle_api_unittest.cc b/extensions/browser/api/idle/idle_api_unittest.cc
index 2e0a604..31535bc 100644
--- a/extensions/browser/api/idle/idle_api_unittest.cc
+++ b/extensions/browser/api/idle/idle_api_unittest.cc
@@ -7,6 +7,7 @@
#include <limits.h>
#include <string>
+#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "extensions/browser/api/idle/idle_api_constants.h"
#include "extensions/browser/api/idle/idle_manager_factory.h"
@@ -111,8 +112,9 @@ ScopedListen::~ScopedListen() {
idle_manager_->OnListenerRemoved(details);
}
-KeyedService* IdleManagerTestFactory(content::BrowserContext* context) {
- return new IdleManager(context);
+scoped_ptr<KeyedService> IdleManagerTestFactory(
+ content::BrowserContext* context) {
+ return make_scoped_ptr(new IdleManager(context));
}
} // namespace
diff --git a/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc b/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
index de1afc3..6bd9fe1 100644
--- a/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
+++ b/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/api/api_resource_manager.h"
@@ -15,7 +16,7 @@
namespace extensions {
namespace core_api {
-static KeyedService* ApiResourceManagerTestFactory(
+static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
content::BrowserContext* context) {
content::BrowserThread::ID id;
CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
diff --git a/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc b/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
index 7fbc871..bf924e7 100644
--- a/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
+++ b/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/socket/socket.h"
@@ -14,7 +15,7 @@
namespace extensions {
namespace core_api {
-static KeyedService* ApiResourceManagerTestFactory(
+static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
content::BrowserContext* context) {
content::BrowserThread::ID id;
CHECK(content::BrowserThread::GetCurrentThreadIdentifier(&id));
diff --git a/extensions/browser/api/storage/storage_api_unittest.cc b/extensions/browser/api/storage/storage_api_unittest.cc
index 0d2dc4d..e8d309b 100644
--- a/extensions/browser/api/storage/storage_api_unittest.cc
+++ b/extensions/browser/api/storage/storage_api_unittest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/api/extensions_api_client.h"
@@ -29,14 +30,14 @@ namespace extensions {
namespace {
// Caller owns the returned object.
-KeyedService* CreateStorageFrontendForTesting(
+scoped_ptr<KeyedService> CreateStorageFrontendForTesting(
content::BrowserContext* context) {
return StorageFrontend::CreateForTesting(new LeveldbSettingsStorageFactory(),
context);
}
-KeyedService* BuildEventRouter(content::BrowserContext* profile) {
- return new extensions::EventRouter(profile, nullptr);
+scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* context) {
+ return make_scoped_ptr(new extensions::EventRouter(context, nullptr));
}
} // namespace
diff --git a/extensions/browser/api/storage/storage_frontend.cc b/extensions/browser/api/storage/storage_frontend.cc
index e94ecd8..dccd5e1 100644
--- a/extensions/browser/api/storage/storage_frontend.cc
+++ b/extensions/browser/api/storage/storage_frontend.cc
@@ -65,10 +65,10 @@ StorageFrontend* StorageFrontend::Get(BrowserContext* context) {
}
// static
-StorageFrontend* StorageFrontend::CreateForTesting(
+scoped_ptr<StorageFrontend> StorageFrontend::CreateForTesting(
const scoped_refptr<SettingsStorageFactory>& storage_factory,
BrowserContext* context) {
- return new StorageFrontend(storage_factory, context);
+ return make_scoped_ptr(new StorageFrontend(storage_factory, context));
}
StorageFrontend::StorageFrontend(BrowserContext* context)
diff --git a/extensions/browser/api/storage/storage_frontend.h b/extensions/browser/api/storage/storage_frontend.h
index 5e11b82..f1c8287 100644
--- a/extensions/browser/api/storage/storage_frontend.h
+++ b/extensions/browser/api/storage/storage_frontend.h
@@ -28,8 +28,8 @@ class StorageFrontend : public BrowserContextKeyedAPI {
// Returns the current instance for |context|.
static StorageFrontend* Get(content::BrowserContext* context);
- // Creates with a specific |storage_factory|. Caller owns the object.
- static StorageFrontend* CreateForTesting(
+ // Creates with a specific |storage_factory|.
+ static scoped_ptr<StorageFrontend> CreateForTesting(
const scoped_refptr<SettingsStorageFactory>& storage_factory,
content::BrowserContext* context);
diff --git a/extensions/browser/api/storage/storage_frontend_unittest.cc b/extensions/browser/api/storage/storage_frontend_unittest.cc
index b292244..75982ea 100644
--- a/extensions/browser/api/storage/storage_frontend_unittest.cc
+++ b/extensions/browser/api/storage/storage_frontend_unittest.cc
@@ -60,8 +60,8 @@ class ExtensionSettingsFrontendTest : public ExtensionsTest {
protected:
void ResetFrontend() {
storage_factory_->Reset(new LeveldbSettingsStorageFactory());
- frontend_.reset(
- StorageFrontend::CreateForTesting(storage_factory_, browser_context()));
+ frontend_ = StorageFrontend::CreateForTesting(storage_factory_,
+ browser_context()).Pass();
}
base::ScopedTempDir temp_dir_;
diff --git a/extensions/browser/extension_prefs_factory.cc b/extensions/browser/extension_prefs_factory.cc
index c07229cb..9e1d3ec 100644
--- a/extensions/browser/extension_prefs_factory.cc
+++ b/extensions/browser/extension_prefs_factory.cc
@@ -28,8 +28,9 @@ ExtensionPrefsFactory* ExtensionPrefsFactory::GetInstance() {
}
void ExtensionPrefsFactory::SetInstanceForTesting(
- content::BrowserContext* context, ExtensionPrefs* prefs) {
- Associate(context, prefs);
+ content::BrowserContext* context,
+ scoped_ptr<ExtensionPrefs> prefs) {
+ Associate(context, prefs.Pass());
}
ExtensionPrefsFactory::ExtensionPrefsFactory()
diff --git a/extensions/browser/extension_prefs_factory.h b/extensions/browser/extension_prefs_factory.h
index a83b4f3..9a6d921 100644
--- a/extensions/browser/extension_prefs_factory.h
+++ b/extensions/browser/extension_prefs_factory.h
@@ -19,8 +19,8 @@ class ExtensionPrefsFactory : public BrowserContextKeyedServiceFactory {
static ExtensionPrefsFactory* GetInstance();
- void SetInstanceForTesting(
- content::BrowserContext* context, ExtensionPrefs* prefs);
+ void SetInstanceForTesting(content::BrowserContext* context,
+ scoped_ptr<ExtensionPrefs> prefs);
private:
friend struct DefaultSingletonTraits<ExtensionPrefsFactory>;
diff --git a/extensions/browser/lazy_background_task_queue_unittest.cc b/extensions/browser/lazy_background_task_queue_unittest.cc
index dbe0794..917967d1 100644
--- a/extensions/browser/lazy_background_task_queue_unittest.cc
+++ b/extensions/browser/lazy_background_task_queue_unittest.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/lazy_background_task_queue.h"
#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/testing_pref_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/user_prefs/user_prefs.h"
@@ -52,8 +53,8 @@ class TestProcessManager : public ProcessManager {
DISALLOW_COPY_AND_ASSIGN(TestProcessManager);
};
-KeyedService* CreateTestProcessManager(BrowserContext* context) {
- return new TestProcessManager(context);
+scoped_ptr<KeyedService> CreateTestProcessManager(BrowserContext* context) {
+ return make_scoped_ptr(new TestProcessManager(context));
}
} // namespace