Commit b92e241e authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[Background Sync] Remove more instances of raw new.

This CL weeds out more instances of raw new and replaces them with
std::make_unique<>, wherever appropriate, per this guideline:
https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-dos-and-donts.md#use-and-instead-of-bare

In one instance, there's no need of a pointer, so it's been removed.

Bug: 932591
Change-Id: I0b99d8ebc468bd7c496b7d50844f46fea2d68b44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529090Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641686}
parent 4c1c5d88
...@@ -48,8 +48,9 @@ class BackgroundSyncControllerImplTest : public testing::Test { ...@@ -48,8 +48,9 @@ class BackgroundSyncControllerImplTest : public testing::Test {
protected: protected:
BackgroundSyncControllerImplTest() BackgroundSyncControllerImplTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
controller_( controller_(std::make_unique<TestBackgroundSyncControllerImpl>(
new TestBackgroundSyncControllerImpl(&profile_, &rappor_service_)) { &profile_,
&rappor_service_)) {
ResetFieldTrialList(); ResetFieldTrialList();
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
BackgroundSyncLauncherAndroid::SetPlayServicesVersionCheckDisabledForTests( BackgroundSyncLauncherAndroid::SetPlayServicesVersionCheckDisabledForTests(
...@@ -58,8 +59,8 @@ class BackgroundSyncControllerImplTest : public testing::Test { ...@@ -58,8 +59,8 @@ class BackgroundSyncControllerImplTest : public testing::Test {
} }
void ResetFieldTrialList() { void ResetFieldTrialList() {
field_trial_list_.reset( field_trial_list_ =
new base::FieldTrialList(nullptr /* entropy provider */)); std::make_unique<base::FieldTrialList>(nullptr /* entropy provider */);
variations::testing::ClearAllVariationParams(); variations::testing::ClearAllVariationParams();
base::FieldTrialList::CreateFieldTrial( base::FieldTrialList::CreateFieldTrial(
BackgroundSyncControllerImpl::kFieldTrialName, kFieldTrialGroup); BackgroundSyncControllerImpl::kFieldTrialName, kFieldTrialGroup);
......
...@@ -166,8 +166,8 @@ class BackgroundSyncBrowserTest : public ContentBrowserTest { ...@@ -166,8 +166,8 @@ class BackgroundSyncBrowserTest : public ContentBrowserTest {
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
https_server_.reset( https_server_ = std::make_unique<net::EmbeddedTestServer>(
new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); net::EmbeddedTestServer::TYPE_HTTPS);
https_server_->ServeFilesFromSourceDirectory("content/test/data"); https_server_->ServeFilesFromSourceDirectory("content/test/data");
ASSERT_TRUE(https_server_->Start()); ASSERT_TRUE(https_server_->Start());
......
...@@ -88,8 +88,7 @@ void ErrorAndRegistrationListCallback( ...@@ -88,8 +88,7 @@ void ErrorAndRegistrationListCallback(
class BackgroundSyncServiceImplTest : public testing::Test { class BackgroundSyncServiceImplTest : public testing::Test {
public: public:
BackgroundSyncServiceImplTest() BackgroundSyncServiceImplTest()
: thread_bundle_( : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {
new TestBrowserThreadBundle(TestBrowserThreadBundle::IO_MAINLOOP)) {
default_sync_registration_ = blink::mojom::SyncRegistrationOptions::New(); default_sync_registration_ = blink::mojom::SyncRegistrationOptions::New();
} }
...@@ -118,10 +117,10 @@ class BackgroundSyncServiceImplTest : public testing::Test { ...@@ -118,10 +117,10 @@ class BackgroundSyncServiceImplTest : public testing::Test {
// SetUp helper methods // SetUp helper methods
void CreateTestHelper() { void CreateTestHelper() {
embedded_worker_helper_.reset( embedded_worker_helper_ =
new EmbeddedWorkerTestHelper(base::FilePath())); std::make_unique<EmbeddedWorkerTestHelper>((base::FilePath()));
std::unique_ptr<MockPermissionManager> mock_permission_manager( std::unique_ptr<MockPermissionManager> mock_permission_manager =
new testing::NiceMock<MockPermissionManager>()); std::make_unique<testing::NiceMock<MockPermissionManager>>();
ON_CALL(*mock_permission_manager, ON_CALL(*mock_permission_manager,
GetPermissionStatus(PermissionType::BACKGROUND_SYNC, _, _)) GetPermissionStatus(PermissionType::BACKGROUND_SYNC, _, _))
.WillByDefault( .WillByDefault(
...@@ -211,7 +210,7 @@ class BackgroundSyncServiceImplTest : public testing::Test { ...@@ -211,7 +210,7 @@ class BackgroundSyncServiceImplTest : public testing::Test {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_; std::unique_ptr<EmbeddedWorkerTestHelper> embedded_worker_helper_;
std::unique_ptr<StoragePartitionImpl> storage_partition_impl_; std::unique_ptr<StoragePartitionImpl> storage_partition_impl_;
scoped_refptr<BackgroundSyncContextImpl> background_sync_context_; scoped_refptr<BackgroundSyncContextImpl> background_sync_context_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment