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

Issue 2341693002: Re-write many calls to WrapUnique() with MakeUnique() (Closed)

Created:
4 years, 3 months ago by Adam Rice
Modified:
4 years, 3 months ago
Reviewers:
sky
CC:
chromium-reviews, extensions-reviews_chromium.org, cbentzel+watch_chromium.org, tfarina, grt+watch_chromium.org, samuong+watch_chromium.org, devtools-reviews_chromium.org, pennymac+watch_chromium.org, wfh+watch_chromium.org, chromium-apps-reviews_chromium.org, pfeldman
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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. Miscellaneous minor cleanups were applied. BUG=637812 Committed: https://crrev.com/0c39556939fdc7a522d9092f8a45e783550322c8 Cr-Commit-Position: refs/heads/master@{#418795}

Patch Set 1 #

Patch Set 2 : Fix one under-change and one mysterious revert #

Total comments: 10

Patch Set 3 : Nitpick changes #

Patch Set 4 : Change std::string() back to "" to fix compile #

Unified diffs Side-by-side diffs Delta from patch set Stats (+77 lines, -77 lines) Patch
M chrome/common/chrome_content_client.cc View 1 2 1 chunk +2 lines, -3 lines 0 comments Download
M chrome/common/extensions/api/extension_action/page_action_manifest_unittest.cc View 1 2 1 chunk +3 lines, -4 lines 0 comments Download
M chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc View 3 1 chunk +1 line, -1 line 0 comments Download
M chrome/installer/util/beacons.cc View 1 chunk +9 lines, -9 lines 0 comments Download
M chrome/installer/util/browser_distribution.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/installer/util/lzma_file_allocator_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/installer/util/scoped_user_protocol_entry_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/renderer/extensions/extension_localization_peer.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/renderer/extensions/extension_localization_peer_unittest.cc View 1 chunk +4 lines, -4 lines 0 comments Download
M chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc View 4 chunks +12 lines, -13 lines 0 comments Download
M chrome/renderer/pepper/pepper_helper.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/renderer/security_filter_peer.cc View 4 chunks +8 lines, -8 lines 0 comments Download
M chrome/service/service_process.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/service/service_process_prefs.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/test/base/chrome_render_view_test.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/test/base/test_browser_window.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/base/testing_profile.cc View 1 4 chunks +10 lines, -10 lines 0 comments Download
M chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/chromedriver/commands.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/chromedriver/net/url_request_context_getter.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/utility/importer/edge_database_reader_win.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/utility/safe_browsing/mac/hfs.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/utility/safe_browsing/mac/udif.cc View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 25 (15 generated)
Adam Rice
I checked for unmodified calls to WrapUnique(). There are only two and they are both ...
4 years, 3 months ago (2016-09-14 09:54:10 UTC) #6
sky
LGTM https://codereview.chromium.org/2341693002/diff/20001/chrome/common/chrome_content_client.cc File chrome/common/chrome_content_client.cc (right): https://codereview.chromium.org/2341693002/diff/20001/chrome/common/chrome_content_client.cc#newcode723 chrome/common/chrome_content_client.cc:723: if (!origin_trial_policy_) { optional: while here remove {} ...
4 years, 3 months ago (2016-09-14 17:46:43 UTC) #9
Adam Rice
https://codereview.chromium.org/2341693002/diff/20001/chrome/common/chrome_content_client.cc File chrome/common/chrome_content_client.cc (right): https://codereview.chromium.org/2341693002/diff/20001/chrome/common/chrome_content_client.cc#newcode723 chrome/common/chrome_content_client.cc:723: if (!origin_trial_policy_) { On 2016/09/14 17:46:42, sky wrote: > ...
4 years, 3 months ago (2016-09-15 02:05:55 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2341693002/40001
4 years, 3 months ago (2016-09-15 04:20:26 UTC) #14
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/224814) linux_chromium_chromeos_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, ...
4 years, 3 months ago (2016-09-15 04:23:05 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2341693002/60001
4 years, 3 months ago (2016-09-15 06:10:28 UTC) #19
Adam Rice
https://codereview.chromium.org/2341693002/diff/20001/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc File chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc (right): https://codereview.chromium.org/2341693002/diff/20001/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc#newcode134 chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc:134: base::MakeUnique<ManifestData>(manifest->CreateDeepCopy(), "")); On 2016/09/15 02:05:55, Adam Rice wrote: > ...
4 years, 3 months ago (2016-09-15 06:18:56 UTC) #20
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 3 months ago (2016-09-15 06:47:51 UTC) #22
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/0c39556939fdc7a522d9092f8a45e783550322c8 Cr-Commit-Position: refs/heads/master@{#418795}
4 years, 3 months ago (2016-09-15 06:51:02 UTC) #24
sky
4 years, 3 months ago (2016-09-15 16:57:28 UTC) #25
Message was sent while issue was closed.
https://codereview.chromium.org/2341693002/diff/20001/chrome/common/extension...
File
chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
(right):

https://codereview.chromium.org/2341693002/diff/20001/chrome/common/extension...
chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc:134:
base::MakeUnique<ManifestData>(manifest->CreateDeepCopy(), ""));
On 2016/09/15 06:18:56, Adam Rice wrote:
> On 2016/09/15 02:05:55, Adam Rice wrote:
> > On 2016/09/14 17:46:43, sky wrote:
> > > "" -> std::string()
> > 
> > Done.
> 
> It didn't compile. The parameter type is actually const char*. I changed it
> back.

My mistake. Sorry.

Powered by Google App Engine
This is Rietveld 408576698