Commit 04dff7f2 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/2254973004
Cr-Commit-Position: refs/heads/master@{#413394}
parent 5c7b49db
...@@ -232,8 +232,7 @@ void AudioEncoderResource::OnPluginMsgInitializeReply( ...@@ -232,8 +232,7 @@ void AudioEncoderResource::OnPluginMsgInitializeReply(
if (!params.TakeSharedMemoryHandleAtIndex(0, &buffer_handle) || if (!params.TakeSharedMemoryHandleAtIndex(0, &buffer_handle) ||
!audio_buffer_manager_.SetBuffers( !audio_buffer_manager_.SetBuffers(
audio_buffer_count, audio_buffer_size, audio_buffer_count, audio_buffer_size,
base::WrapUnique(new base::SharedMemory(buffer_handle, false)), base::MakeUnique<base::SharedMemory>(buffer_handle, false), true)) {
true)) {
RunCallback(&initialize_callback_, PP_ERROR_NOMEMORY); RunCallback(&initialize_callback_, PP_ERROR_NOMEMORY);
return; return;
} }
...@@ -242,8 +241,7 @@ void AudioEncoderResource::OnPluginMsgInitializeReply( ...@@ -242,8 +241,7 @@ void AudioEncoderResource::OnPluginMsgInitializeReply(
if (!params.TakeSharedMemoryHandleAtIndex(1, &buffer_handle) || if (!params.TakeSharedMemoryHandleAtIndex(1, &buffer_handle) ||
!bitstream_buffer_manager_.SetBuffers( !bitstream_buffer_manager_.SetBuffers(
bitstream_buffer_count, bitstream_buffer_size, bitstream_buffer_count, bitstream_buffer_size,
base::WrapUnique(new base::SharedMemory(buffer_handle, false)), base::MakeUnique<base::SharedMemory>(buffer_handle, false), false)) {
false)) {
RunCallback(&initialize_callback_, PP_ERROR_NOMEMORY); RunCallback(&initialize_callback_, PP_ERROR_NOMEMORY);
return; return;
} }
......
...@@ -73,7 +73,7 @@ const std::string* FlashFontFileResource::AddFontTable( ...@@ -73,7 +73,7 @@ const std::string* FlashFontFileResource::AddFontTable(
uint32_t table, uint32_t table,
const std::string& contents) { const std::string& contents) {
FontTableMap::const_iterator it = FontTableMap::const_iterator it =
font_tables_.set(table, base::WrapUnique(new std::string(contents))); font_tables_.set(table, base::MakeUnique<std::string>(contents));
return it->second; return it->second;
} }
......
...@@ -351,8 +351,7 @@ void VideoEncoderResource::OnPluginMsgGetVideoFramesReply( ...@@ -351,8 +351,7 @@ void VideoEncoderResource::OnPluginMsgGetVideoFramesReply(
if (!buffer_manager_.SetBuffers( if (!buffer_manager_.SetBuffers(
frame_count, frame_length, frame_count, frame_length,
base::WrapUnique(new base::SharedMemory(buffer_handle, false)), base::MakeUnique<base::SharedMemory>(buffer_handle, false), true)) {
true)) {
NotifyError(PP_ERROR_FAILED); NotifyError(PP_ERROR_FAILED);
return; return;
} }
......
...@@ -207,10 +207,10 @@ void VpnProviderResource::OnPluginMsgBindReply( ...@@ -207,10 +207,10 @@ void VpnProviderResource::OnPluginMsgBindReply(
NOTREACHED(); NOTREACHED();
return; return;
} }
send_packet_buffer_ = base::WrapUnique(new ppapi::VpnProviderSharedBuffer( send_packet_buffer_ = base::MakeUnique<ppapi::VpnProviderSharedBuffer>(
queue_size, max_packet_size, std::move(send_shm))); queue_size, max_packet_size, std::move(send_shm));
recv_packet_buffer_ = base::WrapUnique(new ppapi::VpnProviderSharedBuffer( recv_packet_buffer_ = base::MakeUnique<ppapi::VpnProviderSharedBuffer>(
queue_size, max_packet_size, std::move(receive_shm))); queue_size, max_packet_size, std::move(receive_shm));
bound_ = (result == PP_OK); bound_ = (result == PP_OK);
} }
......
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