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.
Additional changes: Four C-style casts have been changed to static_cast. One instance of using "" to construct an empty string has been changed to std::string().
BUG=637812
Review-Url: https://codereview.chromium.org/2334613003
Cr-Commit-Position: refs/heads/master@{#418180}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 99dea1d..7abddbb 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -507,8 +507,9 @@
DCHECK(CalledOnValidThread());
if (!metrics_services_manager_) {
metrics_services_manager_.reset(
- new metrics_services_manager::MetricsServicesManager(base::WrapUnique(
- new ChromeMetricsServicesManagerClient(local_state()))));
+ new metrics_services_manager::MetricsServicesManager(
+ base::MakeUnique<ChromeMetricsServicesManagerClient>(
+ local_state())));
}
return metrics_services_manager_.get();
}