Commit 799a1fd2 authored by ricea's avatar ricea Committed by Commit bot

Re-write many calls to WrapUnique() with MakeUnique()

A mostly-automated change to convert instances of WrapUnique(new Foo(...)) to
MakeUnique<Foo>(...). See the thread at
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/iQgMedVA8-k
for background.

To avoid requiring too many manual fixups, the change skips some cases that are
frequently problematic. In particular, in methods named Foo::Method() it will
not try to change WrapUnique(new Foo()) to MakeUnique<Foo>(). This is because
Foo::Method() may be accessing an internal constructor of Foo.

Cases where MakeUnique<NestedClass>(...) is called within a method of
OuterClass are common but hard to detect automatically, so have been fixed-up
manually.

The only types of manual fix ups applied are:
1) Revert MakeUnique back to WrapUnique
2) Change NULL to nullptr in argument list (MakeUnique cannot forward NULL
   correctly)
3) Add base:: namespace qualifier where missing.

WrapUnique(new Foo) has not been converted to MakeUnique<Foo>() as this might
change behaviour if Foo does not have a user-defined constructor. For example,
WrapUnique(new int) creates an unitialised integer, but MakeUnique<int>()
creates an integer initialised to 0.

git cl format has been been run over the CL. Spot-checking has uncovered no
cases of mis-formatting.

  BUG=637812

Review-Url: https://codereview.chromium.org/2256813005
Cr-Commit-Position: refs/heads/master@{#413388}
parent c9462d4d
......@@ -191,7 +191,7 @@ void AbstractProfileSyncServiceTest::CreateSyncService(
profile_sync_service_bundle_.CreateBasicInitParams(
ProfileSyncService::AUTO_START, std::move(sync_client));
sync_service_ =
base::WrapUnique(new TestProfileSyncService(std::move(init_params)));
base::MakeUnique<TestProfileSyncService>(std::move(init_params));
SyncApiComponentFactoryMock* components =
profile_sync_service_bundle_.component_factory();
......
......@@ -294,9 +294,8 @@ ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost(
std::unique_ptr<sync_driver::LocalDeviceInfoProvider>
ProfileSyncComponentsFactoryImpl::CreateLocalDeviceInfoProvider() {
return base::WrapUnique(
new browser_sync::LocalDeviceInfoProviderImpl(channel_, version_,
is_tablet_));
return base::MakeUnique<browser_sync::LocalDeviceInfoProviderImpl>(
channel_, version_, is_tablet_);
}
class TokenServiceProvider
......
......@@ -412,16 +412,16 @@ class ProfileSyncServiceAutofillTest
data_type_thread()->task_runner());
web_database_.reset(new WebDatabaseFake(&autofill_table_));
web_data_wrapper_ = base::WrapUnique(new MockWebDataServiceWrapper(
web_data_wrapper_ = base::MakeUnique<MockWebDataServiceWrapper>(
new WebDataServiceFake(base::ThreadTaskRunnerHandle::Get(),
data_type_thread()->task_runner()),
new TokenWebDataServiceFake(base::ThreadTaskRunnerHandle::Get(),
data_type_thread()->task_runner())));
data_type_thread()->task_runner()));
web_data_service_ = static_cast<WebDataServiceFake*>(
web_data_wrapper_->GetAutofillWebData().get());
web_data_service_->SetDatabase(web_database_.get());
personal_data_manager_ = base::WrapUnique(new MockPersonalDataManager());
personal_data_manager_ = base::MakeUnique<MockPersonalDataManager>();
EXPECT_CALL(personal_data_manager(), LoadProfiles());
EXPECT_CALL(personal_data_manager(), LoadCreditCards());
......
......@@ -437,8 +437,8 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
// will be deleted before starting up the BookmarkModel.
std::unique_ptr<BookmarkModel> CreateBookmarkModel(bool delete_bookmarks) {
const base::FilePath& data_path = data_dir_.path();
auto model = base::WrapUnique(new BookmarkModel(
base::WrapUnique(new bookmarks::TestBookmarkClient())));
auto model = base::MakeUnique<BookmarkModel>(
base::WrapUnique(new bookmarks::TestBookmarkClient()));
managed_bookmark_service_->BookmarkModelCreated(model.get());
int64_t next_id = 0;
static_cast<bookmarks::TestBookmarkClient*>(model->client())
......@@ -787,8 +787,8 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
void delete_change_processor() { change_processor_.reset(); }
void ResetChangeProcessor() {
change_processor_ = base::WrapUnique(new BookmarkChangeProcessor(
sync_client_.get(), model_associator_.get(), &mock_error_handler_));
change_processor_ = base::MakeUnique<BookmarkChangeProcessor>(
sync_client_.get(), model_associator_.get(), &mock_error_handler_);
}
syncer::DataTypeErrorHandlerMock* mock_error_handler() {
......
......@@ -197,8 +197,8 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
void CreateHistoryService() {
history_backend_ = new HistoryBackendMock();
syncable_service_ = base::WrapUnique(
new TestTypedUrlSyncableService(history_backend_.get()));
syncable_service_ =
base::MakeUnique<TestTypedUrlSyncableService>(history_backend_.get());
}
void DeleteSyncableService() {
......
......@@ -217,14 +217,14 @@ void ProfileSyncServiceBundle::SyncClientBuilder::SetBookmarkModelCallback(
std::unique_ptr<sync_driver::FakeSyncClient>
ProfileSyncServiceBundle::SyncClientBuilder::Build() {
return base::WrapUnique(new BundleSyncClient(
return base::MakeUnique<BundleSyncClient>(
bundle_->component_factory(), bundle_->pref_service(),
bundle_->sync_sessions_client(), personal_data_manager_,
get_syncable_service_callback_, get_sync_service_callback_,
get_bookmark_model_callback_,
activate_model_creation_ ? bundle_->db_thread() : nullptr,
activate_model_creation_ ? base::ThreadTaskRunnerHandle::Get() : nullptr,
history_service_));
history_service_);
}
ProfileSyncServiceBundle::ProfileSyncServiceBundle()
......@@ -257,7 +257,7 @@ ProfileSyncService::InitParams ProfileSyncServiceBundle::CreateBasicInitParams(
init_params.start_behavior = start_behavior;
init_params.sync_client = std::move(sync_client);
init_params.signin_wrapper =
base::WrapUnique(new SigninManagerWrapper(signin_manager()));
base::MakeUnique<SigninManagerWrapper>(signin_manager());
init_params.oauth2_token_service = auth_service();
init_params.network_time_update_callback =
base::Bind(&EmptyNetworkTimeUpdate);
......
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