Convert //base to use std::unique_ptr
With bonus IWYU fixes that weren't caught by local android gn, cros gn,
linux gn, mac gyp, and win gyp builds.
BUG=554298
TBR=brettw@chromium.org
Review URL: https://codereview.chromium.org/1852433005
Cr-Commit-Position: refs/heads/master@{#385011}
CrOS-Libchrome-Original-Commit: 093de9b30c0ba6ded896506a297314e5ed818b89
diff --git a/base/android/application_status_listener_unittest.cc b/base/android/application_status_listener_unittest.cc
index ce78bf9..896bbe8 100644
--- a/base/android/application_status_listener_unittest.cc
+++ b/base/android/application_status_listener_unittest.cc
@@ -3,10 +3,12 @@
// found in the LICENSE file.
#include "base/android/application_status_listener.h"
+
+#include <memory>
+
#include "base/bind.h"
#include "base/callback_forward.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
@@ -92,7 +94,7 @@
base::WaitableEvent event_;
base::Thread thread_;
base::MessageLoop main_;
- scoped_ptr<ApplicationStatusListener> listener_;
+ std::unique_ptr<ApplicationStatusListener> listener_;
};
} // namespace
diff --git a/base/android/java_handler_thread.h b/base/android/java_handler_thread.h
index 07715a8..1709ff4 100644
--- a/base/android/java_handler_thread.h
+++ b/base/android/java_handler_thread.h
@@ -7,8 +7,9 @@
#include <jni.h>
+#include <memory>
+
#include "base/android/scoped_java_ref.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
@@ -43,7 +44,7 @@
static bool RegisterBindings(JNIEnv* env);
private:
- scoped_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
ScopedJavaGlobalRef<jobject> java_thread_;
};
diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc
index 8194dc1..6348d49 100644
--- a/base/android/record_histogram.cc
+++ b/base/android/record_histogram.cc
@@ -314,7 +314,7 @@
return 0;
}
- scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
return samples->GetCount(static_cast<int>(sample));
}
diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc
index a436a4d..a60e112 100644
--- a/base/base_paths_posix.cc
+++ b/base/base_paths_posix.cc
@@ -6,18 +6,19 @@
// don't have their own base_paths_OS.cc implementation (i.e. all but Mac and
// Android).
+#include "base/base_paths.h"
+
#include <limits.h>
#include <stddef.h>
+#include <memory>
#include <ostream>
#include <string>
-#include "base/base_paths.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/nix/xdg_util.h"
#include "base/path_service.h"
#include "base/process/process_metrics.h"
@@ -79,7 +80,7 @@
case base::DIR_SOURCE_ROOT: {
// Allow passing this in the environment, for more flexibility in build
// tree configurations (sub-project builds, gyp --output_dir, etc.)
- scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string cr_source_root;
if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) {
path = FilePath(cr_source_root);
@@ -106,7 +107,7 @@
*result = base::nix::GetXDGUserDirectory("DESKTOP", "Desktop");
return true;
case base::DIR_CACHE: {
- scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME",
".cache"));
*result = cache_dir;
diff --git a/base/bind_helpers.h b/base/bind_helpers.h
index d19c749..590d788 100644
--- a/base/bind_helpers.h
+++ b/base/bind_helpers.h
@@ -121,10 +121,11 @@
//
// EXAMPLE OF Passed():
//
-// void TakesOwnership(scoped_ptr<Foo> arg) { }
-// scoped_ptr<Foo> CreateFoo() { return scoped_ptr<Foo>(new Foo()); }
+// void TakesOwnership(std::unique_ptr<Foo> arg) { }
+// std::unique_ptr<Foo> CreateFoo() { return std::unique_ptr<Foo>(new Foo());
+// }
//
-// scoped_ptr<Foo> f(new Foo());
+// std::unique_ptr<Foo> f(new Foo());
//
// // |cb| is given ownership of Foo(). |f| is now NULL.
// // You can use std::move(f) in place of &f, but it's more verbose.
@@ -353,7 +354,7 @@
// An alternate implementation is to avoid the destructive copy, and instead
// specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to
-// a class that is essentially a scoped_ptr<>.
+// a class that is essentially a std::unique_ptr<>.
//
// The current implementation has the benefit though of leaving ParamTraits<>
// fully in callback_internal.h as well as avoiding type conversions during
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index daf8c12..f827801 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -10,8 +10,8 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -817,7 +817,7 @@
};
using MoveOnlyTypesToTest =
- ::testing::Types<scoped_ptr<DeleteCounter>,
+ ::testing::Types<std::unique_ptr<DeleteCounter>,
std::unique_ptr<DeleteCounter>,
std::unique_ptr<DeleteCounter, CustomDeleter>>;
TYPED_TEST_CASE(BindMoveOnlyTypeTest, MoveOnlyTypesToTest);
@@ -874,23 +874,23 @@
EXPECT_EQ(1, deletes);
}
-void VerifyVector(const std::vector<scoped_ptr<int>>& v) {
+void VerifyVector(const std::vector<std::unique_ptr<int>>& v) {
ASSERT_EQ(1u, v.size());
EXPECT_EQ(12345, *v[0]);
}
-std::vector<scoped_ptr<int>> AcceptAndReturnMoveOnlyVector(
- std::vector<scoped_ptr<int>> v) {
+std::vector<std::unique_ptr<int>> AcceptAndReturnMoveOnlyVector(
+ std::vector<std::unique_ptr<int>> v) {
VerifyVector(v);
return v;
}
// Test that a vector containing move-only types can be used with Callback.
TEST_F(BindTest, BindMoveOnlyVector) {
- using MoveOnlyVector = std::vector<scoped_ptr<int>>;
+ using MoveOnlyVector = std::vector<std::unique_ptr<int>>;
MoveOnlyVector v;
- v.push_back(make_scoped_ptr(new int(12345)));
+ v.push_back(WrapUnique(new int(12345)));
// Early binding should work:
base::Callback<MoveOnlyVector()> bound_cb =
diff --git a/base/callback.h b/base/callback.h
index c04e90d..abb907b 100644
--- a/base/callback.h
+++ b/base/callback.h
@@ -187,8 +187,8 @@
//
// PASSING PARAMETERS AS A scoped_ptr
//
-// void TakesOwnership(scoped_ptr<Foo> arg) {}
-// scoped_ptr<Foo> f(new Foo);
+// void TakesOwnership(std::unique_ptr<Foo> arg) {}
+// std::unique_ptr<Foo> f(new Foo);
// // f becomes null during the following call.
// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f));
//
diff --git a/base/callback_internal.h b/base/callback_internal.h
index 1670557..7bff0ba 100644
--- a/base/callback_internal.h
+++ b/base/callback_internal.h
@@ -18,7 +18,6 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
namespace internal {
diff --git a/base/callback_list.h b/base/callback_list.h
index 7d6a478..848c900 100644
--- a/base/callback_list.h
+++ b/base/callback_list.h
@@ -6,13 +6,13 @@
#define BASE_CALLBACK_LIST_H_
#include <list>
+#include <memory>
#include "base/callback.h"
#include "base/callback_internal.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
// OVERVIEW:
//
@@ -29,7 +29,7 @@
//
// typedef base::Callback<void(const Foo&)> OnFooCallback;
//
-// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
+// std::unique_ptr<base::CallbackList<void(const Foo&)>::Subscription>
// RegisterCallback(const OnFooCallback& cb) {
// return callback_list_.Add(cb);
// }
@@ -62,7 +62,7 @@
// // Do something.
// }
//
-// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
+// std::unique_ptr<base::CallbackList<void(const Foo&)>::Subscription>
// foo_subscription_;
//
// DISALLOW_COPY_AND_ASSIGN(MyWidgetListener);
@@ -103,9 +103,9 @@
// Add a callback to the list. The callback will remain registered until the
// returned Subscription is destroyed, which must occur before the
// CallbackList is destroyed.
- scoped_ptr<Subscription> Add(const CallbackType& cb) WARN_UNUSED_RESULT {
+ std::unique_ptr<Subscription> Add(const CallbackType& cb) WARN_UNUSED_RESULT {
DCHECK(!cb.is_null());
- return scoped_ptr<Subscription>(
+ return std::unique_ptr<Subscription>(
new Subscription(this, callbacks_.insert(callbacks_.end(), cb)));
}
diff --git a/base/callback_list_unittest.cc b/base/callback_list_unittest.cc
index 010efc5..62081e9 100644
--- a/base/callback_list_unittest.cc
+++ b/base/callback_list_unittest.cc
@@ -4,12 +4,12 @@
#include "base/callback_list.h"
+#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -38,7 +38,7 @@
removal_subscription_.reset();
}
void SetSubscriptionToRemove(
- scoped_ptr<CallbackList<void(void)>::Subscription> sub) {
+ std::unique_ptr<CallbackList<void(void)>::Subscription> sub) {
removal_subscription_ = std::move(sub);
}
@@ -46,7 +46,7 @@
private:
int total_;
- scoped_ptr<CallbackList<void(void)>::Subscription> removal_subscription_;
+ std::unique_ptr<CallbackList<void(void)>::Subscription> removal_subscription_;
DISALLOW_COPY_AND_ASSIGN(Remover);
};
@@ -74,7 +74,7 @@
bool added_;
int total_;
CallbackList<void(void)>* cb_reg_;
- scoped_ptr<CallbackList<void(void)>::Subscription> subscription_;
+ std::unique_ptr<CallbackList<void(void)>::Subscription> subscription_;
DISALLOW_COPY_AND_ASSIGN(Adder);
};
@@ -118,42 +118,43 @@
Summer s;
CallbackList<void(int)> c1;
- scoped_ptr<CallbackList<void(int)>::Subscription> subscription1 =
+ std::unique_ptr<CallbackList<void(int)>::Subscription> subscription1 =
c1.Add(Bind(&Summer::AddOneParam, Unretained(&s)));
c1.Notify(1);
EXPECT_EQ(1, s.value());
CallbackList<void(int, int)> c2;
- scoped_ptr<CallbackList<void(int, int)>::Subscription> subscription2 =
+ std::unique_ptr<CallbackList<void(int, int)>::Subscription> subscription2 =
c2.Add(Bind(&Summer::AddTwoParam, Unretained(&s)));
c2.Notify(1, 2);
EXPECT_EQ(3, s.value());
CallbackList<void(int, int, int)> c3;
- scoped_ptr<CallbackList<void(int, int, int)>::Subscription>
+ std::unique_ptr<CallbackList<void(int, int, int)>::Subscription>
subscription3 = c3.Add(Bind(&Summer::AddThreeParam, Unretained(&s)));
c3.Notify(1, 2, 3);
EXPECT_EQ(6, s.value());
CallbackList<void(int, int, int, int)> c4;
- scoped_ptr<CallbackList<void(int, int, int, int)>::Subscription>
+ std::unique_ptr<CallbackList<void(int, int, int, int)>::Subscription>
subscription4 = c4.Add(Bind(&Summer::AddFourParam, Unretained(&s)));
c4.Notify(1, 2, 3, 4);
EXPECT_EQ(10, s.value());
CallbackList<void(int, int, int, int, int)> c5;
- scoped_ptr<CallbackList<void(int, int, int, int, int)>::Subscription>
+ std::unique_ptr<CallbackList<void(int, int, int, int, int)>::Subscription>
subscription5 = c5.Add(Bind(&Summer::AddFiveParam, Unretained(&s)));
c5.Notify(1, 2, 3, 4, 5);
EXPECT_EQ(15, s.value());
CallbackList<void(int, int, int, int, int, int)> c6;
- scoped_ptr<CallbackList<void(int, int, int, int, int, int)>::Subscription>
+ std::unique_ptr<
+ CallbackList<void(int, int, int, int, int, int)>::Subscription>
subscription6 = c6.Add(Bind(&Summer::AddSixParam, Unretained(&s)));
c6.Notify(1, 2, 3, 4, 5, 6);
@@ -166,9 +167,9 @@
CallbackList<void(void)> cb_reg;
Listener a, b, c;
- scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&a)));
- scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
EXPECT_TRUE(a_subscription.get());
@@ -181,7 +182,7 @@
b_subscription.reset();
- scoped_ptr<CallbackList<void(void)>::Subscription> c_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> c_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&c)));
cb_reg.Notify();
@@ -201,9 +202,9 @@
CallbackList<void(int)> cb_reg;
Listener a(1), b(-1), c(1);
- scoped_ptr<CallbackList<void(int)>::Subscription> a_subscription =
+ std::unique_ptr<CallbackList<void(int)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&a)));
- scoped_ptr<CallbackList<void(int)>::Subscription> b_subscription =
+ std::unique_ptr<CallbackList<void(int)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&b)));
EXPECT_TRUE(a_subscription.get());
@@ -216,7 +217,7 @@
b_subscription.reset();
- scoped_ptr<CallbackList<void(int)>::Subscription> c_subscription =
+ std::unique_ptr<CallbackList<void(int)>::Subscription> c_subscription =
cb_reg.Add(Bind(&Listener::IncrementByMultipleOfScaler, Unretained(&c)));
cb_reg.Notify(10);
@@ -237,15 +238,15 @@
Listener a, b;
Remover remover_1, remover_2;
- scoped_ptr<CallbackList<void(void)>::Subscription> remover_1_sub =
- cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
- Unretained(&remover_1)));
- scoped_ptr<CallbackList<void(void)>::Subscription> remover_2_sub =
- cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
- Unretained(&remover_2)));
- scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> remover_1_sub =
+ cb_reg.Add(
+ Bind(&Remover::IncrementTotalAndRemove, Unretained(&remover_1)));
+ std::unique_ptr<CallbackList<void(void)>::Subscription> remover_2_sub =
+ cb_reg.Add(
+ Bind(&Remover::IncrementTotalAndRemove, Unretained(&remover_2)));
+ std::unique_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&a)));
- scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
// |remover_1| will remove itself.
@@ -278,9 +279,9 @@
CallbackList<void(void)> cb_reg;
Adder a(&cb_reg);
Listener b;
- scoped_ptr<CallbackList<void(void)>::Subscription> a_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> a_subscription =
cb_reg.Add(Bind(&Adder::AddCallback, Unretained(&a)));
- scoped_ptr<CallbackList<void(void)>::Subscription> b_subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> b_subscription =
cb_reg.Add(Bind(&Listener::IncrementTotal, Unretained(&b)));
cb_reg.Notify();
@@ -308,7 +309,7 @@
cb_reg.set_removal_callback(
Bind(&Counter::Increment, Unretained(&remove_count)));
- scoped_ptr<CallbackList<void(void)>::Subscription> subscription =
+ std::unique_ptr<CallbackList<void(void)>::Subscription> subscription =
cb_reg.Add(Bind(&DoNothing));
// Removing a subscription outside of iteration signals the callback.
@@ -318,12 +319,12 @@
// Configure two subscriptions to remove themselves.
Remover remover_1, remover_2;
- scoped_ptr<CallbackList<void(void)>::Subscription> remover_1_sub =
- cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
- Unretained(&remover_1)));
- scoped_ptr<CallbackList<void(void)>::Subscription> remover_2_sub =
- cb_reg.Add(Bind(&Remover::IncrementTotalAndRemove,
- Unretained(&remover_2)));
+ std::unique_ptr<CallbackList<void(void)>::Subscription> remover_1_sub =
+ cb_reg.Add(
+ Bind(&Remover::IncrementTotalAndRemove, Unretained(&remover_1)));
+ std::unique_ptr<CallbackList<void(void)>::Subscription> remover_2_sub =
+ cb_reg.Add(
+ Bind(&Remover::IncrementTotalAndRemove, Unretained(&remover_2)));
remover_1.SetSubscriptionToRemove(std::move(remover_1_sub));
remover_2.SetSubscriptionToRemove(std::move(remover_2_sub));
diff --git a/base/callback_list_unittest.nc b/base/callback_list_unittest.nc
index ef193f4..0ddc135 100644
--- a/base/callback_list_unittest.nc
+++ b/base/callback_list_unittest.nc
@@ -7,12 +7,12 @@
#include "base/callback_list.h"
+#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
@@ -26,9 +26,9 @@
public:
FooListener() {}
- void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = std::move(f); }
+ void GotAScopedFoo(std::unique_ptr<Foo> f) { foo_ = std::move(f); }
- scoped_ptr<Foo> foo_;
+ std::unique_ptr<Foo> foo_;
private:
DISALLOW_COPY_AND_ASSIGN(FooListener);
@@ -45,10 +45,10 @@
// first callback has been run.
void WontCompile() {
FooListener f;
- CallbackList<void(scoped_ptr<Foo>)> c1;
- scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub =
+ CallbackList<void(std::unique_ptr<Foo>)> c1;
+ std::unique_ptr<CallbackList<void(std::unique_ptr<Foo>)>::Subscription> sub =
c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
- c1.Notify(scoped_ptr<Foo>(new Foo()));
+ c1.Notify(std::unique_ptr<Foo>(new Foo()));
}
#endif
diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc
index 1f492d4..176ea06 100644
--- a/base/callback_unittest.cc
+++ b/base/callback_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/bind.h"
#include "base/callback.h"
+
+#include <memory>
+
+#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/callback_internal.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 967ce1c..bcfc6c5 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
+
+#include <memory>
#include <string>
#include <vector>
-#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -390,7 +391,8 @@
// Test that copies of CommandLine have a valid StringPiece map.
TEST(CommandLineTest, Copy) {
- scoped_ptr<CommandLine> initial(new CommandLine(CommandLine::NO_PROGRAM));
+ std::unique_ptr<CommandLine> initial(
+ new CommandLine(CommandLine::NO_PROGRAM));
initial->AppendSwitch("a");
initial->AppendSwitch("bbbbbbbbbbbbbbb");
initial->AppendSwitch("c");
diff --git a/base/containers/mru_cache_unittest.cc b/base/containers/mru_cache_unittest.cc
index d38337e..99b14d1 100644
--- a/base/containers/mru_cache_unittest.cc
+++ b/base/containers/mru_cache_unittest.cc
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/containers/mru_cache.h"
+
#include <stddef.h>
-#include "base/containers/mru_cache.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace base {
+
namespace {
int cached_item_live_count = 0;
@@ -188,15 +193,15 @@
// Make sure that the owning version release its pointers properly.
TEST(MRUCacheTest, Owning) {
- using Cache = base::MRUCache<int, scoped_ptr<CachedItem>>;
+ using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>;
Cache cache(Cache::NO_AUTO_EVICT);
int initial_count = cached_item_live_count;
// First insert and item and then overwrite it.
static const int kItem1Key = 1;
- cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(20)));
- cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(22)));
+ cache.Put(kItem1Key, WrapUnique(new CachedItem(20)));
+ cache.Put(kItem1Key, WrapUnique(new CachedItem(22)));
// There should still be one item, and one extra live item.
Cache::iterator iter = cache.Get(kItem1Key);
@@ -212,8 +217,8 @@
// go away.
{
Cache cache2(Cache::NO_AUTO_EVICT);
- cache2.Put(1, make_scoped_ptr(new CachedItem(20)));
- cache2.Put(2, make_scoped_ptr(new CachedItem(20)));
+ cache2.Put(1, WrapUnique(new CachedItem(20)));
+ cache2.Put(2, WrapUnique(new CachedItem(20)));
}
// There should be no objects leaked.
@@ -222,8 +227,8 @@
// Check that Clear() also frees things correctly.
{
Cache cache2(Cache::NO_AUTO_EVICT);
- cache2.Put(1, make_scoped_ptr(new CachedItem(20)));
- cache2.Put(2, make_scoped_ptr(new CachedItem(20)));
+ cache2.Put(1, WrapUnique(new CachedItem(20)));
+ cache2.Put(2, WrapUnique(new CachedItem(20)));
EXPECT_EQ(initial_count + 2, cached_item_live_count);
cache2.Clear();
EXPECT_EQ(initial_count, cached_item_live_count);
@@ -231,7 +236,7 @@
}
TEST(MRUCacheTest, AutoEvict) {
- using Cache = base::MRUCache<int, scoped_ptr<CachedItem>>;
+ using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>;
static const Cache::size_type kMaxSize = 3;
int initial_count = cached_item_live_count;
@@ -240,10 +245,10 @@
Cache cache(kMaxSize);
static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4;
- cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(20)));
- cache.Put(kItem2Key, make_scoped_ptr(new CachedItem(21)));
- cache.Put(kItem3Key, make_scoped_ptr(new CachedItem(22)));
- cache.Put(kItem4Key, make_scoped_ptr(new CachedItem(23)));
+ cache.Put(kItem1Key, WrapUnique(new CachedItem(20)));
+ cache.Put(kItem2Key, WrapUnique(new CachedItem(21)));
+ cache.Put(kItem3Key, WrapUnique(new CachedItem(22)));
+ cache.Put(kItem4Key, WrapUnique(new CachedItem(23)));
// The cache should only have kMaxSize items in it even though we inserted
// more.
@@ -375,3 +380,5 @@
EXPECT_EQ(item1.value, iter->second.value);
}
}
+
+} // namespace base
diff --git a/base/containers/scoped_ptr_hash_map.h b/base/containers/scoped_ptr_hash_map.h
index dd100c6..f513f06 100644
--- a/base/containers/scoped_ptr_hash_map.h
+++ b/base/containers/scoped_ptr_hash_map.h
@@ -8,19 +8,19 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
#include <utility>
#include "base/containers/hash_tables.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
namespace base {
// Deprecated. Use std::unordered_map instead. https://crbug.com/579229
//
-// This type acts like a hash_map<K, scoped_ptr<V, D> >, based on top of
+// This type acts like a hash_map<K, std::unique_ptr<V, D> >, based on top of
// base::hash_map. The ScopedPtrHashMap has ownership of all values in the data
// structure.
template <typename Key, typename ScopedPtr>
diff --git a/base/containers/scoped_ptr_hash_map_unittest.cc b/base/containers/scoped_ptr_hash_map_unittest.cc
index 38fc91a..eddabaf 100644
--- a/base/containers/scoped_ptr_hash_map_unittest.cc
+++ b/base/containers/scoped_ptr_hash_map_unittest.cc
@@ -4,7 +4,9 @@
#include "base/containers/scoped_ptr_hash_map.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -56,8 +58,9 @@
DeleteCounter::ResetCounter();
CountingDeleter::ResetCounter();
{
- ScopedPtrHashMap<int, scoped_ptr<DeleteCounter, CountingDeleter>> map;
- map.set(key, scoped_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
+ ScopedPtrHashMap<int, std::unique_ptr<DeleteCounter, CountingDeleter>> map;
+ map.set(key,
+ std::unique_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
}
EXPECT_EQ(1, DeleteCounter::delete_count());
EXPECT_EQ(1, CountingDeleter::count());
@@ -66,9 +69,9 @@
DeleteCounter::ResetCounter();
CountingDeleter::ResetCounter();
{
- ScopedPtrHashMap<int, scoped_ptr<DeleteCounter, CountingDeleter>> map;
- map.erase(map.set(
- key, scoped_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter)));
+ ScopedPtrHashMap<int, std::unique_ptr<DeleteCounter, CountingDeleter>> map;
+ map.erase(map.set(key, std::unique_ptr<DeleteCounter, CountingDeleter>(
+ new DeleteCounter)));
EXPECT_EQ(1, DeleteCounter::delete_count());
EXPECT_EQ(1, CountingDeleter::count());
}
@@ -79,10 +82,13 @@
DeleteCounter::ResetCounter();
CountingDeleter::ResetCounter();
{
- ScopedPtrHashMap<int, scoped_ptr<DeleteCounter, CountingDeleter>> map;
- map.set(key, scoped_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
- map.set(key, scoped_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
- map.set(key, scoped_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
+ ScopedPtrHashMap<int, std::unique_ptr<DeleteCounter, CountingDeleter>> map;
+ map.set(key,
+ std::unique_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
+ map.set(key,
+ std::unique_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
+ map.set(key,
+ std::unique_ptr<DeleteCounter, CountingDeleter>(new DeleteCounter));
EXPECT_EQ(2, DeleteCounter::delete_count());
EXPECT_EQ(2, CountingDeleter::count());
}
@@ -93,9 +99,9 @@
// Test that using a value type from a namespace containing an ignore_result
// function compiles correctly.
TEST(ScopedPtrHashMapTest, IgnoreResultCompile) {
- ScopedPtrHashMap<int, scoped_ptr<namespace_with_ignore_result::Value>>
+ ScopedPtrHashMap<int, std::unique_ptr<namespace_with_ignore_result::Value>>
scoped_map;
- scoped_map.add(1, make_scoped_ptr(new namespace_with_ignore_result::Value));
+ scoped_map.add(1, WrapUnique(new namespace_with_ignore_result::Value));
}
} // namespace
diff --git a/base/debug/asan_invalid_access.cc b/base/debug/asan_invalid_access.cc
index ba0a10b..ba222ae 100644
--- a/base/debug/asan_invalid_access.cc
+++ b/base/debug/asan_invalid_access.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/debug/asan_invalid_access.h"
+
#include <stddef.h>
+#include <memory>
+
#include "base/debug/alias.h"
-#include "base/debug/asan_invalid_access.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#if defined(OS_WIN)
@@ -61,7 +63,7 @@
void AsanHeapOverflow() {
// Declares the array as volatile to make sure it doesn't get optimized away.
- scoped_ptr<volatile int[]> array(
+ std::unique_ptr<volatile int[]> array(
const_cast<volatile int*>(new int[kArraySize]));
int dummy = array[kArraySize];
base::debug::Alias(&dummy);
@@ -69,7 +71,7 @@
void AsanHeapUnderflow() {
// Declares the array as volatile to make sure it doesn't get optimized away.
- scoped_ptr<volatile int[]> array(
+ std::unique_ptr<volatile int[]> array(
const_cast<volatile int*>(new int[kArraySize]));
// We need to store the underflow address in a temporary variable as trying to
// access array[-1] will trigger a warning C4245: "conversion from 'int' to
@@ -81,7 +83,7 @@
void AsanHeapUseAfterFree() {
// Declares the array as volatile to make sure it doesn't get optimized away.
- scoped_ptr<volatile int[]> array(
+ std::unique_ptr<volatile int[]> array(
const_cast<volatile int*>(new int[kArraySize]));
volatile int* dangling = array.get();
array.reset();
diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc
index cd6dc76..e92d5a5 100644
--- a/base/debug/debugger_posix.cc
+++ b/base/debug/debugger_posix.cc
@@ -3,8 +3,6 @@
// found in the LICENSE file.
#include "base/debug/debugger.h"
-#include "base/macros.h"
-#include "build/build_config.h"
#include <errno.h>
#include <fcntl.h>
@@ -16,8 +14,12 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
#include <vector>
+#include "base/macros.h"
+#include "build/build_config.h"
+
#if defined(__GLIBCXX__)
#include <cxxabi.h>
#endif
@@ -38,7 +40,6 @@
#include "base/debug/alias.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_piece.h"
diff --git a/base/debug/leak_tracker_unittest.cc b/base/debug/leak_tracker_unittest.cc
index 99df4c1..8b4c568 100644
--- a/base/debug/leak_tracker_unittest.cc
+++ b/base/debug/leak_tracker_unittest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/debug/leak_tracker.h"
-#include "base/memory/scoped_ptr.h"
+
+#include <memory>
+
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -29,9 +31,9 @@
EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances());
// Use scoped_ptr so compiler doesn't complain about unused variables.
- scoped_ptr<ClassA> a1(new ClassA);
- scoped_ptr<ClassB> b1(new ClassB);
- scoped_ptr<ClassB> b2(new ClassB);
+ std::unique_ptr<ClassA> a1(new ClassA);
+ std::unique_ptr<ClassB> b1(new ClassB);
+ std::unique_ptr<ClassB> b2(new ClassB);
EXPECT_EQ(-1, LeakTracker<ClassA>::NumLiveInstances());
EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances());
@@ -52,7 +54,7 @@
EXPECT_EQ(1, LeakTracker<ClassA>::NumLiveInstances());
EXPECT_EQ(2, LeakTracker<ClassB>::NumLiveInstances());
- scoped_ptr<ClassA> a2(new ClassA);
+ std::unique_ptr<ClassA> a2(new ClassA);
EXPECT_EQ(2, LeakTracker<ClassA>::NumLiveInstances());
EXPECT_EQ(2, LeakTracker<ClassB>::NumLiveInstances());
@@ -72,10 +74,10 @@
TEST(LeakTrackerTest, LinkedList) {
EXPECT_EQ(0, LeakTracker<ClassB>::NumLiveInstances());
- scoped_ptr<ClassA> a1(new ClassA);
- scoped_ptr<ClassA> a2(new ClassA);
- scoped_ptr<ClassA> a3(new ClassA);
- scoped_ptr<ClassA> a4(new ClassA);
+ std::unique_ptr<ClassA> a1(new ClassA);
+ std::unique_ptr<ClassA> a2(new ClassA);
+ std::unique_ptr<ClassA> a3(new ClassA);
+ std::unique_ptr<ClassA> a4(new ClassA);
EXPECT_EQ(4, LeakTracker<ClassA>::NumLiveInstances());
@@ -88,7 +90,7 @@
EXPECT_EQ(2, LeakTracker<ClassA>::NumLiveInstances());
// Append to the new tail of the list (a3).
- scoped_ptr<ClassA> a5(new ClassA);
+ std::unique_ptr<ClassA> a5(new ClassA);
EXPECT_EQ(3, LeakTracker<ClassA>::NumLiveInstances());
a2.reset();
diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc
index 0551784..fc3ee14 100644
--- a/base/debug/stack_trace_posix.cc
+++ b/base/debug/stack_trace_posix.cc
@@ -17,12 +17,11 @@
#include <unistd.h>
#include <map>
+#include <memory>
#include <ostream>
#include <string>
#include <vector>
-#include "base/memory/free_deleter.h"
-
#if defined(__GLIBCXX__)
#include <cxxabi.h>
#endif
@@ -38,7 +37,7 @@
#include "base/debug/proc_maps_linux.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/free_deleter.h"
#include "base/memory/singleton.h"
#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
@@ -99,7 +98,7 @@
// Try to demangle the mangled symbol candidate.
int status = 0;
- scoped_ptr<char, base::FreeDeleter> demangled_symbol(
+ std::unique_ptr<char, base::FreeDeleter> demangled_symbol(
abi::__cxa_demangle(mangled_symbol.c_str(), NULL, 0, &status));
if (status == 0) { // Demangling is successful.
// Remove the mangled symbol.
@@ -180,8 +179,8 @@
// Below part is async-signal unsafe (uses malloc), so execute it only
// when we are not executing the signal handler.
if (in_signal_handler == 0) {
- scoped_ptr<char*, FreeDeleter>
- trace_symbols(backtrace_symbols(trace, size));
+ std::unique_ptr<char*, FreeDeleter> trace_symbols(
+ backtrace_symbols(trace, size));
if (trace_symbols.get()) {
for (size_t i = 0; i < size; ++i) {
std::string trace_symbol = trace_symbols.get()[i];
diff --git a/base/environment.cc b/base/environment.cc
index adb7387..d14ce87 100644
--- a/base/environment.cc
+++ b/base/environment.cc
@@ -69,7 +69,7 @@
if (value_length == 0)
return false;
if (result) {
- scoped_ptr<wchar_t[]> value(new wchar_t[value_length]);
+ std::unique_ptr<wchar_t[]> value(new wchar_t[value_length]);
::GetEnvironmentVariable(UTF8ToWide(variable_name).c_str(), value.get(),
value_length);
*result = WideToUTF8(value.get());
@@ -184,8 +184,8 @@
#elif defined(OS_POSIX)
-scoped_ptr<char*[]> AlterEnvironment(const char* const* const env,
- const EnvironmentMap& changes) {
+std::unique_ptr<char* []> AlterEnvironment(const char* const* const env,
+ const EnvironmentMap& changes) {
std::string value_storage; // Holds concatenated null-terminated strings.
std::vector<size_t> result_indices; // Line indices into value_storage.
@@ -218,7 +218,7 @@
size_t pointer_count_required =
result_indices.size() + 1 + // Null-terminated array of pointers.
(value_storage.size() + sizeof(char*) - 1) / sizeof(char*); // Buffer.
- scoped_ptr<char*[]> result(new char*[pointer_count_required]);
+ std::unique_ptr<char* []> result(new char*[pointer_count_required]);
// The string storage goes after the array of pointers.
char* storage_data = reinterpret_cast<char*>(
diff --git a/base/environment.h b/base/environment.h
index c8811e2..12eeaf7 100644
--- a/base/environment.h
+++ b/base/environment.h
@@ -6,10 +6,10 @@
#define BASE_ENVIRONMENT_H_
#include <map>
+#include <memory>
#include <string>
#include "base/base_export.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
@@ -79,7 +79,7 @@
// returned array will have appended to it the storage for the array itself so
// there is only one pointer to manage, but this means that you can't copy the
// array without keeping the original around.
-BASE_EXPORT scoped_ptr<char*[]> AlterEnvironment(
+BASE_EXPORT std::unique_ptr<char* []> AlterEnvironment(
const char* const* env,
const EnvironmentMap& changes);
diff --git a/base/environment_unittest.cc b/base/environment_unittest.cc
index 77e9717..ef264cf 100644
--- a/base/environment_unittest.cc
+++ b/base/environment_unittest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/environment.h"
-#include "base/memory/scoped_ptr.h"
+
+#include <memory>
+
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -14,14 +16,14 @@
TEST_F(EnvironmentTest, GetVar) {
// Every setup should have non-empty PATH...
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
std::string env_value;
EXPECT_TRUE(env->GetVar("PATH", &env_value));
EXPECT_NE(env_value, "");
}
TEST_F(EnvironmentTest, GetVarReverse) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
const char kFooUpper[] = "FOO";
const char kFooLower[] = "foo";
@@ -50,12 +52,12 @@
TEST_F(EnvironmentTest, HasVar) {
// Every setup should have PATH...
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
EXPECT_TRUE(env->HasVar("PATH"));
}
TEST_F(EnvironmentTest, SetVar) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
const char kFooUpper[] = "FOO";
const char kFooLower[] = "foo";
@@ -70,7 +72,7 @@
}
TEST_F(EnvironmentTest, UnSetVar) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
const char kFooUpper[] = "FOO";
const char kFooLower[] = "foo";
@@ -128,7 +130,7 @@
const char* const empty[] = { NULL };
const char* const a2[] = { "A=2", NULL };
EnvironmentMap changes;
- scoped_ptr<char*[]> e;
+ std::unique_ptr<char* []> e;
e = AlterEnvironment(empty, changes);
EXPECT_TRUE(e[0] == NULL);
diff --git a/base/feature_list.cc b/base/feature_list.cc
index 2e79098..dcb76f5 100644
--- a/base/feature_list.cc
+++ b/base/feature_list.cc
@@ -161,7 +161,7 @@
g_instance = nullptr;
}
- scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
feature_list->InitializeFromCommandLine(enable_features, disable_features);
base::FeatureList::SetInstance(std::move(feature_list));
}
@@ -172,7 +172,7 @@
}
// static
-void FeatureList::SetInstance(scoped_ptr<FeatureList> instance) {
+void FeatureList::SetInstance(std::unique_ptr<FeatureList> instance) {
DCHECK(!g_instance);
instance->FinalizeInitialization();
diff --git a/base/feature_list.h b/base/feature_list.h
index c4d6e83..9f80684 100644
--- a/base/feature_list.h
+++ b/base/feature_list.h
@@ -6,13 +6,13 @@
#define BASE_FEATURE_LIST_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/base_export.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "base/synchronization/lock.h"
@@ -159,7 +159,7 @@
// Registers the given |instance| to be the singleton feature list for this
// process. This should only be called once and |instance| must not be null.
- static void SetInstance(scoped_ptr<FeatureList> instance);
+ static void SetInstance(std::unique_ptr<FeatureList> instance);
// Clears the previously-registered singleton instance for tests.
static void ClearInstanceForTesting();
diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc
index 58a7ebc..b49177f 100644
--- a/base/feature_list_unittest.cc
+++ b/base/feature_list_unittest.cc
@@ -11,6 +11,7 @@
#include "base/format_macros.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -42,11 +43,11 @@
class FeatureListTest : public testing::Test {
public:
FeatureListTest() : feature_list_(nullptr) {
- RegisterFeatureListInstance(make_scoped_ptr(new FeatureList));
+ RegisterFeatureListInstance(WrapUnique(new FeatureList));
}
~FeatureListTest() override { ClearFeatureListInstance(); }
- void RegisterFeatureListInstance(scoped_ptr<FeatureList> feature_list) {
+ void RegisterFeatureListInstance(std::unique_ptr<FeatureList> feature_list) {
FeatureList::ClearInstanceForTesting();
feature_list_ = feature_list.get();
FeatureList::SetInstance(std::move(feature_list));
@@ -93,7 +94,7 @@
test_case.disable_features));
ClearFeatureListInstance();
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine(test_case.enable_features,
test_case.disable_features);
RegisterFeatureListInstance(std::move(feature_list));
@@ -149,7 +150,7 @@
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
FieldTrial* trial1 = FieldTrialList::CreateFieldTrial("TrialExample1", "A");
FieldTrial* trial2 = FieldTrialList::CreateFieldTrial("TrialExample2", "B");
@@ -181,7 +182,7 @@
TEST_F(FeatureListTest, FieldTrialAssociateUseDefault) {
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
FieldTrial* trial1 = FieldTrialList::CreateFieldTrial("TrialExample1", "A");
FieldTrial* trial2 = FieldTrialList::CreateFieldTrial("TrialExample2", "B");
@@ -212,7 +213,7 @@
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
// The feature is explicitly enabled on the command-line.
feature_list->InitializeFromCommandLine(kFeatureOffByDefaultName, "");
@@ -236,7 +237,7 @@
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
// No features are overridden from the command line yet
EXPECT_FALSE(feature_list->IsFeatureOverriddenFromCommandLine(
@@ -311,7 +312,7 @@
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine(test_case.enable_features,
test_case.disable_features);
@@ -354,7 +355,7 @@
TEST_F(FeatureListTest, GetFeatureOverrides) {
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine("A,X", "D");
FieldTrial* trial = FieldTrialList::CreateFieldTrial("Trial", "Group");
@@ -375,7 +376,7 @@
TEST_F(FeatureListTest, GetFeatureOverrides_UseDefault) {
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine("A,X", "D");
FieldTrial* trial = FieldTrialList::CreateFieldTrial("Trial", "Group");
@@ -396,7 +397,7 @@
ClearFeatureListInstance();
FieldTrialList field_trial_list(nullptr);
FieldTrialList::CreateFieldTrial("Trial", "Group");
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine("A,OffByDefault<Trial,X", "D");
RegisterFeatureListInstance(std::move(feature_list));
@@ -410,7 +411,7 @@
FieldTrialList field_trial_list(nullptr);
FieldTrialList::CreateFieldTrial("T1", "Group");
FieldTrialList::CreateFieldTrial("T2", "Group");
- scoped_ptr<FeatureList> feature_list(new FeatureList);
+ std::unique_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine(
"A,*OffByDefault<T1,*OnByDefault<T2,X", "D");
RegisterFeatureListInstance(std::move(feature_list));
@@ -427,7 +428,7 @@
TEST_F(FeatureListTest, InitializeInstance) {
ClearFeatureListInstance();
- scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
FeatureList::SetInstance(std::move(feature_list));
EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOnByDefault));
EXPECT_FALSE(FeatureList::IsEnabled(kFeatureOffByDefault));
diff --git a/base/file_version_info_unittest.cc b/base/file_version_info_unittest.cc
index 4c0ba6f..ac5320f 100644
--- a/base/file_version_info_unittest.cc
+++ b/base/file_version_info_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_version_info.h"
+
#include <stddef.h>
-#include "base/file_version_info.h"
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -60,7 +62,7 @@
FilePath dll_path = GetTestDataPath();
dll_path = dll_path.Append(kDLLName);
- scoped_ptr<FileVersionInfo> version_info(
+ std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(dll_path));
int j = 0;
@@ -101,7 +103,7 @@
FilePath dll_path = GetTestDataPath();
dll_path = dll_path.Append(kDLLNames[i]);
- scoped_ptr<FileVersionInfo> version_info(
+ std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(dll_path));
EXPECT_EQ(kExpected[i], version_info->is_official_build());
@@ -114,7 +116,7 @@
FilePath dll_path = GetTestDataPath();
dll_path = dll_path.AppendASCII("FileVersionInfoTest1.dll");
- scoped_ptr<FileVersionInfo> version_info(
+ std::unique_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(dll_path));
// Test few existing properties.
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index a75eaba..15285ae 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -14,6 +14,7 @@
#include <algorithm>
#include <map>
+#include <memory>
#include <set>
#include <utility>
#include <vector>
@@ -27,7 +28,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
diff --git a/base/files/file_path_watcher_unittest.cc b/base/files/file_path_watcher_unittest.cc
index a860b13..027e0c2 100644
--- a/base/files/file_path_watcher_unittest.cc
+++ b/base/files/file_path_watcher_unittest.cc
@@ -227,7 +227,7 @@
// Basic test: Create the file and verify that we notice.
TEST_F(FilePathWatcherTest, NewFile) {
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
ASSERT_TRUE(WriteFile(test_file(), "content"));
@@ -240,7 +240,7 @@
ASSERT_TRUE(WriteFile(test_file(), "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
// Now make sure we get notified if the file is modified.
@@ -255,7 +255,7 @@
ASSERT_TRUE(WriteFile(source_file, "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
// Now make sure we get notified if the file is modified.
@@ -268,7 +268,7 @@
ASSERT_TRUE(WriteFile(test_file(), "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
// Now make sure we get notified if the file is deleted.
@@ -296,7 +296,7 @@
FilePathWatcher* watcher() const { return watcher_.get(); }
private:
- scoped_ptr<FilePathWatcher> watcher_;
+ std::unique_ptr<FilePathWatcher> watcher_;
MessageLoop* loop_;
DISALLOW_COPY_AND_ASSIGN(Deleter);
@@ -306,7 +306,7 @@
TEST_F(FilePathWatcherTest, DeleteDuringNotify) {
FilePathWatcher* watcher = new FilePathWatcher;
// Takes ownership of watcher.
- scoped_ptr<Deleter> deleter(new Deleter(watcher, &loop_));
+ std::unique_ptr<Deleter> deleter(new Deleter(watcher, &loop_));
ASSERT_TRUE(SetupWatch(test_file(), watcher, deleter.get(), false));
ASSERT_TRUE(WriteFile(test_file(), "content"));
@@ -321,7 +321,7 @@
// notification.
// Flaky on MacOS (and ARM linux): http://crbug.com/85930
TEST_F(FilePathWatcherTest, DISABLED_DestroyWithPendingNotification) {
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
FilePathWatcher* watcher = new FilePathWatcher;
ASSERT_TRUE(SetupWatch(test_file(), watcher, delegate.get(), false));
ASSERT_TRUE(WriteFile(test_file(), "content"));
@@ -331,8 +331,8 @@
TEST_F(FilePathWatcherTest, MultipleWatchersSingleFile) {
FilePathWatcher watcher1, watcher2;
- scoped_ptr<TestDelegate> delegate1(new TestDelegate(collector()));
- scoped_ptr<TestDelegate> delegate2(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate1(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate2(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher1, delegate1.get(), false));
ASSERT_TRUE(SetupWatch(test_file(), &watcher2, delegate2.get(), false));
@@ -348,7 +348,7 @@
FilePathWatcher watcher;
FilePath dir(temp_dir_.path().AppendASCII("dir"));
FilePath file(dir.AppendASCII("file"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
ASSERT_TRUE(base::CreateDirectory(dir));
@@ -381,7 +381,7 @@
FilePathWatcher watcher;
FilePath file(path.AppendASCII("file"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
FilePath sub_path(temp_dir_.path());
@@ -411,7 +411,7 @@
FilePath file(dir.AppendASCII("file"));
ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false));
ASSERT_TRUE(base::DeleteFile(dir, true));
@@ -423,7 +423,7 @@
TEST_F(FilePathWatcherTest, DeleteAndRecreate) {
ASSERT_TRUE(WriteFile(test_file(), "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
ASSERT_TRUE(base::DeleteFile(test_file(), false));
@@ -441,7 +441,7 @@
FilePath dir(temp_dir_.path().AppendASCII("dir"));
FilePath file1(dir.AppendASCII("file1"));
FilePath file2(dir.AppendASCII("file2"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(dir, &watcher, delegate.get(), false));
ASSERT_TRUE(base::CreateDirectory(dir));
@@ -476,9 +476,9 @@
FilePath dest(temp_dir_.path().AppendASCII("dest"));
FilePath subdir(dir.AppendASCII("subdir"));
FilePath file(subdir.AppendASCII("file"));
- scoped_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(file, &file_watcher, file_delegate.get(), false));
- scoped_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(subdir, &subdir_watcher, subdir_delegate.get(),
false));
@@ -499,7 +499,7 @@
TEST_F(FilePathWatcherTest, RecursiveWatch) {
FilePathWatcher watcher;
FilePath dir(temp_dir_.path().AppendASCII("dir"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
bool setup_result = SetupWatch(dir, &watcher, delegate.get(), true);
if (!FilePathWatcher::RecursiveWatchAvailable()) {
ASSERT_FALSE(setup_result);
@@ -579,7 +579,7 @@
FilePath test_dir(temp_dir_.path().AppendASCII("test_dir"));
ASSERT_TRUE(base::CreateDirectory(test_dir));
FilePath symlink(test_dir.AppendASCII("symlink"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(symlink, &watcher, delegate.get(), true));
// Link creation.
@@ -626,9 +626,9 @@
ASSERT_TRUE(base::CreateDirectory(source_subdir));
ASSERT_TRUE(WriteFile(source_file, "content"));
- scoped_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> file_delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(dest_file, &file_watcher, file_delegate.get(), false));
- scoped_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> subdir_delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(dest_subdir, &subdir_watcher, subdir_delegate.get(),
false));
@@ -651,7 +651,7 @@
TEST_F(FilePathWatcherTest, FileAttributesChanged) {
ASSERT_TRUE(WriteFile(test_file(), "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false));
// Now make sure we get notified if the file is modified.
@@ -665,7 +665,7 @@
// Verify that creating a symlink is caught.
TEST_F(FilePathWatcherTest, CreateLink) {
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// Note that we are watching the symlink
ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
@@ -683,7 +683,7 @@
ASSERT_TRUE(WriteFile(test_file(), "content"));
ASSERT_TRUE(CreateSymbolicLink(test_file(), test_link()));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
// Now make sure we get notified if the link is deleted.
@@ -698,7 +698,7 @@
ASSERT_TRUE(WriteFile(test_file(), "content"));
ASSERT_TRUE(CreateSymbolicLink(test_file(), test_link()));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// Note that we are watching the symlink.
ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
@@ -713,7 +713,7 @@
TEST_F(FilePathWatcherTest, CreateTargetLinkedFile) {
ASSERT_TRUE(CreateSymbolicLink(test_file(), test_link()));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// Note that we are watching the symlink.
ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
@@ -729,7 +729,7 @@
ASSERT_TRUE(WriteFile(test_file(), "content"));
ASSERT_TRUE(CreateSymbolicLink(test_file(), test_link()));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// Note that we are watching the symlink.
ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false));
@@ -747,7 +747,7 @@
FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
FilePath file(dir.AppendASCII("file"));
FilePath linkfile(link_dir.AppendASCII("file"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// dir/file should exist.
ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(WriteFile(file, "content"));
@@ -776,7 +776,7 @@
FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
FilePath file(dir.AppendASCII("file"));
FilePath linkfile(link_dir.AppendASCII("file"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
// Now create the link from dir.lnk pointing to dir but
// neither dir nor dir/file exist yet.
ASSERT_TRUE(CreateSymbolicLink(dir, link_dir));
@@ -806,7 +806,7 @@
FilePath link_dir(temp_dir_.path().AppendASCII("dir.lnk"));
FilePath file(dir.AppendASCII("file"));
FilePath linkfile(link_dir.AppendASCII("file"));
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(base::CreateDirectory(dir));
ASSERT_TRUE(CreateSymbolicLink(dir, link_dir));
// Note that we are watching dir.lnk/file but the file doesn't exist yet.
@@ -883,7 +883,7 @@
ASSERT_TRUE(WriteFile(test_file, "content"));
FilePathWatcher watcher;
- scoped_ptr<TestDelegate> delegate(new TestDelegate(collector()));
+ std::unique_ptr<TestDelegate> delegate(new TestDelegate(collector()));
ASSERT_TRUE(SetupWatch(test_file, &watcher, delegate.get(), false));
// We should not get notified in this case as it hasn't affected our ability
diff --git a/base/files/file_proxy.cc b/base/files/file_proxy.cc
index f157d4d..829f700 100644
--- a/base/files/file_proxy.cc
+++ b/base/files/file_proxy.cc
@@ -192,7 +192,7 @@
}
private:
- scoped_ptr<char[]> buffer_;
+ std::unique_ptr<char[]> buffer_;
int bytes_to_read_;
int bytes_read_;
DISALLOW_COPY_AND_ASSIGN(ReadHelper);
@@ -222,7 +222,7 @@
}
private:
- scoped_ptr<char[]> buffer_;
+ std::unique_ptr<char[]> buffer_;
int bytes_to_write_;
int bytes_written_;
DISALLOW_COPY_AND_ASSIGN(WriteHelper);
diff --git a/base/files/file_util.cc b/base/files/file_util.cc
index 3169370..80fa44f 100644
--- a/base/files/file_util.cc
+++ b/base/files/file_util.cc
@@ -137,7 +137,7 @@
}
const size_t kBufferSize = 1 << 16;
- scoped_ptr<char[]> buf(new char[kBufferSize]);
+ std::unique_ptr<char[]> buf(new char[kBufferSize]);
size_t len;
size_t size = 0;
bool read_status = true;
diff --git a/base/files/file_util.h b/base/files/file_util.h
index 05b3cbf..8f7d53c 100644
--- a/base/files/file_util.h
+++ b/base/files/file_util.h
@@ -19,7 +19,6 @@
#include "base/base_export.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index 0e99b01..ca1c525 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -27,7 +27,6 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc
index a724dc3..922aa0f 100644
--- a/base/files/important_file_writer.cc
+++ b/base/files/important_file_writer.cc
@@ -55,9 +55,10 @@
DPLOG(WARNING) << "temp file failure: " << path.value() << " : " << message;
}
-// Helper function to call WriteFileAtomically() with a scoped_ptr<std::string>.
+// Helper function to call WriteFileAtomically() with a
+// std::unique_ptr<std::string>.
bool WriteScopedStringToFileAtomically(const FilePath& path,
- scoped_ptr<std::string> data) {
+ std::unique_ptr<std::string> data) {
return ImportantFileWriter::WriteFileAtomically(path, *data);
}
@@ -157,7 +158,7 @@
return timer_.IsRunning();
}
-void ImportantFileWriter::WriteNow(scoped_ptr<std::string> data) {
+void ImportantFileWriter::WriteNow(std::unique_ptr<std::string> data) {
DCHECK(CalledOnValidThread());
if (!IsValueInRangeForNumericType<int32_t>(data->length())) {
NOTREACHED();
@@ -192,7 +193,7 @@
void ImportantFileWriter::DoScheduledWrite() {
DCHECK(serializer_);
- scoped_ptr<std::string> data(new std::string);
+ std::unique_ptr<std::string> data(new std::string);
if (serializer_->SerializeData(data.get())) {
WriteNow(std::move(data));
} else {
diff --git a/base/files/important_file_writer.h b/base/files/important_file_writer.h
index b28231e..71067fb 100644
--- a/base/files/important_file_writer.h
+++ b/base/files/important_file_writer.h
@@ -82,7 +82,7 @@
// Save |data| to target filename. Does not block. If there is a pending write
// scheduled by ScheduleWrite(), it is cancelled.
- void WriteNow(scoped_ptr<std::string> data);
+ void WriteNow(std::unique_ptr<std::string> data);
// Schedule a save to target filename. Data will be serialized and saved
// to disk after the commit interval. If another ScheduleWrite is issued
diff --git a/base/files/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc
index 28e6001..61d5e53 100644
--- a/base/files/important_file_writer_unittest.cc
+++ b/base/files/important_file_writer_unittest.cc
@@ -12,6 +12,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
@@ -103,7 +104,7 @@
ImportantFileWriter writer(file_, ThreadTaskRunnerHandle::Get());
EXPECT_FALSE(PathExists(writer.path()));
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
- writer.WriteNow(make_scoped_ptr(new std::string("foo")));
+ writer.WriteNow(WrapUnique(new std::string("foo")));
RunLoop().RunUntilIdle();
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
@@ -116,7 +117,7 @@
EXPECT_FALSE(PathExists(writer.path()));
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
successful_write_observer_.ObserveNextSuccessfulWrite(&writer);
- writer.WriteNow(make_scoped_ptr(new std::string("foo")));
+ writer.WriteNow(WrapUnique(new std::string("foo")));
RunLoop().RunUntilIdle();
// Confirm that the observer is invoked.
@@ -127,7 +128,7 @@
// Confirm that re-installing the observer works for another write.
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
successful_write_observer_.ObserveNextSuccessfulWrite(&writer);
- writer.WriteNow(make_scoped_ptr(new std::string("bar")));
+ writer.WriteNow(WrapUnique(new std::string("bar")));
RunLoop().RunUntilIdle();
EXPECT_TRUE(successful_write_observer_.GetAndResetObservationState());
@@ -137,7 +138,7 @@
// Confirm that writing again without re-installing the observer doesn't
// result in a notification.
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
- writer.WriteNow(make_scoped_ptr(new std::string("baz")));
+ writer.WriteNow(WrapUnique(new std::string("baz")));
RunLoop().RunUntilIdle();
EXPECT_FALSE(successful_write_observer_.GetAndResetObservationState());
diff --git a/base/files/memory_mapped_file_unittest.cc b/base/files/memory_mapped_file_unittest.cc
index f75686f..396ab72 100644
--- a/base/files/memory_mapped_file_unittest.cc
+++ b/base/files/memory_mapped_file_unittest.cc
@@ -19,8 +19,8 @@
namespace {
// Create a temporary buffer and fill it with a watermark sequence.
-scoped_ptr<uint8_t[]> CreateTestBuffer(size_t size, size_t offset) {
- scoped_ptr<uint8_t[]> buf(new uint8_t[size]);
+std::unique_ptr<uint8_t[]> CreateTestBuffer(size_t size, size_t offset) {
+ std::unique_ptr<uint8_t[]> buf(new uint8_t[size]);
for (size_t i = 0; i < size; ++i)
buf.get()[i] = static_cast<uint8_t>((offset + i) % 253);
return buf;
@@ -28,7 +28,7 @@
// Check that the watermark sequence is consistent with the |offset| provided.
bool CheckBufferContents(const uint8_t* data, size_t size, size_t offset) {
- scoped_ptr<uint8_t[]> test_data(CreateTestBuffer(size, offset));
+ std::unique_ptr<uint8_t[]> test_data(CreateTestBuffer(size, offset));
return memcmp(test_data.get(), data, size) == 0;
}
@@ -46,7 +46,7 @@
File::FLAG_CREATE_ALWAYS | File::FLAG_READ | File::FLAG_WRITE);
EXPECT_TRUE(file.IsValid());
- scoped_ptr<uint8_t[]> test_data(CreateTestBuffer(size, 0));
+ std::unique_ptr<uint8_t[]> test_data(CreateTestBuffer(size, 0));
size_t bytes_written =
file.Write(0, reinterpret_cast<char*>(test_data.get()), size);
EXPECT_EQ(size, bytes_written);
diff --git a/base/files/scoped_file.h b/base/files/scoped_file.h
index 106f6ad..68c0415 100644
--- a/base/files/scoped_file.h
+++ b/base/files/scoped_file.h
@@ -7,9 +7,10 @@
#include <stdio.h>
+#include <memory>
+
#include "base/base_export.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_generic.h"
#include "build/build_config.h"
@@ -54,7 +55,7 @@
#endif
// Automatically closes |FILE*|s.
-typedef scoped_ptr<FILE, internal::ScopedFILECloser> ScopedFILE;
+typedef std::unique_ptr<FILE, internal::ScopedFILECloser> ScopedFILE;
} // namespace base
diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc
index 4f4e69a..7b3375e 100644
--- a/base/i18n/file_util_icu.cc
+++ b/base/i18n/file_util_icu.cc
@@ -8,12 +8,13 @@
#include <stdint.h>
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/i18n/string_compare.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
@@ -56,10 +57,10 @@
~IllegalCharacters() { }
// set of characters considered invalid anywhere inside a filename.
- scoped_ptr<icu::UnicodeSet> illegal_anywhere_;
+ std::unique_ptr<icu::UnicodeSet> illegal_anywhere_;
// set of characters considered invalid at either end of a filename.
- scoped_ptr<icu::UnicodeSet> illegal_at_ends_;
+ std::unique_ptr<icu::UnicodeSet> illegal_at_ends_;
DISALLOW_COPY_AND_ASSIGN(IllegalCharacters);
};
@@ -149,7 +150,8 @@
UErrorCode error_code = U_ZERO_ERROR;
// Use the default collator. The default locale should have been properly
// set by the time this constructor is called.
- scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error_code));
+ std::unique_ptr<icu::Collator> collator(
+ icu::Collator::createInstance(error_code));
DCHECK(U_SUCCESS(error_code));
// Make it case-sensitive.
collator->setStrength(icu::Collator::TERTIARY);
diff --git a/base/i18n/icu_string_conversions.cc b/base/i18n/icu_string_conversions.cc
index 68ce529..be82db2 100644
--- a/base/i18n/icu_string_conversions.cc
+++ b/base/i18n/icu_string_conversions.cc
@@ -7,10 +7,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/icu/source/common/unicode/ucnv.h"
@@ -177,7 +177,7 @@
size_t uchar_max_length = encoded.length() + 1;
SetUpErrorHandlerForToUChars(on_error, converter, &status);
- scoped_ptr<char16[]> buffer(new char16[uchar_max_length]);
+ std::unique_ptr<char16[]> buffer(new char16[uchar_max_length]);
int actual_size = ucnv_toUChars(converter, buffer.get(),
static_cast<int>(uchar_max_length), encoded.data(),
static_cast<int>(encoded.length()), &status);
@@ -203,7 +203,7 @@
UErrorCode status = U_ZERO_ERROR;
size_t max_length = utf16.length() + 1;
string16 normalized_utf16;
- scoped_ptr<char16[]> buffer(new char16[max_length]);
+ std::unique_ptr<char16[]> buffer(new char16[max_length]);
int actual_length = unorm_normalize(
utf16.c_str(), utf16.length(), UNORM_NFC, 0,
buffer.get(), static_cast<int>(max_length), &status);
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index afadb25..05e1467 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -184,7 +184,7 @@
return false;
}
- scoped_ptr<MemoryMappedFile> icudtl_mapped_file(new MemoryMappedFile());
+ std::unique_ptr<MemoryMappedFile> icudtl_mapped_file(new MemoryMappedFile());
if (!icudtl_mapped_file->Initialize(File(data_fd), data_region)) {
g_debug_icu_load = 2; // To debug http://crbug.com/445616.
LOG(ERROR) << "Couldn't mmap icu data file";
@@ -310,7 +310,7 @@
// when requested.
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
if (result)
- scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
+ std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
#endif
return result;
}
diff --git a/base/i18n/message_formatter.h b/base/i18n/message_formatter.h
index 4a5b92f..4394023 100644
--- a/base/i18n/message_formatter.h
+++ b/base/i18n/message_formatter.h
@@ -6,11 +6,12 @@
#define BASE_I18N_MESSAGE_FORMATTER_H_
#include <stdint.h>
+
+#include <memory>
#include <string>
#include "base/i18n/base_i18n_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
#include "third_party/icu/source/common/unicode/uversion.h"
@@ -46,7 +47,7 @@
MessageArg();
// Tests if this argument has a value, and if so increments *count.
bool has_value(int* count) const;
- scoped_ptr<icu::Formattable> formattable;
+ std::unique_ptr<icu::Formattable> formattable;
DISALLOW_COPY_AND_ASSIGN(MessageArg);
};
diff --git a/base/i18n/message_formatter_unittest.cc b/base/i18n/message_formatter_unittest.cc
index 85e2e17..a6f4613 100644
--- a/base/i18n/message_formatter_unittest.cc
+++ b/base/i18n/message_formatter_unittest.cc
@@ -4,8 +4,9 @@
#include "base/i18n/message_formatter.h"
+#include <memory>
+
#include "base/i18n/rtl.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -36,8 +37,9 @@
namespace {
-void AppendFormattedDateTime(const scoped_ptr<icu::DateFormat>& df,
- const Time& now, std::string* result) {
+void AppendFormattedDateTime(const std::unique_ptr<icu::DateFormat>& df,
+ const Time& now,
+ std::string* result) {
icu::UnicodeString formatted;
df->format(static_cast<UDate>(now.ToJsTime()), formatted).
toUTF8String(*result);
@@ -119,7 +121,8 @@
base::Time now = base::Time::Now();
using icu::DateFormat;
- scoped_ptr<DateFormat> df(DateFormat::createDateInstance(DateFormat::FULL));
+ std::unique_ptr<DateFormat> df(
+ DateFormat::createDateInstance(DateFormat::FULL));
std::string second_sentence = " Today is ";
AppendFormattedDateTime(df, now, &second_sentence);
@@ -141,8 +144,10 @@
"The speed of the wind was {3,number,###.#} mph.");
using icu::DateFormat;
- scoped_ptr<DateFormat> tf(DateFormat::createTimeInstance(DateFormat::SHORT));
- scoped_ptr<DateFormat> df(DateFormat::createDateInstance(DateFormat::MEDIUM));
+ std::unique_ptr<DateFormat> tf(
+ DateFormat::createTimeInstance(DateFormat::SHORT));
+ std::unique_ptr<DateFormat> df(
+ DateFormat::createDateInstance(DateFormat::MEDIUM));
base::Time now = base::Time::Now();
std::string expected = "At ";
diff --git a/base/i18n/number_formatting.cc b/base/i18n/number_formatting.cc
index 920ba96..6f454a0 100644
--- a/base/i18n/number_formatting.cc
+++ b/base/i18n/number_formatting.cc
@@ -6,10 +6,11 @@
#include <stddef.h>
+#include <memory>
+
#include "base/format_macros.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -37,7 +38,7 @@
DCHECK(U_SUCCESS(status));
}
- scoped_ptr<icu::NumberFormat> number_format;
+ std::unique_ptr<icu::NumberFormat> number_format;
};
LazyInstance<NumberFormatWrapper> g_number_format_int =
diff --git a/base/i18n/time_formatting.cc b/base/i18n/time_formatting.cc
index 321020c..666abd4 100644
--- a/base/i18n/time_formatting.cc
+++ b/base/i18n/time_formatting.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "third_party/icu/source/i18n/unicode/datefmt.h"
@@ -53,7 +54,7 @@
// use (some locales use '.' instead of ':'), and where to put the am/pm
// marker.
UErrorCode status = U_ZERO_ERROR;
- scoped_ptr<icu::DateTimePatternGenerator> generator(
+ std::unique_ptr<icu::DateTimePatternGenerator> generator(
icu::DateTimePatternGenerator::createInstance(status));
DCHECK(U_SUCCESS(status));
icu::UnicodeString generated_pattern =
@@ -72,7 +73,7 @@
string16 TimeFormatTimeOfDay(const Time& time) {
// We can omit the locale parameter because the default should match
// Chrome's application locale.
- scoped_ptr<icu::DateFormat> formatter(
+ std::unique_ptr<icu::DateFormat> formatter(
icu::DateFormat::createTimeInstance(icu::DateFormat::kShort));
return TimeFormat(formatter.get(), time);
}
@@ -103,38 +104,39 @@
}
string16 TimeFormatShortDate(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(
+ std::unique_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateInstance(icu::DateFormat::kMedium));
return TimeFormat(formatter.get(), time);
}
string16 TimeFormatShortDateNumeric(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(
+ std::unique_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateInstance(icu::DateFormat::kShort));
return TimeFormat(formatter.get(), time);
}
string16 TimeFormatShortDateAndTime(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(
+ std::unique_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateTimeInstance(icu::DateFormat::kShort));
return TimeFormat(formatter.get(), time);
}
string16 TimeFormatShortDateAndTimeWithTimeZone(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(icu::DateFormat::createDateTimeInstance(
- icu::DateFormat::kShort, icu::DateFormat::kLong));
+ std::unique_ptr<icu::DateFormat> formatter(
+ icu::DateFormat::createDateTimeInstance(icu::DateFormat::kShort,
+ icu::DateFormat::kLong));
return TimeFormat(formatter.get(), time);
}
string16 TimeFormatFriendlyDateAndTime(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(
+ std::unique_ptr<icu::DateFormat> formatter(
icu::DateFormat::createDateTimeInstance(icu::DateFormat::kFull));
return TimeFormat(formatter.get(), time);
}
string16 TimeFormatFriendlyDate(const Time& time) {
- scoped_ptr<icu::DateFormat> formatter(icu::DateFormat::createDateInstance(
- icu::DateFormat::kFull));
+ std::unique_ptr<icu::DateFormat> formatter(
+ icu::DateFormat::createDateInstance(icu::DateFormat::kFull));
return TimeFormat(formatter.get(), time);
}
@@ -142,7 +144,7 @@
// TODO(satorux,jshin): Rework this with ures_getByKeyWithFallback()
// once it becomes public. The short time format can be found at
// "calendar/gregorian/DateTimePatterns/3" in the resources.
- scoped_ptr<icu::SimpleDateFormat> formatter(
+ std::unique_ptr<icu::SimpleDateFormat> formatter(
static_cast<icu::SimpleDateFormat*>(
icu::DateFormat::createTimeInstance(icu::DateFormat::kShort)));
// Retrieve the short time format.
diff --git a/base/i18n/time_formatting_unittest.cc b/base/i18n/time_formatting_unittest.cc
index 665b715..b07eb47 100644
--- a/base/i18n/time_formatting_unittest.cc
+++ b/base/i18n/time_formatting_unittest.cc
@@ -4,8 +4,9 @@
#include "base/i18n/time_formatting.h"
+#include <memory>
+
#include "base/i18n/rtl.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/icu_test_util.h"
#include "base/time/time.h"
@@ -28,8 +29,8 @@
// see https://en.wikipedia.org/wiki/Daylight_saving_time for details.
base::string16 GetShortTimeZone(const Time& time) {
UErrorCode status = U_ZERO_ERROR;
- scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
- scoped_ptr<icu::TimeZoneFormat> zone_formatter(
+ std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
+ std::unique_ptr<icu::TimeZoneFormat> zone_formatter(
icu::TimeZoneFormat::createInstance(icu::Locale::getDefault(), status));
EXPECT_TRUE(U_SUCCESS(status));
icu::UnicodeString name;
diff --git a/base/i18n/timezone.cc b/base/i18n/timezone.cc
index fbc9949..e881c9d 100644
--- a/base/i18n/timezone.cc
+++ b/base/i18n/timezone.cc
@@ -607,7 +607,7 @@
} // namespace
std::string CountryCodeForCurrentTimezone() {
- scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
+ std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
icu::UnicodeString id;
zone->getID(id);
string16 olson_code(id.getBuffer(), id.length());
diff --git a/base/json/json_file_value_serializer.cc b/base/json/json_file_value_serializer.cc
index 516f876..1a9b7a2 100644
--- a/base/json/json_file_value_serializer.cc
+++ b/base/json/json_file_value_serializer.cc
@@ -101,7 +101,7 @@
}
}
-scoped_ptr<base::Value> JSONFileValueDeserializer::Deserialize(
+std::unique_ptr<base::Value> JSONFileValueDeserializer::Deserialize(
int* error_code,
std::string* error_str) {
std::string json_string;
diff --git a/base/json/json_file_value_serializer.h b/base/json/json_file_value_serializer.h
index f6b4e5f..67d2342 100644
--- a/base/json/json_file_value_serializer.h
+++ b/base/json/json_file_value_serializer.h
@@ -60,8 +60,8 @@
// If |error_message| is non-null, it will be filled in with a formatted
// error message including the location of the error if appropriate.
// The caller takes ownership of the returned value.
- scoped_ptr<base::Value> Deserialize(int* error_code,
- std::string* error_message) override;
+ std::unique_ptr<base::Value> Deserialize(int* error_code,
+ std::string* error_message) override;
// This enum is designed to safely overlap with JSONReader::JsonParseError.
enum JsonFileError {
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc
index d270471..801c84a 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -5,10 +5,10 @@
#include "base/json/json_parser.h"
#include <cmath>
+#include <memory>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
@@ -44,7 +44,7 @@
// First deep copy to convert JSONStringValue to std::string and swap that
// copy with |other|, which contains the new contents of |this|.
- scoped_ptr<DictionaryValue> copy(DeepCopy());
+ std::unique_ptr<DictionaryValue> copy(DeepCopy());
copy->Swap(other);
// Then erase the contents of the current dictionary and swap in the
@@ -58,7 +58,7 @@
// the method below.
bool RemoveWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value>* out) override {
+ std::unique_ptr<Value>* out) override {
// If the caller won't take ownership of the removed value, just call up.
if (!out)
return DictionaryValue::RemoveWithoutPathExpansion(key, out);
@@ -67,7 +67,7 @@
// Otherwise, remove the value while its still "owned" by this and copy it
// to convert any JSONStringValues to std::string.
- scoped_ptr<Value> out_owned;
+ std::unique_ptr<Value> out_owned;
if (!DictionaryValue::RemoveWithoutPathExpansion(key, &out_owned))
return false;
@@ -77,7 +77,7 @@
}
private:
- scoped_ptr<std::string> json_;
+ std::unique_ptr<std::string> json_;
DISALLOW_COPY_AND_ASSIGN(DictionaryHiddenRootValue);
};
@@ -94,7 +94,7 @@
// First deep copy to convert JSONStringValue to std::string and swap that
// copy with |other|, which contains the new contents of |this|.
- scoped_ptr<ListValue> copy(DeepCopy());
+ std::unique_ptr<ListValue> copy(DeepCopy());
copy->Swap(other);
// Then erase the contents of the current list and swap in the new contents,
@@ -104,7 +104,7 @@
ListValue::Swap(copy.get());
}
- bool Remove(size_t index, scoped_ptr<Value>* out) override {
+ bool Remove(size_t index, std::unique_ptr<Value>* out) override {
// If the caller won't take ownership of the removed value, just call up.
if (!out)
return ListValue::Remove(index, out);
@@ -113,7 +113,7 @@
// Otherwise, remove the value while its still "owned" by this and copy it
// to convert any JSONStringValues to std::string.
- scoped_ptr<Value> out_owned;
+ std::unique_ptr<Value> out_owned;
if (!ListValue::Remove(index, &out_owned))
return false;
@@ -123,7 +123,7 @@
}
private:
- scoped_ptr<std::string> json_;
+ std::unique_ptr<std::string> json_;
DISALLOW_COPY_AND_ASSIGN(ListHiddenRootValue);
};
@@ -204,7 +204,7 @@
}
Value* JSONParser::Parse(const StringPiece& input) {
- scoped_ptr<std::string> input_copy;
+ std::unique_ptr<std::string> input_copy;
// If the children of a JSON root can be detached, then hidden roots cannot
// be used, so do not bother copying the input because StringPiece will not
// be used anywhere.
@@ -235,7 +235,7 @@
}
// Parse the first and any nested tokens.
- scoped_ptr<Value> root(ParseNextToken());
+ std::unique_ptr<Value> root(ParseNextToken());
if (!root.get())
return NULL;
@@ -499,7 +499,7 @@
return NULL;
}
- scoped_ptr<DictionaryValue> dict(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> dict(new DictionaryValue);
NextChar();
Token token = GetNextToken();
@@ -563,7 +563,7 @@
return NULL;
}
- scoped_ptr<ListValue> list(new ListValue);
+ std::unique_ptr<ListValue> list(new ListValue);
NextChar();
Token token = GetNextToken();
diff --git a/base/json/json_parser.h b/base/json/json_parser.h
index fc04594..304edd1 100644
--- a/base/json/json_parser.h
+++ b/base/json/json_parser.h
@@ -133,7 +133,7 @@
size_t length_;
// The copied string representation. NULL until Convert() is called.
- // Strong. scoped_ptr<T> has too much of an overhead here.
+ // Strong. std::unique_ptr<T> has too much of an overhead here.
std::string* string_;
};
diff --git a/base/json/json_parser_unittest.cc b/base/json/json_parser_unittest.cc
index da86b33..30255ca 100644
--- a/base/json/json_parser_unittest.cc
+++ b/base/json/json_parser_unittest.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,7 +35,7 @@
TEST_F(JSONParserTest, NextChar) {
std::string input("Hello world");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
EXPECT_EQ('H', *parser->pos_);
for (size_t i = 1; i < input.length(); ++i) {
@@ -45,8 +46,8 @@
TEST_F(JSONParserTest, ConsumeString) {
std::string input("\"test\",|");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
- scoped_ptr<Value> value(parser->ConsumeString());
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<Value> value(parser->ConsumeString());
EXPECT_EQ('"', *parser->pos_);
TestLastThree(parser.get());
@@ -59,8 +60,8 @@
TEST_F(JSONParserTest, ConsumeList) {
std::string input("[true, false],|");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
- scoped_ptr<Value> value(parser->ConsumeList());
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<Value> value(parser->ConsumeList());
EXPECT_EQ(']', *parser->pos_);
TestLastThree(parser.get());
@@ -73,8 +74,8 @@
TEST_F(JSONParserTest, ConsumeDictionary) {
std::string input("{\"abc\":\"def\"},|");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
- scoped_ptr<Value> value(parser->ConsumeDictionary());
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<Value> value(parser->ConsumeDictionary());
EXPECT_EQ('}', *parser->pos_);
TestLastThree(parser.get());
@@ -90,8 +91,8 @@
TEST_F(JSONParserTest, ConsumeLiterals) {
// Literal |true|.
std::string input("true,|");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
- scoped_ptr<Value> value(parser->ConsumeLiteral());
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<Value> value(parser->ConsumeLiteral());
EXPECT_EQ('e', *parser->pos_);
TestLastThree(parser.get());
@@ -128,8 +129,8 @@
TEST_F(JSONParserTest, ConsumeNumbers) {
// Integer.
std::string input("1234,|");
- scoped_ptr<JSONParser> parser(NewTestParser(input));
- scoped_ptr<Value> value(parser->ConsumeNumber());
+ std::unique_ptr<JSONParser> parser(NewTestParser(input));
+ std::unique_ptr<Value> value(parser->ConsumeNumber());
EXPECT_EQ('4', *parser->pos_);
TestLastThree(parser.get());
@@ -205,7 +206,7 @@
// Error strings should not be modified in case of success.
std::string error_message;
int error_code = 0;
- scoped_ptr<Value> root = JSONReader::ReadAndReturnError(
+ std::unique_ptr<Value> root = JSONReader::ReadAndReturnError(
"[42]", JSON_PARSE_RFC, &error_code, &error_message);
EXPECT_TRUE(error_message.empty());
EXPECT_EQ(0, error_code);
@@ -309,7 +310,7 @@
"[\"😇\",[],[],[],{\"google:suggesttype\":[]}]";
std::string error_message;
int error_code = 0;
- scoped_ptr<Value> root = JSONReader::ReadAndReturnError(
+ std::unique_ptr<Value> root = JSONReader::ReadAndReturnError(
kUtf8Data, JSON_PARSE_RFC, &error_code, &error_message);
EXPECT_TRUE(root.get()) << error_message;
}
diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc
index 3ab5f75..983508c 100644
--- a/base/json/json_reader.cc
+++ b/base/json/json_reader.cc
@@ -6,6 +6,7 @@
#include "base/json/json_parser.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
namespace base {
@@ -43,27 +44,28 @@
}
// static
-scoped_ptr<Value> JSONReader::Read(const StringPiece& json) {
+std::unique_ptr<Value> JSONReader::Read(const StringPiece& json) {
internal::JSONParser parser(JSON_PARSE_RFC);
- return make_scoped_ptr(parser.Parse(json));
+ return WrapUnique(parser.Parse(json));
}
// static
-scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) {
+std::unique_ptr<Value> JSONReader::Read(const StringPiece& json, int options) {
internal::JSONParser parser(options);
- return make_scoped_ptr(parser.Parse(json));
+ return WrapUnique(parser.Parse(json));
}
// static
-scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json,
- int options,
- int* error_code_out,
- std::string* error_msg_out,
- int* error_line_out,
- int* error_column_out) {
+std::unique_ptr<Value> JSONReader::ReadAndReturnError(
+ const StringPiece& json,
+ int options,
+ int* error_code_out,
+ std::string* error_msg_out,
+ int* error_line_out,
+ int* error_column_out) {
internal::JSONParser parser(options);
- scoped_ptr<Value> root(parser.Parse(json));
+ std::unique_ptr<Value> root(parser.Parse(json));
if (!root) {
if (error_code_out)
*error_code_out = parser.error_code();
@@ -105,8 +107,8 @@
}
}
-scoped_ptr<Value> JSONReader::ReadToValue(const std::string& json) {
- return make_scoped_ptr(parser_->Parse(json));
+std::unique_ptr<Value> JSONReader::ReadToValue(const std::string& json) {
+ return WrapUnique(parser_->Parse(json));
}
JSONReader::JsonParseError JSONReader::error_code() const {
diff --git a/base/json/json_reader.h b/base/json/json_reader.h
index c6bcb52..7b5b3b0 100644
--- a/base/json/json_reader.h
+++ b/base/json/json_reader.h
@@ -28,10 +28,10 @@
#ifndef BASE_JSON_JSON_READER_H_
#define BASE_JSON_JSON_READER_H_
+#include <memory>
#include <string>
#include "base/base_export.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
namespace base {
@@ -93,30 +93,31 @@
// Reads and parses |json|, returning a Value. The caller owns the returned
// instance. If |json| is not a properly formed JSON string, returns NULL.
- static scoped_ptr<Value> Read(const StringPiece& json);
+ static std::unique_ptr<Value> Read(const StringPiece& json);
// Reads and parses |json|, returning a Value owned by the caller. The
// parser respects the given |options|. If the input is not properly formed,
// returns NULL.
- static scoped_ptr<Value> Read(const StringPiece& json, int options);
+ static std::unique_ptr<Value> Read(const StringPiece& json, int options);
// Reads and parses |json| like Read(). |error_code_out| and |error_msg_out|
// are optional. If specified and NULL is returned, they will be populated
// an error code and a formatted error message (including error location if
// appropriate). Otherwise, they will be unmodified.
- static scoped_ptr<Value> ReadAndReturnError(const StringPiece& json,
- int options, // JSONParserOptions
- int* error_code_out,
- std::string* error_msg_out,
- int* error_line_out = nullptr,
- int* error_column_out = nullptr);
+ static std::unique_ptr<Value> ReadAndReturnError(
+ const StringPiece& json,
+ int options, // JSONParserOptions
+ int* error_code_out,
+ std::string* error_msg_out,
+ int* error_line_out = nullptr,
+ int* error_column_out = nullptr);
// Converts a JSON parse error code into a human readable message.
// Returns an empty string if error_code is JSON_NO_ERROR.
static std::string ErrorCodeToString(JsonParseError error_code);
// Parses an input string into a Value that is owned by the caller.
- scoped_ptr<Value> ReadToValue(const std::string& json);
+ std::unique_ptr<Value> ReadToValue(const std::string& json);
// Returns the error code if the last call to ReadToValue() failed.
// Returns JSON_NO_ERROR otherwise.
@@ -127,7 +128,7 @@
std::string GetErrorMessage() const;
private:
- scoped_ptr<internal::JSONParser> parser_;
+ std::unique_ptr<internal::JSONParser> parser_;
};
} // namespace base
diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc
index 21eec4a..1a62356 100644
--- a/base/json/json_reader_unittest.cc
+++ b/base/json/json_reader_unittest.cc
@@ -6,11 +6,12 @@
#include <stddef.h>
+#include <memory>
+
#include "base/base_paths.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
@@ -22,7 +23,7 @@
TEST(JSONReaderTest, Reading) {
// some whitespace checking
- scoped_ptr<Value> root = JSONReader().ReadToValue(" null ");
+ std::unique_ptr<Value> root = JSONReader().ReadToValue(" null ");
ASSERT_TRUE(root.get());
EXPECT_TRUE(root->IsType(Value::TYPE_NULL));
@@ -251,7 +252,7 @@
EXPECT_EQ(3U, list->GetSize());
// Test with trailing comma. Should be parsed the same as above.
- scoped_ptr<Value> root2 =
+ std::unique_ptr<Value> root2 =
JSONReader::Read("[true, false, null, ]", JSON_ALLOW_TRAILING_COMMAS);
EXPECT_TRUE(root->Equals(root2.get()));
@@ -553,7 +554,7 @@
path.Append(FILE_PATH_LITERAL("bom_feff.json")), &input));
JSONReader reader;
- scoped_ptr<Value> root(reader.ReadToValue(input));
+ std::unique_ptr<Value> root(reader.ReadToValue(input));
ASSERT_TRUE(root.get()) << reader.GetErrorMessage();
EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
}
@@ -561,15 +562,15 @@
// Tests that the root of a JSON object can be deleted safely while its
// children outlive it.
TEST(JSONReaderTest, StringOptimizations) {
- scoped_ptr<Value> dict_literal_0;
- scoped_ptr<Value> dict_literal_1;
- scoped_ptr<Value> dict_string_0;
- scoped_ptr<Value> dict_string_1;
- scoped_ptr<Value> list_value_0;
- scoped_ptr<Value> list_value_1;
+ std::unique_ptr<Value> dict_literal_0;
+ std::unique_ptr<Value> dict_literal_1;
+ std::unique_ptr<Value> dict_string_0;
+ std::unique_ptr<Value> dict_string_1;
+ std::unique_ptr<Value> list_value_0;
+ std::unique_ptr<Value> list_value_1;
{
- scoped_ptr<Value> root = JSONReader::Read(
+ std::unique_ptr<Value> root = JSONReader::Read(
"{"
" \"test\": {"
" \"foo\": true,"
diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc
index af7e010..cd786db 100644
--- a/base/json/json_string_value_serializer.cc
+++ b/base/json/json_string_value_serializer.cc
@@ -48,7 +48,7 @@
JSONStringValueDeserializer::~JSONStringValueDeserializer() {}
-scoped_ptr<Value> JSONStringValueDeserializer::Deserialize(
+std::unique_ptr<Value> JSONStringValueDeserializer::Deserialize(
int* error_code,
std::string* error_str) {
return base::JSONReader::ReadAndReturnError(
diff --git a/base/json/json_string_value_serializer.h b/base/json/json_string_value_serializer.h
index 2459f48..a97da23 100644
--- a/base/json/json_string_value_serializer.h
+++ b/base/json/json_string_value_serializer.h
@@ -59,8 +59,8 @@
// If |error_message| is non-null, it will be filled in with a formatted
// error message including the location of the error if appropriate.
// The caller takes ownership of the returned value.
- scoped_ptr<base::Value> Deserialize(int* error_code,
- std::string* error_message) override;
+ std::unique_ptr<base::Value> Deserialize(int* error_code,
+ std::string* error_message) override;
void set_allow_trailing_comma(bool new_value) {
allow_trailing_comma_ = new_value;
diff --git a/base/json/json_value_converter.h b/base/json/json_value_converter.h
index a1e0d5b..4cca034 100644
--- a/base/json/json_value_converter.h
+++ b/base/json/json_value_converter.h
@@ -7,13 +7,13 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/base_export.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
@@ -131,7 +131,7 @@
private:
FieldType StructType::* field_pointer_;
- scoped_ptr<ValueConverter<FieldType> > value_converter_;
+ std::unique_ptr<ValueConverter<FieldType>> value_converter_;
DISALLOW_COPY_AND_ASSIGN(FieldConverter);
};
@@ -266,7 +266,7 @@
if (!list->Get(i, &element))
continue;
- scoped_ptr<Element> e(new Element);
+ std::unique_ptr<Element> e(new Element);
if (basic_converter_.Convert(*element, e.get())) {
field->push_back(e.release());
} else {
@@ -300,7 +300,7 @@
if (!list->Get(i, &element))
continue;
- scoped_ptr<NestedType> nested(new NestedType);
+ std::unique_ptr<NestedType> nested(new NestedType);
if (converter_.Convert(*element, nested.get())) {
field->push_back(nested.release());
} else {
@@ -337,7 +337,7 @@
if (!list->Get(i, &element))
continue;
- scoped_ptr<NestedType> nested(new NestedType);
+ std::unique_ptr<NestedType> nested(new NestedType);
if ((*convert_func_)(element, nested.get())) {
field->push_back(nested.release());
} else {
diff --git a/base/json/json_value_converter_unittest.cc b/base/json/json_value_converter_unittest.cc
index 9038610..56ade24 100644
--- a/base/json/json_value_converter_unittest.cc
+++ b/base/json/json_value_converter_unittest.cc
@@ -4,11 +4,11 @@
#include "base/json/json_value_converter.h"
+#include <memory>
#include <string>
#include <vector>
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
@@ -106,7 +106,7 @@
" \"ints\": [1, 2]"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
SimpleMessage message;
base::JSONValueConverter<SimpleMessage> converter;
EXPECT_TRUE(converter.Convert(*value.get(), &message));
@@ -148,7 +148,7 @@
" }]\n"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
NestedMessage message;
base::JSONValueConverter<NestedMessage> converter;
EXPECT_TRUE(converter.Convert(*value.get(), &message));
@@ -190,7 +190,7 @@
" \"ints\": [1, 2]"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
SimpleMessage message;
base::JSONValueConverter<SimpleMessage> converter;
EXPECT_FALSE(converter.Convert(*value.get(), &message));
@@ -206,7 +206,7 @@
" \"ints\": [1, 2]"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
SimpleMessage message;
base::JSONValueConverter<SimpleMessage> converter;
// Convert() still succeeds even if the input doesn't have "bar" field.
@@ -229,7 +229,7 @@
" \"ints\": [1, 2]"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
SimpleMessage message;
base::JSONValueConverter<SimpleMessage> converter;
EXPECT_FALSE(converter.Convert(*value.get(), &message));
@@ -246,7 +246,7 @@
" \"ints\": [1, false]"
"}\n";
- scoped_ptr<Value> value = base::JSONReader::Read(normal_data);
+ std::unique_ptr<Value> value = base::JSONReader::Read(normal_data);
SimpleMessage message;
base::JSONValueConverter<SimpleMessage> converter;
EXPECT_FALSE(converter.Convert(*value.get(), &message));
diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc
index a8531f0..77d015c 100644
--- a/base/json/json_value_serializer_unittest.cc
+++ b/base/json/json_value_serializer_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <string>
#include "base/files/file_util.h"
@@ -10,7 +11,6 @@
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
@@ -76,7 +76,7 @@
}
void ValidateJsonList(const std::string& json) {
- scoped_ptr<Value> root = JSONReader::Read(json);
+ std::unique_ptr<Value> root = JSONReader::Read(json);
ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
@@ -94,7 +94,7 @@
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -113,7 +113,7 @@
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -130,7 +130,7 @@
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
str_deserializer.Deserialize(&error_code, &error_message);
ASSERT_FALSE(value.get());
ASSERT_NE(0, error_code);
@@ -158,7 +158,7 @@
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
file_deserializer.Deserialize(&error_code, &error_message);
ASSERT_TRUE(value.get());
ASSERT_EQ(0, error_code);
@@ -183,7 +183,7 @@
// This must fail without the proper flag.
int error_code = 0;
std::string error_message;
- scoped_ptr<Value> value =
+ std::unique_ptr<Value> value =
file_deserializer.Deserialize(&error_code, &error_message);
ASSERT_FALSE(value.get());
ASSERT_NE(0, error_code);
@@ -198,8 +198,8 @@
}
TEST(JSONValueDeserializerTest, AllowTrailingComma) {
- scoped_ptr<Value> root;
- scoped_ptr<Value> root_expected;
+ std::unique_ptr<Value> root;
+ std::unique_ptr<Value> root_expected;
static const char kTestWithCommas[] = "{\"key\": [true,],}";
static const char kTestNoCommas[] = "{\"key\": [true]}";
@@ -217,7 +217,7 @@
static const char kOriginalSerialization[] =
"{\"bool\":true,\"double\":3.14,\"int\":42,\"list\":[1,2],\"null\":null}";
JSONStringValueDeserializer deserializer(kOriginalSerialization);
- scoped_ptr<Value> root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
@@ -327,7 +327,7 @@
// escaped ascii text -> json
JSONStringValueDeserializer deserializer(kExpected);
- scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
@@ -351,7 +351,7 @@
// escaped ascii text -> json
JSONStringValueDeserializer deserializer(kExpected);
- scoped_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<Value> deserial_root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(deserial_root.get());
DictionaryValue* dict_root =
static_cast<DictionaryValue*>(deserial_root.get());
@@ -378,7 +378,7 @@
ValidateJsonList("[ 1 //// ,2\r\n ]");
// It's ok to have a comment in a string.
- scoped_ptr<Value> root = JSONReader::Read("[\"// ok\\n /* foo */ \"]");
+ std::unique_ptr<Value> root = JSONReader::Read("[\"// ok\\n /* foo */ \"]");
ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST));
ListValue* list = static_cast<ListValue*>(root.get());
ASSERT_EQ(1U, list->GetSize());
@@ -413,7 +413,7 @@
ASSERT_TRUE(PathExists(original_file_path));
JSONFileValueDeserializer deserializer(original_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
@@ -461,7 +461,7 @@
ASSERT_TRUE(PathExists(original_file_path));
JSONFileValueDeserializer deserializer(original_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
@@ -486,7 +486,7 @@
FILE_PATH_LITERAL("serializer_test_nowhitespace.json"));
ASSERT_TRUE(PathExists(source_file_path));
JSONFileValueDeserializer deserializer(source_file_path);
- scoped_ptr<Value> root;
+ std::unique_ptr<Value> root;
root = deserializer.Deserialize(NULL, NULL);
ASSERT_TRUE(root.get());
}
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc
index a62b3ba..37ad268 100644
--- a/base/json/json_writer_unittest.cc
+++ b/base/json/json_writer_unittest.cc
@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "base/json/json_writer.h"
+
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -55,11 +57,11 @@
// Writer unittests like empty list/dict nesting,
// list list nesting, etc.
DictionaryValue root_dict;
- scoped_ptr<ListValue> list(new ListValue());
- scoped_ptr<DictionaryValue> inner_dict(new DictionaryValue());
+ std::unique_ptr<ListValue> list(new ListValue());
+ std::unique_ptr<DictionaryValue> inner_dict(new DictionaryValue());
inner_dict->SetInteger("inner int", 10);
list->Append(std::move(inner_dict));
- list->Append(make_scoped_ptr(new ListValue()));
+ list->Append(WrapUnique(new ListValue()));
list->AppendBoolean(true);
root_dict.Set("list", std::move(list));
@@ -91,7 +93,7 @@
DictionaryValue period_dict;
period_dict.SetIntegerWithoutPathExpansion("a.b", 3);
period_dict.SetIntegerWithoutPathExpansion("c", 2);
- scoped_ptr<DictionaryValue> period_dict2(new DictionaryValue());
+ std::unique_ptr<DictionaryValue> period_dict2(new DictionaryValue());
period_dict2->SetIntegerWithoutPathExpansion("g.h.i.j", 1);
period_dict.SetWithoutPathExpansion("d.e.f", std::move(period_dict2));
EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js));
@@ -109,7 +111,7 @@
// Binary values should return errors unless suppressed via the
// OPTIONS_OMIT_BINARY_VALUES flag.
- scoped_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
+ std::unique_ptr<Value> root(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
EXPECT_FALSE(JSONWriter::Write(*root, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
*root, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
@@ -117,9 +119,9 @@
ListValue binary_list;
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
- binary_list.Append(make_scoped_ptr(new FundamentalValue(5)));
+ binary_list.Append(WrapUnique(new FundamentalValue(5)));
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
- binary_list.Append(make_scoped_ptr(new FundamentalValue(2)));
+ binary_list.Append(WrapUnique(new FundamentalValue(2)));
binary_list.Append(BinaryValue::CreateWithCopiedBuffer("asdf", 4));
EXPECT_FALSE(JSONWriter::Write(binary_list, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
@@ -128,13 +130,13 @@
DictionaryValue binary_dict;
binary_dict.Set(
- "a", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
+ "a", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
binary_dict.SetInteger("b", 5);
binary_dict.Set(
- "c", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
+ "c", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
binary_dict.SetInteger("d", 2);
binary_dict.Set(
- "e", make_scoped_ptr(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
+ "e", WrapUnique(BinaryValue::CreateWithCopiedBuffer("asdf", 4)));
EXPECT_FALSE(JSONWriter::Write(binary_dict, &output_js));
EXPECT_TRUE(JSONWriter::WriteWithOptions(
binary_dict, JSONWriter::OPTIONS_OMIT_BINARY_VALUES, &output_js));
diff --git a/base/linux_util.cc b/base/linux_util.cc
index 744a231..74ac98f 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -13,11 +13,11 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/process/launch.h"
#include "base/strings/string_util.h"
@@ -155,7 +155,7 @@
}
closedir(task);
- scoped_ptr<char[]> syscall_data(new char[expected_data.length()]);
+ std::unique_ptr<char[]> syscall_data(new char[expected_data.length()]);
for (std::vector<pid_t>::const_iterator
i = tids.begin(); i != tids.end(); ++i) {
const pid_t current_tid = *i;
diff --git a/base/macros.h b/base/macros.h
index 46ee1da..554ea43 100644
--- a/base/macros.h
+++ b/base/macros.h
@@ -52,7 +52,7 @@
// really sure you don't want to do anything with the return value of a function
// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
//
-// scoped_ptr<MyType> my_var = ...;
+// std::unique_ptr<MyType> my_var = ...;
// if (TakeOwnership(my_var.get()) == SUCCESS)
// ignore_result(my_var.release());
//
diff --git a/base/md5_unittest.cc b/base/md5_unittest.cc
index 3926b66..b27efe9 100644
--- a/base/md5_unittest.cc
+++ b/base/md5_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/md5.h"
+
#include <string.h>
+
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
-#include "base/md5.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -66,7 +68,7 @@
TEST(MD5, MD5SumLongData) {
const int length = 10 * 1024 * 1024 + 1;
- scoped_ptr<char[]> data(new char[length]);
+ std::unique_ptr<char[]> data(new char[length]);
for (int i = 0; i < length; ++i)
data[i] = i & 0xFF;
@@ -108,7 +110,7 @@
MD5Init(&ctx);
const int length = 10 * 1024 * 1024 + 1;
- scoped_ptr<char[]> data(new char[length]);
+ std::unique_ptr<char[]> data(new char[length]);
for (int i = 0; i < length; ++i)
data[i] = i & 0xFF;
diff --git a/base/memory/aligned_memory.h b/base/memory/aligned_memory.h
index bb7bd87..f6b8395 100644
--- a/base/memory/aligned_memory.h
+++ b/base/memory/aligned_memory.h
@@ -28,7 +28,7 @@
//
// Or using scoped_ptr:
//
-// scoped_ptr<float, AlignedFreeDeleter> my_array(
+// std::unique_ptr<float, AlignedFreeDeleter> my_array(
// static_cast<float*>(AlignedAlloc(size, alignment)));
#ifndef BASE_MEMORY_ALIGNED_MEMORY_H_
@@ -105,7 +105,7 @@
}
// Deleter for use with scoped_ptr. E.g., use as
-// scoped_ptr<Foo, base::AlignedFreeDeleter> foo;
+// std::unique_ptr<Foo, base::AlignedFreeDeleter> foo;
struct AlignedFreeDeleter {
inline void operator()(void* ptr) const {
AlignedFree(ptr);
diff --git a/base/memory/aligned_memory_unittest.cc b/base/memory/aligned_memory_unittest.cc
index b89e341..abe0cf3 100644
--- a/base/memory/aligned_memory_unittest.cc
+++ b/base/memory/aligned_memory_unittest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/memory/aligned_memory.h"
-#include "base/memory/scoped_ptr.h"
+
+#include <memory>
+
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -92,7 +94,7 @@
}
TEST(AlignedMemoryTest, ScopedDynamicAllocation) {
- scoped_ptr<float, base::AlignedFreeDeleter> p(
+ std::unique_ptr<float, base::AlignedFreeDeleter> p(
static_cast<float*>(base::AlignedAlloc(8, 8)));
EXPECT_TRUE(p.get());
EXPECT_ALIGNED(p.get(), 8);
diff --git a/base/memory/discardable_memory_allocator.h b/base/memory/discardable_memory_allocator.h
index ea7947e..ad73f08 100644
--- a/base/memory/discardable_memory_allocator.h
+++ b/base/memory/discardable_memory_allocator.h
@@ -7,8 +7,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/base_export.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
class DiscardableMemory;
@@ -22,7 +23,7 @@
// Ownership of |instance| remains with the caller.
static void SetInstance(DiscardableMemoryAllocator* allocator);
- virtual scoped_ptr<DiscardableMemory> AllocateLockedDiscardableMemory(
+ virtual std::unique_ptr<DiscardableMemory> AllocateLockedDiscardableMemory(
size_t size) = 0;
protected:
diff --git a/base/memory/memory_pressure_listener_unittest.cc b/base/memory/memory_pressure_listener_unittest.cc
index 38d429d..acff1fd 100644
--- a/base/memory/memory_pressure_listener_unittest.cc
+++ b/base/memory/memory_pressure_listener_unittest.cc
@@ -46,8 +46,8 @@
MOCK_METHOD1(OnMemoryPressure,
void(MemoryPressureListener::MemoryPressureLevel));
- scoped_ptr<MessageLoopForUI> message_loop_;
- scoped_ptr<MemoryPressureListener> listener_;
+ std::unique_ptr<MessageLoopForUI> message_loop_;
+ std::unique_ptr<MemoryPressureListener> listener_;
};
TEST_F(MemoryPressureListenerTest, NotifyMemoryPressure) {
diff --git a/base/memory/memory_pressure_monitor_chromeos_unittest.cc b/base/memory/memory_pressure_monitor_chromeos_unittest.cc
index a82cef4..4333cd9 100644
--- a/base/memory/memory_pressure_monitor_chromeos_unittest.cc
+++ b/base/memory/memory_pressure_monitor_chromeos_unittest.cc
@@ -74,9 +74,9 @@
// for the correct behavior on event reposting as well as state updates.
TEST(ChromeOSMemoryPressureMonitorTest, CheckMemoryPressure) {
base::MessageLoopForUI message_loop;
- scoped_ptr<TestMemoryPressureMonitor> monitor(
+ std::unique_ptr<TestMemoryPressureMonitor> monitor(
new TestMemoryPressureMonitor);
- scoped_ptr<MemoryPressureListener> listener(
+ std::unique_ptr<MemoryPressureListener> listener(
new MemoryPressureListener(base::Bind(&OnMemoryPressure)));
// Checking the memory pressure while 0% are used should not produce any
// events.
diff --git a/base/memory/scoped_vector.h b/base/memory/scoped_vector.h
index 6730612..adbab8c 100644
--- a/base/memory/scoped_vector.h
+++ b/base/memory/scoped_vector.h
@@ -7,10 +7,10 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/move.h"
#include "base/stl_util.h"
@@ -69,7 +69,7 @@
reference back() { return v_.back(); }
void push_back(T* elem) { v_.push_back(elem); }
- void push_back(scoped_ptr<T> elem) { v_.push_back(elem.release()); }
+ void push_back(std::unique_ptr<T> elem) { v_.push_back(elem.release()); }
void pop_back() {
DCHECK(!empty());
@@ -110,7 +110,7 @@
return v_.insert(position, x);
}
- iterator insert(iterator position, scoped_ptr<T> x) {
+ iterator insert(iterator position, std::unique_ptr<T> x) {
return v_.insert(position, x.release());
}
diff --git a/base/memory/scoped_vector_unittest.cc b/base/memory/scoped_vector_unittest.cc
index 8638ece..ea3dcdc 100644
--- a/base/memory/scoped_vector_unittest.cc
+++ b/base/memory/scoped_vector_unittest.cc
@@ -4,12 +4,12 @@
#include "base/memory/scoped_vector.h"
+#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -112,7 +112,7 @@
private:
LifeCycleState life_cycle_state_;
- scoped_ptr<LifeCycleObject> constructed_life_cycle_object_;
+ std::unique_ptr<LifeCycleObject> constructed_life_cycle_object_;
DISALLOW_COPY_AND_ASSIGN(LifeCycleWatcher);
};
@@ -325,7 +325,7 @@
// Assertions for push_back(scoped_ptr).
TEST(ScopedVectorTest, PushBackScopedPtr) {
int delete_counter = 0;
- scoped_ptr<DeleteCounter> elem(new DeleteCounter(&delete_counter));
+ std::unique_ptr<DeleteCounter> elem(new DeleteCounter(&delete_counter));
EXPECT_EQ(0, delete_counter);
{
ScopedVector<DeleteCounter> v;
diff --git a/base/memory/shared_memory_unittest.cc b/base/memory/shared_memory_unittest.cc
index 059e019..948a9d0 100644
--- a/base/memory/shared_memory_unittest.cc
+++ b/base/memory/shared_memory_unittest.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/shared_memory.h"
+
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+
#include "base/atomicops.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/shared_memory.h"
#include "base/memory/shared_memory_handle.h"
#include "base/process/kill.h"
#include "base/rand_util.h"
@@ -246,8 +248,8 @@
int threadcounts[] = { 1, kNumThreads };
for (size_t i = 0; i < arraysize(threadcounts); i++) {
int numthreads = threadcounts[i];
- scoped_ptr<PlatformThreadHandle[]> thread_handles;
- scoped_ptr<MultipleThreadMain*[]> thread_delegates;
+ std::unique_ptr<PlatformThreadHandle[]> thread_handles;
+ std::unique_ptr<MultipleThreadMain* []> thread_delegates;
thread_handles.reset(new PlatformThreadHandle[numthreads]);
thread_delegates.reset(new MultipleThreadMain*[numthreads]);
@@ -279,8 +281,8 @@
bool rv;
const uint32_t kDataSize = 8192;
- scoped_ptr<SharedMemory[]> memories(new SharedMemory[count]);
- scoped_ptr<int*[]> pointers(new int*[count]);
+ std::unique_ptr<SharedMemory[]> memories(new SharedMemory[count]);
+ std::unique_ptr<int* []> pointers(new int*[count]);
ASSERT_TRUE(memories.get());
ASSERT_TRUE(pointers.get());
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc
index 5f9b6b6..df398d9 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -4,12 +4,12 @@
#include "base/memory/weak_ptr.h"
+#include <memory>
#include <string>
#include "base/bind.h"
#include "base/debug/leak_annotations.h"
#include "base/location.h"
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -327,7 +327,7 @@
// Test that it is OK to create an object that supports WeakPtr on one thread,
// but use it on another. This tests that we do not trip runtime checks that
// ensure that a WeakPtr is not used by multiple threads.
- scoped_ptr<Target> target(OffThreadObjectCreator<Target>::NewObject());
+ std::unique_ptr<Target> target(OffThreadObjectCreator<Target>::NewObject());
WeakPtr<Target> weak_ptr = target->AsWeakPtr();
EXPECT_EQ(target.get(), weak_ptr.get());
}
@@ -336,7 +336,7 @@
// Test that it is OK to create an object that has a WeakPtr member on one
// thread, but use it on another. This tests that we do not trip runtime
// checks that ensure that a WeakPtr is not used by multiple threads.
- scoped_ptr<Arrow> arrow(OffThreadObjectCreator<Arrow>::NewObject());
+ std::unique_ptr<Arrow> arrow(OffThreadObjectCreator<Arrow>::NewObject());
Target target;
arrow->target = target.AsWeakPtr();
EXPECT_EQ(&target, arrow->target.get());
@@ -409,7 +409,7 @@
background.Start();
Arrow arrow;
- scoped_ptr<TargetWithFactory> target(new TargetWithFactory);
+ std::unique_ptr<TargetWithFactory> target(new TargetWithFactory);
// Bind to main thread.
arrow.target = target->factory.GetWeakPtr();
@@ -579,7 +579,7 @@
// (introduces deadlock on Linux).
::testing::FLAGS_gtest_death_test_style = "threadsafe";
- scoped_ptr<Target> target(new Target());
+ std::unique_ptr<Target> target(new Target());
// Main thread creates an arrow referencing the Target.
Arrow arrow;
@@ -603,7 +603,7 @@
// (introduces deadlock on Linux).
::testing::FLAGS_gtest_death_test_style = "threadsafe";
- scoped_ptr<Target> target(new Target());
+ std::unique_ptr<Target> target(new Target());
// Main thread creates an arrow referencing the Target, and references it, so
// that it becomes bound to the thread.
@@ -622,7 +622,7 @@
// (introduces deadlock on Linux).
::testing::FLAGS_gtest_death_test_style = "threadsafe";
- scoped_ptr<Target> target(new Target());
+ std::unique_ptr<Target> target(new Target());
// Main thread creates an arrow referencing the Target.
Arrow arrow;
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 04aa9a8..01e7512 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -5,13 +5,14 @@
#include "base/message_loop/message_loop.h"
#include <algorithm>
+#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_pump_default.h"
#include "base/metrics/histogram.h"
#include "base/metrics/statistics_recorder.h"
@@ -103,7 +104,7 @@
}
#endif // !defined(OS_NACL_SFI)
-scoped_ptr<MessagePump> ReturnPump(scoped_ptr<MessagePump> pump) {
+std::unique_ptr<MessagePump> ReturnPump(std::unique_ptr<MessagePump> pump) {
return pump;
}
@@ -127,7 +128,7 @@
BindToCurrentThread();
}
-MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump)
+MessageLoop::MessageLoop(std::unique_ptr<MessagePump> pump)
: MessageLoop(TYPE_CUSTOM, Bind(&ReturnPump, Passed(&pump))) {
BindToCurrentThread();
}
@@ -206,7 +207,7 @@
}
// static
-scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
+std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
// TODO(rvargas): Get rid of the OS guards.
#if defined(USE_GLIB) && !defined(OS_NACL)
typedef MessagePumpGlib MessagePumpForUI;
@@ -215,21 +216,22 @@
#endif
#if defined(OS_IOS) || defined(OS_MACOSX)
-#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create())
+#define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(MessagePumpMac::Create())
#elif defined(OS_NACL)
// Currently NaCl doesn't have a UI MessageLoop.
// TODO(abarth): Figure out if we need this.
-#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>()
+#define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>()
#else
-#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI())
+#define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(new MessagePumpForUI())
#endif
#if defined(OS_MACOSX)
// Use an OS native runloop on Mac to support timer coalescing.
- #define MESSAGE_PUMP_DEFAULT \
- scoped_ptr<MessagePump>(new MessagePumpCFRunLoop())
+#define MESSAGE_PUMP_DEFAULT \
+ std::unique_ptr<MessagePump>(new MessagePumpCFRunLoop())
#else
- #define MESSAGE_PUMP_DEFAULT scoped_ptr<MessagePump>(new MessagePumpDefault())
+#define MESSAGE_PUMP_DEFAULT \
+ std::unique_ptr<MessagePump>(new MessagePumpDefault())
#endif
if (type == MessageLoop::TYPE_UI) {
@@ -238,11 +240,11 @@
return MESSAGE_PUMP_UI;
}
if (type == MessageLoop::TYPE_IO)
- return scoped_ptr<MessagePump>(new MessagePumpForIO());
+ return std::unique_ptr<MessagePump>(new MessagePumpForIO());
#if defined(OS_ANDROID)
if (type == MessageLoop::TYPE_JAVA)
- return scoped_ptr<MessagePump>(new MessagePumpForUI());
+ return std::unique_ptr<MessagePump>(new MessagePumpForUI());
#endif
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
@@ -375,9 +377,10 @@
//------------------------------------------------------------------------------
// static
-scoped_ptr<MessageLoop> MessageLoop::CreateUnbound(
- Type type, MessagePumpFactoryCallback pump_factory) {
- return make_scoped_ptr(new MessageLoop(type, pump_factory));
+std::unique_ptr<MessageLoop> MessageLoop::CreateUnbound(
+ Type type,
+ MessagePumpFactoryCallback pump_factory) {
+ return WrapUnique(new MessageLoop(type, pump_factory));
}
MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory)
@@ -674,9 +677,8 @@
//------------------------------------------------------------------------------
// MessageLoopForUI
-MessageLoopForUI::MessageLoopForUI(scoped_ptr<MessagePump> pump)
- : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {
-}
+MessageLoopForUI::MessageLoopForUI(std::unique_ptr<MessagePump> pump)
+ : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {}
#if defined(OS_ANDROID)
void MessageLoopForUI::Start() {
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index ce960e1..802fae0 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -5,6 +5,7 @@
#ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
#define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
+#include <memory>
#include <queue>
#include <string>
@@ -15,7 +16,6 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/incoming_task_queue.h"
#include "base/message_loop/message_loop_task_runner.h"
#include "base/message_loop/message_pump.h"
@@ -115,7 +115,7 @@
explicit MessageLoop(Type type = TYPE_DEFAULT);
// Creates a TYPE_CUSTOM MessageLoop with the supplied MessagePump, which must
// be non-NULL.
- explicit MessageLoop(scoped_ptr<MessagePump> pump);
+ explicit MessageLoop(std::unique_ptr<MessagePump> pump);
~MessageLoop() override;
@@ -124,7 +124,7 @@
static void EnableHistogrammer(bool enable_histogrammer);
- typedef scoped_ptr<MessagePump> (MessagePumpFactory)();
+ typedef std::unique_ptr<MessagePump>(MessagePumpFactory)();
// Uses the given base::MessagePumpForUIFactory to override the default
// MessagePump implementation for 'TYPE_UI'. Returns true if the factory
// was successfully registered.
@@ -132,7 +132,7 @@
// Creates the default MessagePump based on |type|. Caller owns return
// value.
- static scoped_ptr<MessagePump> CreateMessagePumpForType(Type type);
+ static std::unique_ptr<MessagePump> CreateMessagePumpForType(Type type);
// A DestructionObserver is notified when the current MessageLoop is being
// destroyed. These observers are notified prior to MessageLoop::current()
// being changed to return NULL. This gives interested parties the chance to
@@ -397,9 +397,9 @@
//----------------------------------------------------------------------------
protected:
- scoped_ptr<MessagePump> pump_;
+ std::unique_ptr<MessagePump> pump_;
- using MessagePumpFactoryCallback = Callback<scoped_ptr<MessagePump>()>;
+ using MessagePumpFactoryCallback = Callback<std::unique_ptr<MessagePump>()>;
// Common protected constructor. Other constructors delegate the
// initialization to this constructor.
@@ -430,7 +430,7 @@
// thread the message loop runs on, before calling Run().
// Before BindToCurrentThread() is called, only Post*Task() functions can
// be called on the message loop.
- static scoped_ptr<MessageLoop> CreateUnbound(
+ static std::unique_ptr<MessageLoop> CreateUnbound(
Type type,
MessagePumpFactoryCallback pump_factory);
@@ -538,7 +538,7 @@
// The task runner associated with this message loop.
scoped_refptr<SingleThreadTaskRunner> task_runner_;
- scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
+ std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_;
template <class T, class R> friend class base::subtle::DeleteHelperInternal;
template <class T, class R> friend class base::subtle::ReleaseHelperInternal;
@@ -567,7 +567,7 @@
MessageLoopForUI() : MessageLoop(TYPE_UI) {
}
- explicit MessageLoopForUI(scoped_ptr<MessagePump> pump);
+ explicit MessageLoopForUI(std::unique_ptr<MessagePump> pump);
// Returns the MessageLoopForUI of the current thread.
static MessageLoopForUI* current() {
diff --git a/base/message_loop/message_loop_task_runner_unittest.cc b/base/message_loop/message_loop_task_runner_unittest.cc
index a0d84b7..51dfd11 100644
--- a/base/message_loop/message_loop_task_runner_unittest.cc
+++ b/base/message_loop/message_loop_task_runner_unittest.cc
@@ -4,10 +4,11 @@
#include "base/message_loop/message_loop_task_runner.h"
+#include <memory>
+
#include "base/atomic_sequence_num.h"
#include "base/bind.h"
#include "base/debug/leak_annotations.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_task_runner.h"
#include "base/synchronization/waitable_event.h"
@@ -88,7 +89,7 @@
static StaticAtomicSequenceNumber g_order;
- scoped_ptr<MessageLoop> current_loop_;
+ std::unique_ptr<MessageLoop> current_loop_;
Thread task_thread_;
private:
@@ -303,8 +304,8 @@
MessageLoopTaskRunnerThreadingTest* test_;
};
- scoped_ptr<Thread> io_thread_;
- scoped_ptr<Thread> file_thread_;
+ std::unique_ptr<Thread> io_thread_;
+ std::unique_ptr<Thread> file_thread_;
private:
mutable MessageLoop loop_;
@@ -330,7 +331,7 @@
}
TEST_F(MessageLoopTaskRunnerThreadingTest, PostTaskAfterThreadExits) {
- scoped_ptr<Thread> test_thread(
+ std::unique_ptr<Thread> test_thread(
new Thread("MessageLoopTaskRunnerThreadingTest_Dummy"));
test_thread->Start();
scoped_refptr<SingleThreadTaskRunner> task_runner =
@@ -345,7 +346,7 @@
TEST_F(MessageLoopTaskRunnerThreadingTest, PostTaskAfterThreadIsDeleted) {
scoped_refptr<SingleThreadTaskRunner> task_runner;
{
- scoped_ptr<Thread> test_thread(
+ std::unique_ptr<Thread> test_thread(
new Thread("MessageLoopTaskRunnerThreadingTest_Dummy"));
test_thread->Start();
task_runner = test_thread->task_runner();
diff --git a/base/message_loop/message_loop_test.cc b/base/message_loop/message_loop_test.cc
index ac50d64..c0e6481 100644
--- a/base/message_loop/message_loop_test.cc
+++ b/base/message_loop/message_loop_test.cc
@@ -91,7 +91,7 @@
} // namespace
void RunTest_PostTask(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Add tests to message loop
scoped_refptr<Foo> foo(new Foo());
@@ -121,7 +121,7 @@
}
void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that PostDelayedTask results in a delayed task.
@@ -144,7 +144,7 @@
}
void RunTest_PostDelayedTask_InDelayOrder(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that two tasks with different delays run in the right order.
@@ -169,7 +169,7 @@
}
void RunTest_PostDelayedTask_InPostOrder(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that two tasks with the same delay run in the order in which they
@@ -199,7 +199,7 @@
}
void RunTest_PostDelayedTask_InPostOrder_2(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that a delayed task still runs after a normal tasks even if the
@@ -226,7 +226,7 @@
}
void RunTest_PostDelayedTask_InPostOrder_3(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that a delayed task still runs after a pile of normal tasks. The key
@@ -254,7 +254,7 @@
}
void RunTest_PostDelayedTask_SharedTimer(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// Test that the interval of the timer, used to run the next delayed task, is
@@ -321,7 +321,7 @@
bool a_was_deleted = false;
bool b_was_deleted = false;
{
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
loop.PostTask(
FROM_HERE, Bind(&RecordDeletionProbe::Run,
@@ -341,7 +341,7 @@
bool b_was_deleted = false;
bool c_was_deleted = false;
{
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
// The scoped_refptr for each of the below is held either by the chained
// RecordDeletionProbe, or the bound RecordDeletionProbe::Run() callback.
@@ -368,7 +368,7 @@
}
void RunTest_Nesting(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
int depth = 100;
@@ -476,7 +476,7 @@
order->RecordEnd(QUITMESSAGELOOP, cookie);
}
void RunTest_RecursiveDenial1(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
@@ -523,7 +523,7 @@
}
void RunTest_RecursiveDenial3(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
@@ -564,7 +564,7 @@
}
void RunTest_RecursiveSupport1(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -597,7 +597,7 @@
// Tests that non nestable tasks run in FIFO if there are no nested loops.
void RunTest_NonNestableWithNoNesting(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -639,7 +639,7 @@
// Tests that non nestable tasks don't run when there's code in the call stack.
void RunTest_NonNestableInNestedLoop(MessagePumpFactory factory,
bool use_delayed) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -707,7 +707,7 @@
}
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_QuitNow(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -742,7 +742,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitTop(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -772,7 +772,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitNested(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -802,7 +802,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitBogus(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -835,7 +835,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitDeep(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -904,7 +904,7 @@
// Tests RunLoopQuit works before RunWithID.
void RunTest_RunLoopQuitOrderBefore(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -925,7 +925,7 @@
// Tests RunLoopQuit works during RunWithID.
void RunTest_RunLoopQuitOrderDuring(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -952,7 +952,7 @@
// Tests RunLoopQuit works after RunWithID.
void RunTest_RunLoopQuitOrderAfter(MessagePumpFactory factory) {
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
TaskList order;
@@ -1010,7 +1010,7 @@
// times to reproduce the bug.
void RunTest_RecursivePosts(MessagePumpFactory factory) {
const int kNumTimes = 1 << 17;
- scoped_ptr<MessagePump> pump(factory());
+ std::unique_ptr<MessagePump> pump(factory());
MessageLoop loop(std::move(pump));
loop.PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, kNumTimes));
loop.Run();
diff --git a/base/message_loop/message_loop_unittest.cc b/base/message_loop/message_loop_unittest.cc
index 7b31214..e0e46e2 100644
--- a/base/message_loop/message_loop_unittest.cc
+++ b/base/message_loop/message_loop_unittest.cc
@@ -41,15 +41,15 @@
namespace {
-scoped_ptr<MessagePump> TypeDefaultMessagePumpFactory() {
+std::unique_ptr<MessagePump> TypeDefaultMessagePumpFactory() {
return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_DEFAULT);
}
-scoped_ptr<MessagePump> TypeIOMessagePumpFactory() {
+std::unique_ptr<MessagePump> TypeIOMessagePumpFactory() {
return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_IO);
}
-scoped_ptr<MessagePump> TypeUIMessagePumpFactory() {
+std::unique_ptr<MessagePump> TypeUIMessagePumpFactory() {
return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_UI);
}
@@ -971,7 +971,7 @@
// It should be possible to delete an unbound message loop on a thread which
// already has another active loop. This happens when thread creation fails.
MessageLoop loop;
- scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound(
+ std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound(
MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback()));
unbound_loop.reset();
EXPECT_EQ(&loop, MessageLoop::current());
diff --git a/base/message_loop/message_pump_glib.h b/base/message_loop/message_pump_glib.h
index b94eeaf..a2b54d8 100644
--- a/base/message_loop/message_pump_glib.h
+++ b/base/message_loop/message_pump_glib.h
@@ -5,9 +5,10 @@
#ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
#define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_pump.h"
#include "base/observer_list.h"
#include "base/time/time.h"
@@ -69,7 +70,7 @@
int wakeup_pipe_read_;
int wakeup_pipe_write_;
// Use a scoped_ptr to avoid needing the definition of GPollFD in the header.
- scoped_ptr<GPollFD> wakeup_gpollfd_;
+ std::unique_ptr<GPollFD> wakeup_gpollfd_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
};
diff --git a/base/message_loop/message_pump_libevent.cc b/base/message_loop/message_pump_libevent.cc
index c0a02b2..d59a234 100644
--- a/base/message_loop/message_pump_libevent.cc
+++ b/base/message_loop/message_pump_libevent.cc
@@ -7,11 +7,12 @@
#include <errno.h>
#include <unistd.h>
+#include <memory>
+
#include "base/auto_reset.h"
#include "base/compiler_specific.h"
#include "base/files/file_util.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/posix/eintr_wrapper.h"
#include "base/third_party/libevent/event.h"
@@ -153,7 +154,7 @@
event_mask |= EV_WRITE;
}
- scoped_ptr<event> evt(controller->ReleaseEvent());
+ std::unique_ptr<event> evt(controller->ReleaseEvent());
if (evt.get() == NULL) {
// Ownership is transferred to the controller.
evt.reset(new event);
@@ -219,7 +220,7 @@
// event_base_loopexit() + EVLOOP_ONCE is leaky, see http://crbug.com/25641.
// Instead, make our own timer and reuse it on each call to event_base_loop().
- scoped_ptr<event> timer_event(new event);
+ std::unique_ptr<event> timer_event(new event);
for (;;) {
#if defined(OS_MACOSX)
diff --git a/base/message_loop/message_pump_libevent_unittest.cc b/base/message_loop/message_pump_libevent_unittest.cc
index eb30d53..81afa5e 100644
--- a/base/message_loop/message_pump_libevent_unittest.cc
+++ b/base/message_loop/message_pump_libevent_unittest.cc
@@ -6,10 +6,12 @@
#include <unistd.h>
+#include <memory>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_util.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/posix/eintr_wrapper.h"
#include "base/run_loop.h"
@@ -55,7 +57,7 @@
}
int pipefds_[2];
- scoped_ptr<MessageLoop> ui_loop_;
+ std::unique_ptr<MessageLoop> ui_loop_;
private:
Thread io_thread_;
@@ -95,7 +97,7 @@
}
TEST_F(MessagePumpLibeventTest, QuitOutsideOfRun) {
- scoped_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
+ std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
ASSERT_DEATH(pump->Quit(), "Check failed: in_run_. "
"Quit was called outside of Run!");
}
@@ -135,7 +137,7 @@
};
TEST_F(MessagePumpLibeventTest, DeleteWatcher) {
- scoped_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
+ std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
MessagePumpLibevent::FileDescriptorWatcher* watcher =
new MessagePumpLibevent::FileDescriptorWatcher;
DeleteWatcher delegate(watcher);
@@ -160,7 +162,7 @@
};
TEST_F(MessagePumpLibeventTest, StopWatcher) {
- scoped_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
+ std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
MessagePumpLibevent::FileDescriptorWatcher watcher;
StopWatcher delegate(&watcher);
pump->WatchFileDescriptor(pipefds_[1],
@@ -195,7 +197,7 @@
};
TEST_F(MessagePumpLibeventTest, NestedPumpWatcher) {
- scoped_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
+ std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent);
MessagePumpLibevent::FileDescriptorWatcher watcher;
NestedPumpWatcher delegate;
pump->WatchFileDescriptor(pipefds_[1],
@@ -242,12 +244,12 @@
ui_loop_.reset();
MessagePumpLibevent* pump = new MessagePumpLibevent; // owned by |loop|.
- MessageLoop loop(make_scoped_ptr(pump));
+ MessageLoop loop(WrapUnique(pump));
RunLoop run_loop;
MessagePumpLibevent::FileDescriptorWatcher controller;
QuitWatcher delegate(&controller, &run_loop);
WaitableEvent event(false /* manual_reset */, false /* initially_signaled */);
- scoped_ptr<WaitableEventWatcher> watcher(new WaitableEventWatcher);
+ std::unique_ptr<WaitableEventWatcher> watcher(new WaitableEventWatcher);
// Tell the pump to watch the pipe.
pump->WatchFileDescriptor(pipefds_[0], false, MessagePumpLibevent::WATCH_READ,
diff --git a/base/message_loop/message_pump_perftest.cc b/base/message_loop/message_pump_perftest.cc
index 789fc1f..edaf206 100644
--- a/base/message_loop/message_pump_perftest.cc
+++ b/base/message_loop/message_pump_perftest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/format_macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/scoped_vector.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/condition_variable.h"
@@ -87,7 +88,7 @@
target_->WaitUntilThreadStarted();
}
- std::vector<scoped_ptr<Thread>> scheduling_threads;
+ std::vector<std::unique_ptr<Thread>> scheduling_threads;
scheduling_times_.reset(new base::TimeDelta[num_scheduling_threads]);
scheduling_thread_times_.reset(new base::TimeDelta[num_scheduling_threads]);
min_batch_times_.reset(new base::TimeDelta[num_scheduling_threads]);
@@ -95,7 +96,7 @@
for (int i = 0; i < num_scheduling_threads; ++i) {
scheduling_threads.push_back(
- make_scoped_ptr(new Thread("posting thread")));
+ WrapUnique(new Thread("posting thread")));
scheduling_threads[i]->Start();
}
@@ -175,14 +176,14 @@
}
private:
- scoped_ptr<Thread> target_;
+ std::unique_ptr<Thread> target_;
#if defined(OS_ANDROID)
- scoped_ptr<android::JavaHandlerThread> java_thread_;
+ std::unique_ptr<android::JavaHandlerThread> java_thread_;
#endif
- scoped_ptr<base::TimeDelta[]> scheduling_times_;
- scoped_ptr<base::TimeDelta[]> scheduling_thread_times_;
- scoped_ptr<base::TimeDelta[]> min_batch_times_;
- scoped_ptr<base::TimeDelta[]> max_batch_times_;
+ std::unique_ptr<base::TimeDelta[]> scheduling_times_;
+ std::unique_ptr<base::TimeDelta[]> scheduling_thread_times_;
+ std::unique_ptr<base::TimeDelta[]> min_batch_times_;
+ std::unique_ptr<base::TimeDelta[]> max_batch_times_;
uint64_t counter_;
static const size_t kTargetTimeSec = 5;
@@ -256,7 +257,7 @@
void Run(int batch_size, int tasks_per_reload) {
base::TimeTicks start = base::TimeTicks::Now();
base::TimeTicks now;
- MessageLoop loop(scoped_ptr<MessagePump>(new FakeMessagePump));
+ MessageLoop loop(std::unique_ptr<MessagePump>(new FakeMessagePump));
scoped_refptr<internal::IncomingTaskQueue> queue(
new internal::IncomingTaskQueue(&loop));
uint32_t num_posted = 0;
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 95cf504..ef35385 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -514,7 +514,7 @@
// Entropy provider to be used for one-time randomized field trials. If NULL,
// one-time randomization is not supported.
- scoped_ptr<const FieldTrial::EntropyProvider> entropy_provider_;
+ std::unique_ptr<const FieldTrial::EntropyProvider> entropy_provider_;
// List of observers to be notified when a group is selected for a FieldTrial.
scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_;
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 35197e2..a48716f 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -18,6 +18,7 @@
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/persistent_histogram_allocator.h"
@@ -122,8 +123,8 @@
// Allocate the correct Histogram object off the heap (in case persistent
// memory is not available).
- virtual scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) {
- return make_scoped_ptr(new Histogram(name_, minimum_, maximum_, ranges));
+ virtual std::unique_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) {
+ return WrapUnique(new Histogram(name_, minimum_, maximum_, ranges));
}
// Perform any required datafill on the just-created histogram. If
@@ -176,7 +177,7 @@
// allocating from it fails, code below will allocate the histogram from
// the process heap.
PersistentHistogramAllocator::Reference histogram_ref = 0;
- scoped_ptr<HistogramBase> tentative_histogram;
+ std::unique_ptr<HistogramBase> tentative_histogram;
PersistentHistogramAllocator* allocator =
PersistentHistogramAllocator::GetGlobalAllocator();
if (allocator) {
@@ -277,7 +278,7 @@
flags);
}
-scoped_ptr<HistogramBase> Histogram::PersistentCreate(
+std::unique_ptr<HistogramBase> Histogram::PersistentCreate(
const std::string& name,
Sample minimum,
Sample maximum,
@@ -287,9 +288,9 @@
uint32_t counts_size,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(new Histogram(
- name, minimum, maximum, ranges, counts, logged_counts, counts_size,
- meta, logged_meta));
+ return WrapUnique(new Histogram(name, minimum, maximum, ranges, counts,
+ logged_counts, counts_size, meta,
+ logged_meta));
}
// Calculate what range of values are held in each bucket.
@@ -440,12 +441,12 @@
FindAndRunCallback(value);
}
-scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
+std::unique_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
return SnapshotSampleVector();
}
-scoped_ptr<HistogramSamples> Histogram::SnapshotDelta() {
- scoped_ptr<HistogramSamples> snapshot = SnapshotSampleVector();
+std::unique_ptr<HistogramSamples> Histogram::SnapshotDelta() {
+ std::unique_ptr<HistogramSamples> snapshot = SnapshotSampleVector();
if (!logged_samples_) {
// If nothing has been previously logged, save this one as
// |logged_samples_| and gather another snapshot to return.
@@ -575,8 +576,8 @@
return histogram;
}
-scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const {
- scoped_ptr<SampleVector> samples(
+std::unique_ptr<SampleVector> Histogram::SnapshotSampleVector() const {
+ std::unique_ptr<SampleVector> samples(
new SampleVector(samples_->id(), bucket_ranges()));
samples->Add(*samples_);
return samples;
@@ -587,7 +588,7 @@
std::string* output) const {
// Get local (stack) copies of all effectively volatile class data so that we
// are consistent across our output activities.
- scoped_ptr<SampleVector> snapshot = SnapshotSampleVector();
+ std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector();
Count sample_count = snapshot->TotalCount();
WriteAsciiHeader(*snapshot, sample_count, output);
@@ -700,14 +701,14 @@
void Histogram::GetCountAndBucketData(Count* count,
int64_t* sum,
ListValue* buckets) const {
- scoped_ptr<SampleVector> snapshot = SnapshotSampleVector();
+ std::unique_ptr<SampleVector> snapshot = SnapshotSampleVector();
*count = snapshot->TotalCount();
*sum = snapshot->sum();
uint32_t index = 0;
for (uint32_t i = 0; i < bucket_count(); ++i) {
Sample count_at_index = snapshot->GetCountAtIndex(i);
if (count_at_index > 0) {
- scoped_ptr<DictionaryValue> bucket_value(new DictionaryValue());
+ std::unique_ptr<DictionaryValue> bucket_value(new DictionaryValue());
bucket_value->SetInteger("low", ranges(i));
if (i != bucket_count() - 1)
bucket_value->SetInteger("high", ranges(i + 1));
@@ -743,8 +744,9 @@
return ranges;
}
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override {
- return make_scoped_ptr(
+ std::unique_ptr<HistogramBase> HeapAlloc(
+ const BucketRanges* ranges) override {
+ return WrapUnique(
new LinearHistogram(name_, minimum_, maximum_, ranges));
}
@@ -804,7 +806,7 @@
flags);
}
-scoped_ptr<HistogramBase> LinearHistogram::PersistentCreate(
+std::unique_ptr<HistogramBase> LinearHistogram::PersistentCreate(
const std::string& name,
Sample minimum,
Sample maximum,
@@ -814,9 +816,9 @@
uint32_t counts_size,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(new LinearHistogram(
- name, minimum, maximum, ranges, counts, logged_counts, counts_size,
- meta, logged_meta));
+ return WrapUnique(new LinearHistogram(name, minimum, maximum, ranges,
+ counts, logged_counts,
+ counts_size, meta, logged_meta));
}
HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
@@ -934,8 +936,9 @@
return ranges;
}
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override {
- return make_scoped_ptr(new BooleanHistogram(name_, ranges));
+ std::unique_ptr<HistogramBase> HeapAlloc(
+ const BucketRanges* ranges) override {
+ return WrapUnique(new BooleanHistogram(name_, ranges));
}
private:
@@ -951,14 +954,14 @@
return FactoryGet(std::string(name), flags);
}
-scoped_ptr<HistogramBase> BooleanHistogram::PersistentCreate(
+std::unique_ptr<HistogramBase> BooleanHistogram::PersistentCreate(
const std::string& name,
const BucketRanges* ranges,
HistogramBase::AtomicCount* counts,
HistogramBase::AtomicCount* logged_counts,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(new BooleanHistogram(
+ return WrapUnique(new BooleanHistogram(
name, ranges, counts, logged_counts, meta, logged_meta));
}
@@ -1031,8 +1034,9 @@
return bucket_ranges;
}
- scoped_ptr<HistogramBase> HeapAlloc(const BucketRanges* ranges) override {
- return make_scoped_ptr(new CustomHistogram(name_, ranges));
+ std::unique_ptr<HistogramBase> HeapAlloc(
+ const BucketRanges* ranges) override {
+ return WrapUnique(new CustomHistogram(name_, ranges));
}
private:
@@ -1057,7 +1061,7 @@
return FactoryGet(std::string(name), custom_ranges, flags);
}
-scoped_ptr<HistogramBase> CustomHistogram::PersistentCreate(
+std::unique_ptr<HistogramBase> CustomHistogram::PersistentCreate(
const std::string& name,
const BucketRanges* ranges,
HistogramBase::AtomicCount* counts,
@@ -1065,7 +1069,7 @@
uint32_t counts_size,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(new CustomHistogram(
+ return WrapUnique(new CustomHistogram(
name, ranges, counts, logged_counts, counts_size, meta, logged_meta));
}
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index 5111b8f..d4d009c 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -70,6 +70,7 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <string>
#include <vector>
@@ -78,7 +79,6 @@
#include "base/gtest_prod_util.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/histogram_base.h"
// TODO(asvitkine): Migrate callers to to include this directly and remove this.
@@ -142,7 +142,7 @@
int32_t flags);
// Create a histogram using data in persistent storage.
- static scoped_ptr<HistogramBase> PersistentCreate(
+ static std::unique_ptr<HistogramBase> PersistentCreate(
const std::string& name,
Sample minimum,
Sample maximum,
@@ -202,8 +202,8 @@
uint32_t expected_bucket_count) const override;
void Add(Sample value) override;
void AddCount(Sample value, int count) override;
- scoped_ptr<HistogramSamples> SnapshotSamples() const override;
- scoped_ptr<HistogramSamples> SnapshotDelta() override;
+ std::unique_ptr<HistogramSamples> SnapshotSamples() const override;
+ std::unique_ptr<HistogramSamples> SnapshotDelta() override;
void AddSamples(const HistogramSamples& samples) override;
bool AddSamplesFromPickle(base::PickleIterator* iter) override;
void WriteHTMLGraph(std::string* output) const override;
@@ -268,7 +268,7 @@
static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter);
// Implementation of SnapshotSamples function.
- scoped_ptr<SampleVector> SnapshotSampleVector() const;
+ std::unique_ptr<SampleVector> SnapshotSampleVector() const;
//----------------------------------------------------------------------------
// Helpers for emitting Ascii graphic. Each method appends data to output.
@@ -308,10 +308,10 @@
// Finally, provide the state that changes with the addition of each new
// sample.
- scoped_ptr<SampleVector> samples_;
+ std::unique_ptr<SampleVector> samples_;
// Also keep a previous uploaded state for calculating deltas.
- scoped_ptr<HistogramSamples> logged_samples_;
+ std::unique_ptr<HistogramSamples> logged_samples_;
DISALLOW_COPY_AND_ASSIGN(Histogram);
};
@@ -352,7 +352,7 @@
int32_t flags);
// Create a histogram using data in persistent storage.
- static scoped_ptr<HistogramBase> PersistentCreate(
+ static std::unique_ptr<HistogramBase> PersistentCreate(
const std::string& name,
Sample minimum,
Sample maximum,
@@ -443,7 +443,7 @@
static HistogramBase* FactoryGet(const char* name, int32_t flags);
// Create a histogram using data in persistent storage.
- static scoped_ptr<HistogramBase> PersistentCreate(
+ static std::unique_ptr<HistogramBase> PersistentCreate(
const std::string& name,
const BucketRanges* ranges,
HistogramBase::AtomicCount* counts,
@@ -493,7 +493,7 @@
int32_t flags);
// Create a histogram using data in persistent storage.
- static scoped_ptr<HistogramBase> PersistentCreate(
+ static std::unique_ptr<HistogramBase> PersistentCreate(
const std::string& name,
const BucketRanges* ranges,
HistogramBase::AtomicCount* counts,
diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
index bf0a14a..6a79ae2 100644
--- a/base/metrics/histogram_base.cc
+++ b/base/metrics/histogram_base.cc
@@ -6,11 +6,11 @@
#include <limits.h>
+#include <memory>
#include <utility>
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/sparse_histogram.h"
@@ -105,9 +105,9 @@
void HistogramBase::WriteJSON(std::string* output) const {
Count count;
int64_t sum;
- scoped_ptr<ListValue> buckets(new ListValue());
+ std::unique_ptr<ListValue> buckets(new ListValue());
GetCountAndBucketData(&count, &sum, buckets.get());
- scoped_ptr<DictionaryValue> parameters(new DictionaryValue());
+ std::unique_ptr<DictionaryValue> parameters(new DictionaryValue());
GetParameters(parameters.get());
JSONStringValueSerializer serializer(output);
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h
index f11befd..24c104c 100644
--- a/base/metrics/histogram_base.h
+++ b/base/metrics/histogram_base.h
@@ -9,13 +9,13 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/atomicops.h"
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "base/time/time.h"
@@ -195,12 +195,12 @@
// Snapshot the current complete set of sample data.
// Override with atomic/locked snapshot if needed.
- virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0;
+ virtual std::unique_ptr<HistogramSamples> SnapshotSamples() const = 0;
// Calculate the change (delta) in histogram counts since the previous call
// to this method. Each successive call will return only those counts
// changed since the last call.
- virtual scoped_ptr<HistogramSamples> SnapshotDelta() = 0;
+ virtual std::unique_ptr<HistogramSamples> SnapshotDelta() = 0;
// The following methods provide graphical histogram displays.
virtual void WriteHTMLGraph(std::string* output) const = 0;
diff --git a/base/metrics/histogram_base_unittest.cc b/base/metrics/histogram_base_unittest.cc
index 6b41597..5ce39ca 100644
--- a/base/metrics/histogram_base_unittest.cc
+++ b/base/metrics/histogram_base_unittest.cc
@@ -38,7 +38,7 @@
}
private:
- scoped_ptr<StatisticsRecorder> statistics_recorder_;
+ std::unique_ptr<StatisticsRecorder> statistics_recorder_;
DISALLOW_COPY_AND_ASSIGN(HistogramBaseTest);
};
@@ -181,7 +181,7 @@
CustomHistogram::FactoryGet("CRH-Custom", ranges, 0);
SparseHistogram::FactoryGet("CRH-Sparse", 0);
- scoped_ptr<HistogramSamples> samples = report->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples = report->SnapshotSamples();
EXPECT_EQ(1, samples->GetCount(HISTOGRAM_REPORT_CREATED));
EXPECT_EQ(5, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_CREATED));
EXPECT_EQ(0, samples->GetCount(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP));
diff --git a/base/metrics/histogram_delta_serialization.h b/base/metrics/histogram_delta_serialization.h
index a05a1a7..3bb04cb 100644
--- a/base/metrics/histogram_delta_serialization.h
+++ b/base/metrics/histogram_delta_serialization.h
@@ -5,12 +5,12 @@
#ifndef BASE_METRICS_HISTOGRAM_DELTA_SERIALIZATION_H_
#define BASE_METRICS_HISTOGRAM_DELTA_SERIALIZATION_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_snapshot_manager.h"
#include "base/threading/thread_checker.h"
diff --git a/base/metrics/histogram_delta_serialization_unittest.cc b/base/metrics/histogram_delta_serialization_unittest.cc
index 93f7198..80a7009 100644
--- a/base/metrics/histogram_delta_serialization_unittest.cc
+++ b/base/metrics/histogram_delta_serialization_unittest.cc
@@ -34,7 +34,7 @@
HistogramDeltaSerialization::DeserializeAndAddSamples(deltas);
// The histogram has kIPCSerializationSourceFlag. So samples will be ignored.
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(1, snapshot->GetCount(1));
EXPECT_EQ(1, snapshot->GetCount(10));
EXPECT_EQ(1, snapshot->GetCount(100));
@@ -44,7 +44,7 @@
histogram->ClearFlags(HistogramBase::kIPCSerializationSourceFlag);
HistogramDeltaSerialization::DeserializeAndAddSamples(deltas);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(2, snapshot2->GetCount(1));
EXPECT_EQ(2, snapshot2->GetCount(10));
EXPECT_EQ(2, snapshot2->GetCount(100));
diff --git a/base/metrics/histogram_samples.cc b/base/metrics/histogram_samples.cc
index 246a020..d42bd00 100644
--- a/base/metrics/histogram_samples.cc
+++ b/base/metrics/histogram_samples.cc
@@ -141,8 +141,7 @@
HistogramBase::Sample min;
HistogramBase::Sample max;
HistogramBase::Count count;
- for (scoped_ptr<SampleCountIterator> it = Iterator();
- !it->Done();
+ for (std::unique_ptr<SampleCountIterator> it = Iterator(); !it->Done();
it->Next()) {
it->Get(&min, &max, &count);
if (!pickle->WriteInt(min) ||
diff --git a/base/metrics/histogram_samples.h b/base/metrics/histogram_samples.h
index 30bff84..fbfe260 100644
--- a/base/metrics/histogram_samples.h
+++ b/base/metrics/histogram_samples.h
@@ -8,9 +8,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+
#include "base/atomicops.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
namespace base {
@@ -68,7 +69,7 @@
virtual void Subtract(const HistogramSamples& other);
- virtual scoped_ptr<SampleCountIterator> Iterator() const = 0;
+ virtual std::unique_ptr<SampleCountIterator> Iterator() const = 0;
virtual bool Serialize(Pickle* pickle) const;
// Accessor fuctions.
diff --git a/base/metrics/histogram_snapshot_manager.cc b/base/metrics/histogram_snapshot_manager.cc
index 32dd4e6..930fa09 100644
--- a/base/metrics/histogram_snapshot_manager.cc
+++ b/base/metrics/histogram_snapshot_manager.cc
@@ -4,7 +4,8 @@
#include "base/metrics/histogram_snapshot_manager.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
@@ -43,7 +44,7 @@
}
void HistogramSnapshotManager::PrepareDeltaTakingOwnership(
- scoped_ptr<HistogramBase> histogram) {
+ std::unique_ptr<HistogramBase> histogram) {
PrepareSamples(histogram.get(), histogram->SnapshotDelta());
owned_histograms_.push_back(std::move(histogram));
}
@@ -53,7 +54,7 @@
}
void HistogramSnapshotManager::PrepareAbsoluteTakingOwnership(
- scoped_ptr<const HistogramBase> histogram) {
+ std::unique_ptr<const HistogramBase> histogram) {
PrepareSamples(histogram.get(), histogram->SnapshotSamples());
owned_histograms_.push_back(std::move(histogram));
}
@@ -96,7 +97,7 @@
void HistogramSnapshotManager::PrepareSamples(
const HistogramBase* histogram,
- scoped_ptr<HistogramSamples> samples) {
+ std::unique_ptr<HistogramSamples> samples) {
DCHECK(histogram_flattener_);
// Get information known about this histogram.
diff --git a/base/metrics/histogram_snapshot_manager.h b/base/metrics/histogram_snapshot_manager.h
index d44db19..42dbac2 100644
--- a/base/metrics/histogram_snapshot_manager.h
+++ b/base/metrics/histogram_snapshot_manager.h
@@ -66,10 +66,10 @@
// automatically delete the histogram once it is "finished".
void StartDeltas();
void PrepareDelta(HistogramBase* histogram);
- void PrepareDeltaTakingOwnership(scoped_ptr<HistogramBase> histogram);
+ void PrepareDeltaTakingOwnership(std::unique_ptr<HistogramBase> histogram);
void PrepareAbsolute(const HistogramBase* histogram);
void PrepareAbsoluteTakingOwnership(
- scoped_ptr<const HistogramBase> histogram);
+ std::unique_ptr<const HistogramBase> histogram);
void FinishDeltas();
private:
@@ -100,7 +100,7 @@
// Capture and hold samples from a histogram. This does all the heavy
// lifting for PrepareDelta() and PrepareAbsolute().
void PrepareSamples(const HistogramBase* histogram,
- scoped_ptr<HistogramSamples> samples);
+ std::unique_ptr<HistogramSamples> samples);
// Try to detect and fix count inconsistency of logged samples.
void InspectLoggedSamplesInconsistency(
@@ -113,7 +113,7 @@
// Collection of histograms of which ownership has been passed to this
// object. They will be deleted by FinishDeltas().
- std::vector<scoped_ptr<const HistogramBase>> owned_histograms_;
+ std::vector<std::unique_ptr<const HistogramBase>> owned_histograms_;
// Indicates if deltas are currently being prepared.
bool preparing_deltas_;
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc
index 03dc7bd..4fa0aa5 100644
--- a/base/metrics/histogram_unittest.cc
+++ b/base/metrics/histogram_unittest.cc
@@ -9,11 +9,11 @@
#include <stdint.h>
#include <climits>
+#include <memory>
#include <string>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/persistent_histogram_allocator.h"
@@ -84,7 +84,7 @@
const bool use_persistent_histogram_allocator_;
StatisticsRecorder* statistics_recorder_ = nullptr;
- scoped_ptr<char[]> allocator_memory_;
+ std::unique_ptr<char[]> allocator_memory_;
PersistentMemoryAllocator* allocator_ = nullptr;
private:
@@ -136,7 +136,7 @@
HistogramBase* histogram = LinearHistogram::FactoryGet(
"DuplicatedHistogram", 1, 101, 102, HistogramBase::kNoFlags);
- scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
EXPECT_EQ(2, samples->TotalCount());
EXPECT_EQ(2, samples->GetCount(10));
}
@@ -150,7 +150,7 @@
histogram->Add(10);
histogram->Add(50);
- scoped_ptr<HistogramSamples> samples = histogram->SnapshotDelta();
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotDelta();
EXPECT_EQ(3, samples->TotalCount());
EXPECT_EQ(1, samples->GetCount(1));
EXPECT_EQ(1, samples->GetCount(10));
@@ -330,7 +330,7 @@
histogram->AddCount(20, 15);
histogram->AddCount(30, 14);
- scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
EXPECT_EQ(29, samples->TotalCount());
EXPECT_EQ(15, samples->GetCount(20));
EXPECT_EQ(14, samples->GetCount(30));
@@ -338,7 +338,7 @@
histogram->AddCount(20, 25);
histogram->AddCount(30, 24);
- scoped_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples();
EXPECT_EQ(78, samples2->TotalCount());
EXPECT_EQ(40, samples2->GetCount(20));
EXPECT_EQ(38, samples2->GetCount(30));
@@ -353,7 +353,7 @@
histogram->AddCount(200000000, 15);
histogram->AddCount(300000000, 14);
- scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
EXPECT_EQ(29, samples->TotalCount());
EXPECT_EQ(15, samples->GetCount(200000000));
EXPECT_EQ(14, samples->GetCount(300000000));
@@ -361,7 +361,7 @@
histogram->AddCount(200000000, 25);
histogram->AddCount(300000000, 24);
- scoped_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples();
EXPECT_EQ(78, samples2->TotalCount());
EXPECT_EQ(40, samples2->GetCount(200000000));
EXPECT_EQ(38, samples2->GetCount(300000000));
@@ -383,7 +383,7 @@
histogram->Add(10000);
// Verify they landed in the underflow, and overflow buckets.
- scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector();
+ std::unique_ptr<SampleVector> samples = histogram->SnapshotSampleVector();
EXPECT_EQ(2, samples->GetCountAtIndex(0));
EXPECT_EQ(0, samples->GetCountAtIndex(1));
size_t array_size = histogram->bucket_count();
@@ -407,7 +407,7 @@
test_custom_histogram->Add(INT_MAX);
// Verify they landed in the underflow, and overflow buckets.
- scoped_ptr<SampleVector> custom_samples =
+ std::unique_ptr<SampleVector> custom_samples =
test_custom_histogram->SnapshotSampleVector();
EXPECT_EQ(2, custom_samples->GetCountAtIndex(0));
EXPECT_EQ(0, custom_samples->GetCountAtIndex(1));
@@ -431,7 +431,7 @@
}
// Check to see that the bucket counts reflect our additions.
- scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector();
+ std::unique_ptr<SampleVector> samples = histogram->SnapshotSampleVector();
for (int i = 0; i < 8; i++)
EXPECT_EQ(i + 1, samples->GetCountAtIndex(i));
}
@@ -444,7 +444,7 @@
histogram->Add(20);
histogram->Add(40);
- scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
+ std::unique_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
histogram->FindCorruption(*snapshot));
EXPECT_EQ(2, snapshot->redundant_count());
@@ -467,7 +467,7 @@
Histogram* histogram = static_cast<Histogram*>(
Histogram::FactoryGet("Histogram", 1, 64, 8, HistogramBase::kNoFlags));
- scoped_ptr<HistogramSamples> snapshot = histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> snapshot = histogram->SnapshotSamples();
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
histogram->FindCorruption(*snapshot));
diff --git a/base/metrics/persistent_histogram_allocator.cc b/base/metrics/persistent_histogram_allocator.cc
index 6006d31..e964336 100644
--- a/base/metrics/persistent_histogram_allocator.cc
+++ b/base/metrics/persistent_histogram_allocator.cc
@@ -4,9 +4,11 @@
#include "base/metrics/persistent_histogram_allocator.h"
+#include <memory>
+
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
@@ -47,12 +49,12 @@
// Take an array of range boundaries and create a proper BucketRanges object
// which is returned to the caller. A return of nullptr indicates that the
// passed boundaries are invalid.
-scoped_ptr<BucketRanges> CreateRangesFromData(
+std::unique_ptr<BucketRanges> CreateRangesFromData(
HistogramBase::Sample* ranges_data,
uint32_t ranges_checksum,
size_t count) {
// To avoid racy destruction at shutdown, the following may be leaked.
- scoped_ptr<BucketRanges> ranges(new BucketRanges(count));
+ std::unique_ptr<BucketRanges> ranges(new BucketRanges(count));
DCHECK_EQ(count, ranges->size());
for (size_t i = 0; i < count; ++i) {
if (i > 0 && ranges_data[i] <= ranges_data[i - 1])
@@ -110,7 +112,7 @@
};
PersistentHistogramAllocator::PersistentHistogramAllocator(
- scoped_ptr<PersistentMemoryAllocator> memory)
+ std::unique_ptr<PersistentMemoryAllocator> memory)
: memory_allocator_(std::move(memory)) {}
PersistentHistogramAllocator::~PersistentHistogramAllocator() {}
@@ -174,7 +176,7 @@
// static
void PersistentHistogramAllocator::SetGlobalAllocator(
- scoped_ptr<PersistentHistogramAllocator> allocator) {
+ std::unique_ptr<PersistentHistogramAllocator> allocator) {
// Releasing or changing an allocator is extremely dangerous because it
// likely has histograms stored within it. If the backing memory is also
// also released, future accesses to those histograms will seg-fault.
@@ -194,7 +196,7 @@
}
// static
-scoped_ptr<PersistentHistogramAllocator>
+std::unique_ptr<PersistentHistogramAllocator>
PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting() {
PersistentHistogramAllocator* histogram_allocator = g_allocator;
if (!histogram_allocator)
@@ -229,7 +231,7 @@
}
g_allocator = nullptr;
- return make_scoped_ptr(histogram_allocator);
+ return WrapUnique(histogram_allocator);
};
// static
@@ -239,9 +241,9 @@
size_t page_size,
uint64_t id,
StringPiece name) {
- SetGlobalAllocator(make_scoped_ptr(new PersistentHistogramAllocator(
- make_scoped_ptr(new PersistentMemoryAllocator(
- base, size, page_size, id, name, false)))));
+ SetGlobalAllocator(WrapUnique(new PersistentHistogramAllocator(
+ WrapUnique(new PersistentMemoryAllocator(base, size, page_size, id,
+ name, false)))));
}
// static
@@ -249,27 +251,28 @@
size_t size,
uint64_t id,
StringPiece name) {
- SetGlobalAllocator(make_scoped_ptr(new PersistentHistogramAllocator(
- make_scoped_ptr(new LocalPersistentMemoryAllocator(size, id, name)))));
+ SetGlobalAllocator(WrapUnique(new PersistentHistogramAllocator(
+ WrapUnique(new LocalPersistentMemoryAllocator(size, id, name)))));
}
// static
void PersistentHistogramAllocator::CreateGlobalAllocatorOnSharedMemory(
size_t size,
const SharedMemoryHandle& handle) {
- scoped_ptr<SharedMemory> shm(new SharedMemory(handle, /*readonly=*/false));
+ std::unique_ptr<SharedMemory> shm(
+ new SharedMemory(handle, /*readonly=*/false));
if (!shm->Map(size)) {
NOTREACHED();
return;
}
- SetGlobalAllocator(make_scoped_ptr(new PersistentHistogramAllocator(
- make_scoped_ptr(new SharedPersistentMemoryAllocator(
+ SetGlobalAllocator(WrapUnique(new PersistentHistogramAllocator(
+ WrapUnique(new SharedPersistentMemoryAllocator(
std::move(shm), 0, StringPiece(), /*readonly=*/false)))));
}
// static
-scoped_ptr<HistogramBase> PersistentHistogramAllocator::CreateHistogram(
+std::unique_ptr<HistogramBase> PersistentHistogramAllocator::CreateHistogram(
PersistentHistogramData* histogram_data_ptr) {
if (!histogram_data_ptr) {
RecordCreateHistogramResult(CREATE_HISTOGRAM_INVALID_METADATA_POINTER);
@@ -279,10 +282,11 @@
// Sparse histograms are quite different so handle them as a special case.
if (histogram_data_ptr->histogram_type == SPARSE_HISTOGRAM) {
- scoped_ptr<HistogramBase> histogram = SparseHistogram::PersistentCreate(
- memory_allocator(), histogram_data_ptr->name,
- &histogram_data_ptr->samples_metadata,
- &histogram_data_ptr->logged_metadata);
+ std::unique_ptr<HistogramBase> histogram =
+ SparseHistogram::PersistentCreate(memory_allocator(),
+ histogram_data_ptr->name,
+ &histogram_data_ptr->samples_metadata,
+ &histogram_data_ptr->logged_metadata);
DCHECK(histogram);
histogram->SetFlags(histogram_data_ptr->flags);
RecordCreateHistogramResult(CREATE_HISTOGRAM_SUCCESS);
@@ -314,7 +318,7 @@
return nullptr;
}
- scoped_ptr<const BucketRanges> created_ranges =
+ std::unique_ptr<const BucketRanges> created_ranges =
CreateRangesFromData(ranges_data, histogram_data.ranges_checksum,
histogram_data.bucket_count + 1);
if (!created_ranges) {
@@ -346,7 +350,7 @@
counts_data + histogram_data.bucket_count;
std::string name(histogram_data_ptr->name);
- scoped_ptr<HistogramBase> histogram;
+ std::unique_ptr<HistogramBase> histogram;
switch (histogram_data.histogram_type) {
case HISTOGRAM:
histogram = Histogram::PersistentCreate(
@@ -393,7 +397,7 @@
return histogram;
}
-scoped_ptr<HistogramBase> PersistentHistogramAllocator::GetHistogram(
+std::unique_ptr<HistogramBase> PersistentHistogramAllocator::GetHistogram(
Reference ref) {
// Unfortunately, the histogram "pickle" methods cannot be used as part of
// the persistance because the deserialization methods always create local
@@ -413,7 +417,7 @@
return CreateHistogram(histogram_data);
}
-scoped_ptr<HistogramBase>
+std::unique_ptr<HistogramBase>
PersistentHistogramAllocator::GetNextHistogramWithIgnore(Iterator* iter,
Reference ignore) {
PersistentMemoryAllocator::Reference ref;
@@ -441,7 +445,7 @@
memory_allocator_->SetType(ref, 0);
}
-scoped_ptr<HistogramBase> PersistentHistogramAllocator::AllocateHistogram(
+std::unique_ptr<HistogramBase> PersistentHistogramAllocator::AllocateHistogram(
HistogramType histogram_type,
const std::string& name,
int minimum,
@@ -521,7 +525,7 @@
// using what is already known above but avoids duplicating the switch
// statement here and serves as a double-check that everything is
// correct before commiting the new histogram to persistent space.
- scoped_ptr<HistogramBase> histogram = CreateHistogram(histogram_data);
+ std::unique_ptr<HistogramBase> histogram = CreateHistogram(histogram_data);
DCHECK(histogram);
if (ref_ptr != nullptr)
*ref_ptr = histogram_ref;
@@ -575,7 +579,7 @@
subtle::NoBarrier_Load(&g_allocator->last_created_);
while (true) {
- scoped_ptr<HistogramBase> histogram =
+ std::unique_ptr<HistogramBase> histogram =
g_allocator->GetNextHistogramWithIgnore(&iter, last_created);
if (!histogram)
break;
diff --git a/base/metrics/persistent_histogram_allocator.h b/base/metrics/persistent_histogram_allocator.h
index cc8d023..cbbeed9 100644
--- a/base/metrics/persistent_histogram_allocator.h
+++ b/base/metrics/persistent_histogram_allocator.h
@@ -5,10 +5,11 @@
#ifndef BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
#define BASE_METRICS_HISTOGRAM_PERSISTENCE_H_
+#include <memory>
+
#include "base/atomicops.h"
#include "base/base_export.h"
#include "base/feature_list.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/persistent_memory_allocator.h"
@@ -38,7 +39,8 @@
// A PersistentHistogramAllocator is constructed from a PersistentMemory-
// Allocator object of which it takes ownership.
- PersistentHistogramAllocator(scoped_ptr<PersistentMemoryAllocator> memory);
+ PersistentHistogramAllocator(
+ std::unique_ptr<PersistentMemoryAllocator> memory);
~PersistentHistogramAllocator();
// Direct access to underlying memory allocator. If the segment is shared
@@ -61,10 +63,10 @@
// shared with all other threads referencing it. This method takes a |ref|
// to where the top-level histogram data may be found in this allocator.
// This method will return null if any problem is detected with the data.
- scoped_ptr<HistogramBase> GetHistogram(Reference ref);
+ std::unique_ptr<HistogramBase> GetHistogram(Reference ref);
// Get the next histogram in persistent data based on iterator.
- scoped_ptr<HistogramBase> GetNextHistogram(Iterator* iter) {
+ std::unique_ptr<HistogramBase> GetNextHistogram(Iterator* iter) {
return GetNextHistogramWithIgnore(iter, 0);
}
@@ -73,7 +75,7 @@
// Allocate a new persistent histogram. The returned histogram will not
// be able to be located by other allocators until it is "finalized".
- scoped_ptr<HistogramBase> AllocateHistogram(
+ std::unique_ptr<HistogramBase> AllocateHistogram(
HistogramType histogram_type,
const std::string& name,
int minimum,
@@ -106,14 +108,14 @@
// possible during startup to capture as many histograms as possible and
// while operating single-threaded so there are no race-conditions.
static void SetGlobalAllocator(
- scoped_ptr<PersistentHistogramAllocator> allocator);
+ std::unique_ptr<PersistentHistogramAllocator> allocator);
static PersistentHistogramAllocator* GetGlobalAllocator();
// This access to the persistent allocator is only for testing; it extracts
// the current allocator completely. This allows easy creation of histograms
// within persistent memory segments which can then be extracted and used
// in other ways.
- static scoped_ptr<PersistentHistogramAllocator>
+ static std::unique_ptr<PersistentHistogramAllocator>
ReleaseGlobalAllocatorForTesting();
// These helper methods perform SetGlobalAllocator() calls with allocators
@@ -186,19 +188,18 @@
// Get the next histogram in persistent data based on iterator while
// ignoring a particular reference if it is found.
- scoped_ptr<HistogramBase> GetNextHistogramWithIgnore(
- Iterator* iter,
- Reference ignore);
+ std::unique_ptr<HistogramBase> GetNextHistogramWithIgnore(Iterator* iter,
+ Reference ignore);
// Create a histogram based on saved (persistent) information about it.
- scoped_ptr<HistogramBase> CreateHistogram(
+ std::unique_ptr<HistogramBase> CreateHistogram(
PersistentHistogramData* histogram_data_ptr);
// Record the result of a histogram creation.
static void RecordCreateHistogramResult(CreateHistogramResultType result);
// The memory allocator that provides the actual histogram storage.
- scoped_ptr<PersistentMemoryAllocator> memory_allocator_;
+ std::unique_ptr<PersistentMemoryAllocator> memory_allocator_;
// A reference to the last-created histogram in the allocator, used to avoid
// trying to import what was just created.
diff --git a/base/metrics/persistent_histogram_allocator_unittest.cc b/base/metrics/persistent_histogram_allocator_unittest.cc
index 64abdec..922245f 100644
--- a/base/metrics/persistent_histogram_allocator_unittest.cc
+++ b/base/metrics/persistent_histogram_allocator_unittest.cc
@@ -5,6 +5,7 @@
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/persistent_memory_allocator.h"
@@ -39,7 +40,7 @@
PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting();
}
- scoped_ptr<char[]> allocator_memory_;
+ std::unique_ptr<char[]> allocator_memory_;
PersistentMemoryAllocator* allocator_ = nullptr;
private:
@@ -96,9 +97,9 @@
EXPECT_EQ(0U, allocator_->GetNextIterable(&iter, &type));
// Create a second allocator and have it access the memory of the first.
- scoped_ptr<HistogramBase> recovered;
+ std::unique_ptr<HistogramBase> recovered;
PersistentHistogramAllocator recovery(
- make_scoped_ptr(new PersistentMemoryAllocator(
+ WrapUnique(new PersistentMemoryAllocator(
allocator_memory_.get(), kAllocatorMemorySize, 0, 0, "", false)));
PersistentHistogramAllocator::Iterator histogram_iter;
recovery.CreateIterator(&histogram_iter);
diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
index a1a960c..1d5df33 100644
--- a/base/metrics/persistent_memory_allocator.cc
+++ b/base/metrics/persistent_memory_allocator.cc
@@ -668,12 +668,16 @@
//----- SharedPersistentMemoryAllocator ----------------------------------------
SharedPersistentMemoryAllocator::SharedPersistentMemoryAllocator(
- scoped_ptr<SharedMemory> memory,
+ std::unique_ptr<SharedMemory> memory,
uint64_t id,
base::StringPiece name,
bool read_only)
: PersistentMemoryAllocator(static_cast<uint8_t*>(memory->memory()),
- memory->mapped_size(), 0, id, name, read_only),
+ memory->mapped_size(),
+ 0,
+ id,
+ name,
+ read_only),
shared_memory_(std::move(memory)) {}
SharedPersistentMemoryAllocator::~SharedPersistentMemoryAllocator() {}
@@ -688,11 +692,15 @@
//----- FilePersistentMemoryAllocator ------------------------------------------
FilePersistentMemoryAllocator::FilePersistentMemoryAllocator(
- scoped_ptr<MemoryMappedFile> file,
+ std::unique_ptr<MemoryMappedFile> file,
uint64_t id,
base::StringPiece name)
: PersistentMemoryAllocator(const_cast<uint8_t*>(file->data()),
- file->length(), 0, id, name, true),
+ file->length(),
+ 0,
+ id,
+ name,
+ true),
mapped_file_(std::move(file)) {}
FilePersistentMemoryAllocator::~FilePersistentMemoryAllocator() {}
diff --git a/base/metrics/persistent_memory_allocator.h b/base/metrics/persistent_memory_allocator.h
index f75b1c0..8c849b6 100644
--- a/base/metrics/persistent_memory_allocator.h
+++ b/base/metrics/persistent_memory_allocator.h
@@ -6,13 +6,14 @@
#define BASE_METRICS_PERSISTENT_MEMORY_ALLOCATOR_H_
#include <stdint.h>
+
#include <atomic>
+#include <memory>
#include "base/atomicops.h"
#include "base/base_export.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
namespace base {
@@ -321,8 +322,10 @@
class BASE_EXPORT SharedPersistentMemoryAllocator
: public PersistentMemoryAllocator {
public:
- SharedPersistentMemoryAllocator(scoped_ptr<SharedMemory> memory, uint64_t id,
- base::StringPiece name, bool read_only);
+ SharedPersistentMemoryAllocator(std::unique_ptr<SharedMemory> memory,
+ uint64_t id,
+ base::StringPiece name,
+ bool read_only);
~SharedPersistentMemoryAllocator() override;
SharedMemory* shared_memory() { return shared_memory_.get(); }
@@ -334,7 +337,7 @@
static bool IsSharedMemoryAcceptable(const SharedMemory& memory);
private:
- scoped_ptr<SharedMemory> shared_memory_;
+ std::unique_ptr<SharedMemory> shared_memory_;
DISALLOW_COPY_AND_ASSIGN(SharedPersistentMemoryAllocator);
};
@@ -346,7 +349,8 @@
class BASE_EXPORT FilePersistentMemoryAllocator
: public PersistentMemoryAllocator {
public:
- FilePersistentMemoryAllocator(scoped_ptr<MemoryMappedFile> file, uint64_t id,
+ FilePersistentMemoryAllocator(std::unique_ptr<MemoryMappedFile> file,
+ uint64_t id,
base::StringPiece name);
~FilePersistentMemoryAllocator() override;
@@ -357,7 +361,7 @@
static bool IsFileAcceptable(const MemoryMappedFile& file);
private:
- scoped_ptr<MemoryMappedFile> mapped_file_;
+ std::unique_ptr<MemoryMappedFile> mapped_file_;
DISALLOW_COPY_AND_ASSIGN(FilePersistentMemoryAllocator);
};
diff --git a/base/metrics/persistent_memory_allocator_unittest.cc b/base/metrics/persistent_memory_allocator_unittest.cc
index ca02f2e..6ec5a03 100644
--- a/base/metrics/persistent_memory_allocator_unittest.cc
+++ b/base/metrics/persistent_memory_allocator_unittest.cc
@@ -4,11 +4,12 @@
#include "base/metrics/persistent_memory_allocator.h"
+#include <memory>
+
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/metrics/histogram.h"
#include "base/rand_util.h"
@@ -79,8 +80,8 @@
}
protected:
- scoped_ptr<char[]> mem_segment_;
- scoped_ptr<PersistentMemoryAllocator> allocator_;
+ std::unique_ptr<char[]> mem_segment_;
+ std::unique_ptr<PersistentMemoryAllocator> allocator_;
};
TEST_F(PersistentMemoryAllocatorTest, AllocateAndIterate) {
@@ -154,13 +155,13 @@
// Check the internal histogram record of used memory.
allocator_->UpdateTrackingHistograms();
- scoped_ptr<HistogramSamples> used_samples(
+ std::unique_ptr<HistogramSamples> used_samples(
allocator_->used_histogram_->SnapshotSamples());
EXPECT_TRUE(used_samples);
EXPECT_EQ(1, used_samples->TotalCount());
// Check the internal histogram record of allocation requests.
- scoped_ptr<HistogramSamples> allocs_samples(
+ std::unique_ptr<HistogramSamples> allocs_samples(
allocator_->allocs_histogram_->SnapshotSamples());
EXPECT_TRUE(allocs_samples);
EXPECT_EQ(2, allocs_samples->TotalCount());
@@ -182,10 +183,9 @@
EXPECT_EQ(2U, allocator_->GetType(block2));
// Create second allocator (read/write) using the same memory segment.
- scoped_ptr<PersistentMemoryAllocator> allocator2(
- new PersistentMemoryAllocator(
- mem_segment_.get(), TEST_MEMORY_SIZE, TEST_MEMORY_PAGE, 0, "",
- false));
+ std::unique_ptr<PersistentMemoryAllocator> allocator2(
+ new PersistentMemoryAllocator(mem_segment_.get(), TEST_MEMORY_SIZE,
+ TEST_MEMORY_PAGE, 0, "", false));
EXPECT_EQ(TEST_ID, allocator2->Id());
EXPECT_FALSE(allocator2->used_histogram_);
EXPECT_FALSE(allocator2->allocs_histogram_);
@@ -200,9 +200,9 @@
EXPECT_NE(nullptr, allocator2->GetAsObject<TestObject2>(block2, 2));
// Create a third allocator (read-only) using the same memory segment.
- scoped_ptr<const PersistentMemoryAllocator> allocator3(
- new PersistentMemoryAllocator(
- mem_segment_.get(), TEST_MEMORY_SIZE, TEST_MEMORY_PAGE, 0, "", true));
+ std::unique_ptr<const PersistentMemoryAllocator> allocator3(
+ new PersistentMemoryAllocator(mem_segment_.get(), TEST_MEMORY_SIZE,
+ TEST_MEMORY_PAGE, 0, "", true));
EXPECT_EQ(TEST_ID, allocator3->Id());
EXPECT_FALSE(allocator3->used_histogram_);
EXPECT_FALSE(allocator3->allocs_histogram_);
@@ -396,7 +396,7 @@
PersistentMemoryAllocator::MemoryInfo meminfo1;
Reference r123, r456, r789;
{
- scoped_ptr<SharedMemory> shmem1(new SharedMemory());
+ std::unique_ptr<SharedMemory> shmem1(new SharedMemory());
ASSERT_TRUE(shmem1->CreateAndMapAnonymous(TEST_MEMORY_SIZE));
SharedPersistentMemoryAllocator local(std::move(shmem1), TEST_ID, "",
false);
@@ -417,8 +417,8 @@
}
// Read-only test.
- scoped_ptr<SharedMemory> shmem2(new SharedMemory(shared_handle,
- /*readonly=*/true));
+ std::unique_ptr<SharedMemory> shmem2(new SharedMemory(shared_handle,
+ /*readonly=*/true));
ASSERT_TRUE(shmem2->Map(TEST_MEMORY_SIZE));
SharedPersistentMemoryAllocator shalloc2(std::move(shmem2), 0, "", true);
@@ -444,8 +444,8 @@
EXPECT_EQ(meminfo1.free, meminfo2.free);
// Read/write test.
- scoped_ptr<SharedMemory> shmem3(new SharedMemory(shared_handle,
- /*readonly=*/false));
+ std::unique_ptr<SharedMemory> shmem3(new SharedMemory(shared_handle,
+ /*readonly=*/false));
ASSERT_TRUE(shmem3->Map(TEST_MEMORY_SIZE));
SharedPersistentMemoryAllocator shalloc3(std::move(shmem3), 0, "", false);
@@ -505,7 +505,7 @@
writer.Write(0, (const char*)local.data(), local.used());
}
- scoped_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile());
+ std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile());
mmfile->Initialize(file_path);
EXPECT_TRUE(mmfile->IsValid());
const size_t mmlength = mmfile->length();
@@ -545,10 +545,10 @@
local.Allocate(1, 1);
local.Allocate(11, 11);
const size_t minsize = local.used();
- scoped_ptr<char[]> garbage(new char[minsize]);
+ std::unique_ptr<char[]> garbage(new char[minsize]);
RandBytes(garbage.get(), minsize);
- scoped_ptr<MemoryMappedFile> mmfile;
+ std::unique_ptr<MemoryMappedFile> mmfile;
char filename[100];
for (size_t filesize = minsize; filesize > 0; --filesize) {
strings::SafeSPrintf(filename, "memory_%d_A", filesize);
diff --git a/base/metrics/persistent_sample_map.cc b/base/metrics/persistent_sample_map.cc
index 014a865..ae8ff32 100644
--- a/base/metrics/persistent_sample_map.cc
+++ b/base/metrics/persistent_sample_map.cc
@@ -5,6 +5,7 @@
#include "base/metrics/persistent_sample_map.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
namespace base {
@@ -135,11 +136,11 @@
return count;
}
-scoped_ptr<SampleCountIterator> PersistentSampleMap::Iterator() const {
+std::unique_ptr<SampleCountIterator> PersistentSampleMap::Iterator() const {
// Have to override "const" in order to make sure all samples have been
// loaded before trying to iterate over the map.
const_cast<PersistentSampleMap*>(this)->ImportSamples(kAllSamples);
- return make_scoped_ptr(new PersistentSampleMapIterator(sample_counts_));
+ return WrapUnique(new PersistentSampleMapIterator(sample_counts_));
}
bool PersistentSampleMap::AddSubtractImpl(SampleCountIterator* iter,
diff --git a/base/metrics/persistent_sample_map.h b/base/metrics/persistent_sample_map.h
index a23b751..4ae54d8 100644
--- a/base/metrics/persistent_sample_map.h
+++ b/base/metrics/persistent_sample_map.h
@@ -12,10 +12,10 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/persistent_memory_allocator.h"
@@ -36,7 +36,7 @@
HistogramBase::Count count) override;
HistogramBase::Count GetCount(HistogramBase::Sample value) const override;
HistogramBase::Count TotalCount() const override;
- scoped_ptr<SampleCountIterator> Iterator() const override;
+ std::unique_ptr<SampleCountIterator> Iterator() const override;
protected:
// Performs arithemetic. |op| is ADD or SUBTRACT.
diff --git a/base/metrics/persistent_sample_map_unittest.cc b/base/metrics/persistent_sample_map_unittest.cc
index c735f8f..52c3cef 100644
--- a/base/metrics/persistent_sample_map_unittest.cc
+++ b/base/metrics/persistent_sample_map_unittest.cc
@@ -4,7 +4,8 @@
#include "base/metrics/persistent_sample_map.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -136,7 +137,7 @@
samples.Accumulate(4, -300);
samples.Accumulate(5, 0);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
HistogramBase::Sample min;
HistogramBase::Sample max;
@@ -187,7 +188,7 @@
samples.Subtract(samples2);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
EXPECT_FALSE(it->Done());
HistogramBase::Sample min;
@@ -221,7 +222,7 @@
allocator.Allocate(sizeof(HistogramSamples::Metadata), 0), 0);
PersistentSampleMap samples(1, &allocator, meta);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
EXPECT_TRUE(it->Done());
diff --git a/base/metrics/sample_map.cc b/base/metrics/sample_map.cc
index 21a4e35..8abd01e 100644
--- a/base/metrics/sample_map.cc
+++ b/base/metrics/sample_map.cc
@@ -5,6 +5,7 @@
#include "base/metrics/sample_map.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
namespace base {
@@ -102,8 +103,8 @@
return count;
}
-scoped_ptr<SampleCountIterator> SampleMap::Iterator() const {
- return make_scoped_ptr(new SampleMapIterator(sample_counts_));
+std::unique_ptr<SampleCountIterator> SampleMap::Iterator() const {
+ return WrapUnique(new SampleMapIterator(sample_counts_));
}
bool SampleMap::AddSubtractImpl(SampleCountIterator* iter, Operator op) {
diff --git a/base/metrics/sample_map.h b/base/metrics/sample_map.h
index 2f24e1f..7458e05 100644
--- a/base/metrics/sample_map.h
+++ b/base/metrics/sample_map.h
@@ -11,10 +11,10 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
@@ -33,7 +33,7 @@
HistogramBase::Count count) override;
HistogramBase::Count GetCount(HistogramBase::Sample value) const override;
HistogramBase::Count TotalCount() const override;
- scoped_ptr<SampleCountIterator> Iterator() const override;
+ std::unique_ptr<SampleCountIterator> Iterator() const override;
protected:
// Performs arithemetic. |op| is ADD or SUBTRACT.
diff --git a/base/metrics/sample_map_unittest.cc b/base/metrics/sample_map_unittest.cc
index 3626bd0..8f57710 100644
--- a/base/metrics/sample_map_unittest.cc
+++ b/base/metrics/sample_map_unittest.cc
@@ -4,7 +4,8 @@
#include "base/metrics/sample_map.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -76,7 +77,7 @@
samples.Accumulate(4, -300);
samples.Accumulate(5, 0);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
HistogramBase::Sample min;
HistogramBase::Sample max;
@@ -119,7 +120,7 @@
samples.Subtract(samples2);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
EXPECT_FALSE(it->Done());
HistogramBase::Sample min;
@@ -148,7 +149,7 @@
TEST(SampleMapIteratorDeathTest, IterateDoneTest) {
SampleMap samples(1);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
EXPECT_TRUE(it->Done());
diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc
index ccb9431..9c6453e 100644
--- a/base/metrics/sample_vector.cc
+++ b/base/metrics/sample_vector.cc
@@ -65,8 +65,8 @@
return subtle::NoBarrier_Load(&counts_[bucket_index]);
}
-scoped_ptr<SampleCountIterator> SampleVector::Iterator() const {
- return scoped_ptr<SampleCountIterator>(
+std::unique_ptr<SampleCountIterator> SampleVector::Iterator() const {
+ return std::unique_ptr<SampleCountIterator>(
new SampleVectorIterator(counts_, counts_size_, bucket_ranges_));
}
diff --git a/base/metrics/sample_vector.h b/base/metrics/sample_vector.h
index 86319ea..ee26c52 100644
--- a/base/metrics/sample_vector.h
+++ b/base/metrics/sample_vector.h
@@ -11,12 +11,12 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
@@ -40,7 +40,7 @@
HistogramBase::Count count) override;
HistogramBase::Count GetCount(HistogramBase::Sample value) const override;
HistogramBase::Count TotalCount() const override;
- scoped_ptr<SampleCountIterator> Iterator() const override;
+ std::unique_ptr<SampleCountIterator> Iterator() const override;
// Get count of a specific bucket.
HistogramBase::Count GetCountAtIndex(size_t bucket_index) const;
diff --git a/base/metrics/sample_vector_unittest.cc b/base/metrics/sample_vector_unittest.cc
index 434def7..02e48aa 100644
--- a/base/metrics/sample_vector_unittest.cc
+++ b/base/metrics/sample_vector_unittest.cc
@@ -7,9 +7,9 @@
#include <limits.h>
#include <stddef.h>
+#include <memory>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/histogram.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -244,7 +244,7 @@
samples.Accumulate(1, 1);
samples.Accumulate(2, 2);
samples.Accumulate(3, 3);
- scoped_ptr<SampleCountIterator> it2 = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it2 = samples.Iterator();
int i;
for (i = 1; !it2->Done(); i++, it2->Next()) {
@@ -271,7 +271,7 @@
ranges.set_range(4, INT_MAX);
SampleVector samples(1, &ranges);
- scoped_ptr<SampleCountIterator> it = samples.Iterator();
+ std::unique_ptr<SampleCountIterator> it = samples.Iterator();
EXPECT_TRUE(it->Done());
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index ee18cfa..1118c41 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_sample_map.h"
@@ -37,7 +38,7 @@
// allocating from it fails, code below will allocate the histogram from
// the process heap.
PersistentMemoryAllocator::Reference histogram_ref = 0;
- scoped_ptr<HistogramBase> tentative_histogram;
+ std::unique_ptr<HistogramBase> tentative_histogram;
PersistentHistogramAllocator* allocator =
PersistentHistogramAllocator::GetGlobalAllocator();
if (allocator) {
@@ -79,12 +80,12 @@
}
// static
-scoped_ptr<HistogramBase> SparseHistogram::PersistentCreate(
+std::unique_ptr<HistogramBase> SparseHistogram::PersistentCreate(
PersistentMemoryAllocator* allocator,
const std::string& name,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
- return make_scoped_ptr(
+ return WrapUnique(
new SparseHistogram(allocator, name, meta, logged_meta));
}
@@ -123,16 +124,16 @@
FindAndRunCallback(value);
}
-scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
- scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
+std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const {
+ std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
base::AutoLock auto_lock(lock_);
snapshot->Add(*samples_);
return std::move(snapshot);
}
-scoped_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
- scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
+std::unique_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() {
+ std::unique_ptr<SampleMap> snapshot(new SampleMap(name_hash()));
base::AutoLock auto_lock(lock_);
snapshot->Add(*samples_);
@@ -219,7 +220,7 @@
const std::string& newline,
std::string* output) const {
// Get a local copy of the data so we are consistent.
- scoped_ptr<HistogramSamples> snapshot = SnapshotSamples();
+ std::unique_ptr<HistogramSamples> snapshot = SnapshotSamples();
Count total_count = snapshot->TotalCount();
double scaled_total_count = total_count / 100.0;
@@ -232,7 +233,7 @@
// normalize the graphical bar-width relative to that sample count.
Count largest_count = 0;
Sample largest_sample = 0;
- scoped_ptr<SampleCountIterator> it = snapshot->Iterator();
+ std::unique_ptr<SampleCountIterator> it = snapshot->Iterator();
while (!it->Done()) {
Sample min;
Sample max;
diff --git a/base/metrics/sparse_histogram.h b/base/metrics/sparse_histogram.h
index b876737..f0296cb 100644
--- a/base/metrics/sparse_histogram.h
+++ b/base/metrics/sparse_histogram.h
@@ -9,13 +9,13 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <string>
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/sample_map.h"
#include "base/synchronization/lock.h"
@@ -60,7 +60,7 @@
static HistogramBase* FactoryGet(const std::string& name, int32_t flags);
// Create a histogram using data in persistent storage.
- static scoped_ptr<HistogramBase> PersistentCreate(
+ static std::unique_ptr<HistogramBase> PersistentCreate(
PersistentMemoryAllocator* allocator,
const std::string& name,
HistogramSamples::Metadata* meta,
@@ -78,8 +78,8 @@
void AddCount(Sample value, int count) override;
void AddSamples(const HistogramSamples& samples) override;
bool AddSamplesFromPickle(base::PickleIterator* iter) override;
- scoped_ptr<HistogramSamples> SnapshotSamples() const override;
- scoped_ptr<HistogramSamples> SnapshotDelta() override;
+ std::unique_ptr<HistogramSamples> SnapshotSamples() const override;
+ std::unique_ptr<HistogramSamples> SnapshotDelta() override;
void WriteHTMLGraph(std::string* output) const override;
void WriteAscii(std::string* output) const override;
@@ -120,8 +120,8 @@
// Protects access to |samples_|.
mutable base::Lock lock_;
- scoped_ptr<HistogramSamples> samples_;
- scoped_ptr<HistogramSamples> logged_samples_;
+ std::unique_ptr<HistogramSamples> samples_;
+ std::unique_ptr<HistogramSamples> logged_samples_;
DISALLOW_COPY_AND_ASSIGN(SparseHistogram);
};
diff --git a/base/metrics/sparse_histogram_unittest.cc b/base/metrics/sparse_histogram_unittest.cc
index 5d5dbcb..6cddd1f 100644
--- a/base/metrics/sparse_histogram_unittest.cc
+++ b/base/metrics/sparse_histogram_unittest.cc
@@ -4,9 +4,9 @@
#include "base/metrics/sparse_histogram.h"
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/persistent_histogram_allocator.h"
@@ -73,14 +73,14 @@
PersistentHistogramAllocator::ReleaseGlobalAllocatorForTesting();
}
- scoped_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) {
- return scoped_ptr<SparseHistogram>(new SparseHistogram(name));
+ std::unique_ptr<SparseHistogram> NewSparseHistogram(const std::string& name) {
+ return std::unique_ptr<SparseHistogram>(new SparseHistogram(name));
}
const bool use_persistent_histogram_allocator_;
StatisticsRecorder* statistics_recorder_;
- scoped_ptr<char[]> allocator_memory_;
+ std::unique_ptr<char[]> allocator_memory_;
PersistentMemoryAllocator* allocator_ = nullptr;
private:
@@ -94,57 +94,57 @@
TEST_P(SparseHistogramTest, BasicTest) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->Add(100);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(1, snapshot1->TotalCount());
EXPECT_EQ(1, snapshot1->GetCount(100));
histogram->Add(100);
histogram->Add(101);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(3, snapshot2->TotalCount());
EXPECT_EQ(2, snapshot2->GetCount(100));
EXPECT_EQ(1, snapshot2->GetCount(101));
}
TEST_P(SparseHistogramTest, BasicTestAddCount) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->AddCount(100, 15);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(15, snapshot1->TotalCount());
EXPECT_EQ(15, snapshot1->GetCount(100));
histogram->AddCount(100, 15);
histogram->AddCount(101, 25);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(55, snapshot2->TotalCount());
EXPECT_EQ(30, snapshot2->GetCount(100));
EXPECT_EQ(25, snapshot2->GetCount(101));
}
TEST_P(SparseHistogramTest, AddCount_LargeValuesDontOverflow) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
- scoped_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<HistogramSamples> snapshot(histogram->SnapshotSamples());
EXPECT_EQ(0, snapshot->TotalCount());
EXPECT_EQ(0, snapshot->sum());
histogram->AddCount(1000000000, 15);
- scoped_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot1(histogram->SnapshotSamples());
EXPECT_EQ(15, snapshot1->TotalCount());
EXPECT_EQ(15, snapshot1->GetCount(1000000000));
histogram->AddCount(1000000000, 15);
histogram->AddCount(1010000000, 25);
- scoped_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> snapshot2(histogram->SnapshotSamples());
EXPECT_EQ(55, snapshot2->TotalCount());
EXPECT_EQ(30, snapshot2->GetCount(1000000000));
EXPECT_EQ(25, snapshot2->GetCount(1010000000));
@@ -170,7 +170,8 @@
: 0),
sparse_histogram->flags());
- scoped_ptr<HistogramSamples> samples = sparse_histogram->SnapshotSamples();
+ std::unique_ptr<HistogramSamples> samples =
+ sparse_histogram->SnapshotSamples();
EXPECT_EQ(3, samples->TotalCount());
EXPECT_EQ(2, samples->GetCount(100));
EXPECT_EQ(1, samples->GetCount(200));
@@ -195,7 +196,7 @@
}
TEST_P(SparseHistogramTest, Serialize) {
- scoped_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
+ std::unique_ptr<SparseHistogram> histogram(NewSparseHistogram("Sparse"));
histogram->SetFlags(HistogramBase::kIPCSerializationSourceFlag);
Pickle pickle;
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index 2bb50ad..0840c9a 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -4,11 +4,12 @@
#include "base/metrics/statistics_recorder.h"
+#include <memory>
+
#include "base/at_exit.h"
#include "base/debug/leak_annotations.h"
#include "base/json/string_escape.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/metrics_hashes.h"
#include "base/stl_util.h"
@@ -147,7 +148,7 @@
const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges(
const BucketRanges* ranges) {
DCHECK(ranges->HasValidChecksum());
- scoped_ptr<const BucketRanges> ranges_deleter;
+ std::unique_ptr<const BucketRanges> ranges_deleter;
if (lock_ == NULL) {
ANNOTATE_LEAKING_OBJECT_PTR(ranges);
@@ -429,9 +430,9 @@
if (!lock_)
return;
- scoped_ptr<HistogramMap> histograms_deleter;
- scoped_ptr<CallbackMap> callbacks_deleter;
- scoped_ptr<RangesMap> ranges_deleter;
+ std::unique_ptr<HistogramMap> histograms_deleter;
+ std::unique_ptr<CallbackMap> callbacks_deleter;
+ std::unique_ptr<RangesMap> ranges_deleter;
// We don't delete lock_ on purpose to avoid having to properly protect
// against it going away after we checked for NULL in the static methods.
{
diff --git a/base/metrics/statistics_recorder_unittest.cc b/base/metrics/statistics_recorder_unittest.cc
index 073cbb1..af05451 100644
--- a/base/metrics/statistics_recorder_unittest.cc
+++ b/base/metrics/statistics_recorder_unittest.cc
@@ -2,17 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/metrics/statistics_recorder.h"
+
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/sparse_histogram.h"
-#include "base/metrics/statistics_recorder.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -272,7 +273,7 @@
std::string json(StatisticsRecorder::ToJSON(std::string()));
// Check for valid JSON.
- scoped_ptr<Value> root = JSONReader::Read(json);
+ std::unique_ptr<Value> root = JSONReader::Read(json);
ASSERT_TRUE(root.get());
DictionaryValue* root_dict = NULL;
diff --git a/base/pickle_unittest.cc b/base/pickle_unittest.cc
index 307cb51..e00edd9 100644
--- a/base/pickle_unittest.cc
+++ b/base/pickle_unittest.cc
@@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/pickle.h"
+
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/pickle.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -163,7 +164,7 @@
// Tests that we can handle really small buffers.
TEST(PickleTest, SmallBuffer) {
- scoped_ptr<char[]> buffer(new char[1]);
+ std::unique_ptr<char[]> buffer(new char[1]);
// We should not touch the buffer.
Pickle pickle(buffer.get(), 1);
@@ -329,7 +330,7 @@
TEST(PickleTest, FindNextWithIncompleteHeader) {
size_t header_size = sizeof(Pickle::Header);
- scoped_ptr<char[]> buffer(new char[header_size - 1]);
+ std::unique_ptr<char[]> buffer(new char[header_size - 1]);
memset(buffer.get(), 0x1, header_size - 1);
const char* start = buffer.get();
@@ -346,7 +347,7 @@
size_t header_size = sizeof(Pickle::Header);
size_t header_size2 = 2 * header_size;
size_t payload_received = 100;
- scoped_ptr<char[]> buffer(new char[header_size2 + payload_received]);
+ std::unique_ptr<char[]> buffer(new char[header_size2 + payload_received]);
const char* start = buffer.get();
Pickle::Header* header = reinterpret_cast<Pickle::Header*>(buffer.get());
const char* end = start + header_size2 + payload_received;
@@ -390,7 +391,7 @@
TEST(PickleTest, Resize) {
size_t unit = Pickle::kPayloadUnit;
- scoped_ptr<char[]> data(new char[unit]);
+ std::unique_ptr<char[]> data(new char[unit]);
char* data_ptr = data.get();
for (size_t i = 0; i < unit; i++)
data_ptr[i] = 'G';
diff --git a/base/power_monitor/power_monitor.cc b/base/power_monitor/power_monitor.cc
index 1033299..11082df 100644
--- a/base/power_monitor/power_monitor.cc
+++ b/base/power_monitor/power_monitor.cc
@@ -12,7 +12,7 @@
static PowerMonitor* g_power_monitor = NULL;
-PowerMonitor::PowerMonitor(scoped_ptr<PowerMonitorSource> source)
+PowerMonitor::PowerMonitor(std::unique_ptr<PowerMonitorSource> source)
: observers_(new ObserverListThreadSafe<PowerObserver>()),
source_(std::move(source)) {
DCHECK(!g_power_monitor);
diff --git a/base/power_monitor/power_monitor.h b/base/power_monitor/power_monitor.h
index 683eeb9..e025b32 100644
--- a/base/power_monitor/power_monitor.h
+++ b/base/power_monitor/power_monitor.h
@@ -20,7 +20,7 @@
class BASE_EXPORT PowerMonitor {
public:
// Takes ownership of |source|.
- explicit PowerMonitor(scoped_ptr<PowerMonitorSource> source);
+ explicit PowerMonitor(std::unique_ptr<PowerMonitorSource> source);
~PowerMonitor();
// Get the process-wide PowerMonitor (if not present, returns NULL).
@@ -45,7 +45,7 @@
void NotifyResume();
scoped_refptr<ObserverListThreadSafe<PowerObserver> > observers_;
- scoped_ptr<PowerMonitorSource> source_;
+ std::unique_ptr<PowerMonitorSource> source_;
DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
};
diff --git a/base/power_monitor/power_monitor_unittest.cc b/base/power_monitor/power_monitor_unittest.cc
index 798a21c..0c4e7cb 100644
--- a/base/power_monitor/power_monitor_unittest.cc
+++ b/base/power_monitor/power_monitor_unittest.cc
@@ -14,7 +14,7 @@
PowerMonitorTest() {
power_monitor_source_ = new PowerMonitorTestSource();
power_monitor_.reset(new PowerMonitor(
- scoped_ptr<PowerMonitorSource>(power_monitor_source_)));
+ std::unique_ptr<PowerMonitorSource>(power_monitor_source_)));
}
~PowerMonitorTest() override{};
@@ -23,7 +23,7 @@
private:
PowerMonitorTestSource* power_monitor_source_;
- scoped_ptr<PowerMonitor> power_monitor_;
+ std::unique_ptr<PowerMonitor> power_monitor_;
DISALLOW_COPY_AND_ASSIGN(PowerMonitorTest);
};
diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc
index 4019de5..c496190 100644
--- a/base/process/launch_posix.cc
+++ b/base/process/launch_posix.cc
@@ -22,6 +22,7 @@
#include <iterator>
#include <limits>
+#include <memory>
#include <set>
#include "base/command_line.h"
@@ -32,7 +33,6 @@
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process.h"
#include "base/process/process_metrics.h"
@@ -202,7 +202,7 @@
};
// Automatically closes |DIR*|s.
-typedef scoped_ptr<DIR, ScopedDIRClose> ScopedDIR;
+typedef std::unique_ptr<DIR, ScopedDIRClose> ScopedDIR;
#if defined(OS_LINUX)
static const char kFDDir[] = "/proc/self/fd";
@@ -301,13 +301,13 @@
fd_shuffle1.reserve(fd_shuffle_size);
fd_shuffle2.reserve(fd_shuffle_size);
- scoped_ptr<char* []> argv_cstr(new char* [argv.size() + 1]);
+ std::unique_ptr<char* []> argv_cstr(new char*[argv.size() + 1]);
for (size_t i = 0; i < argv.size(); i++) {
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
}
argv_cstr[argv.size()] = NULL;
- scoped_ptr<char*[]> new_environ;
+ std::unique_ptr<char* []> new_environ;
char* const empty_environ = NULL;
char* const* old_environ = GetEnvironment();
if (options.clear_environ)
@@ -552,7 +552,7 @@
int pipe_fd[2];
pid_t pid;
InjectiveMultimap fd_shuffle1, fd_shuffle2;
- scoped_ptr<char*[]> argv_cstr(new char*[argv.size() + 1]);
+ std::unique_ptr<char* []> argv_cstr(new char*[argv.size() + 1]);
fd_shuffle1.reserve(3);
fd_shuffle2.reserve(3);
diff --git a/base/process/process_metrics.cc b/base/process/process_metrics.cc
index a21891d..0b38726 100644
--- a/base/process/process_metrics.cc
+++ b/base/process/process_metrics.cc
@@ -31,8 +31,8 @@
return system_metrics;
}
-scoped_ptr<Value> SystemMetrics::ToValue() const {
- scoped_ptr<DictionaryValue> res(new DictionaryValue());
+std::unique_ptr<Value> SystemMetrics::ToValue() const {
+ std::unique_ptr<DictionaryValue> res(new DictionaryValue());
res->SetInteger("committed_memory", static_cast<int>(committed_memory_));
#if defined(OS_LINUX) || defined(OS_ANDROID)
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index 9c868cc..8d4e51b 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -267,7 +267,7 @@
SystemMemoryInfoKB(const SystemMemoryInfoKB& other);
// Serializes the platform specific fields to value.
- scoped_ptr<Value> ToValue() const;
+ std::unique_ptr<Value> ToValue() const;
int total;
int free;
@@ -343,7 +343,7 @@
SystemDiskInfo(const SystemDiskInfo& other);
// Serializes the platform specific fields to value.
- scoped_ptr<Value> ToValue() const;
+ std::unique_ptr<Value> ToValue() const;
uint64_t reads;
uint64_t reads_merged;
@@ -380,7 +380,7 @@
}
// Serializes the platform specific fields to value.
- scoped_ptr<Value> ToValue() const;
+ std::unique_ptr<Value> ToValue() const;
uint64_t num_reads;
uint64_t num_writes;
@@ -404,7 +404,7 @@
static SystemMetrics Sample();
// Serializes the system metrics to value.
- scoped_ptr<Value> ToValue() const;
+ std::unique_ptr<Value> ToValue() const;
private:
FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics);
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc
index c6aff3e..89a2609 100644
--- a/base/process/process_metrics_linux.cc
+++ b/base/process/process_metrics_linux.cc
@@ -559,8 +559,8 @@
SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) =
default;
-scoped_ptr<Value> SystemMemoryInfoKB::ToValue() const {
- scoped_ptr<DictionaryValue> res(new DictionaryValue());
+std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const {
+ std::unique_ptr<DictionaryValue> res(new DictionaryValue());
res->SetInteger("total", total);
res->SetInteger("free", free);
@@ -772,8 +772,8 @@
SystemDiskInfo::SystemDiskInfo(const SystemDiskInfo& other) = default;
-scoped_ptr<Value> SystemDiskInfo::ToValue() const {
- scoped_ptr<DictionaryValue> res(new DictionaryValue());
+std::unique_ptr<Value> SystemDiskInfo::ToValue() const {
+ std::unique_ptr<DictionaryValue> res(new DictionaryValue());
// Write out uint64_t variables as doubles.
// Note: this may discard some precision, but for JS there's no other option.
@@ -898,8 +898,8 @@
}
#if defined(OS_CHROMEOS)
-scoped_ptr<Value> SwapInfo::ToValue() const {
- scoped_ptr<DictionaryValue> res(new DictionaryValue());
+std::unique_ptr<Value> SwapInfo::ToValue() const {
+ std::unique_ptr<DictionaryValue> res(new DictionaryValue());
// Write out uint64_t variables as doubles.
// Note: this may discard some precision, but for JS there's no other option.
diff --git a/base/process/process_metrics_unittest.cc b/base/process/process_metrics_unittest.cc
index 96ba6ce..4c5b71d 100644
--- a/base/process/process_metrics_unittest.cc
+++ b/base/process/process_metrics_unittest.cc
@@ -303,7 +303,7 @@
// calls to it.
TEST_F(SystemMetricsTest, TestNoNegativeCpuUsage) {
ProcessHandle handle = GetCurrentProcessHandle();
- scoped_ptr<ProcessMetrics> metrics(
+ std::unique_ptr<ProcessMetrics> metrics(
ProcessMetrics::CreateProcessMetrics(handle));
EXPECT_GE(metrics->GetCPUUsage(), 0.0);
@@ -424,7 +424,7 @@
ASSERT_GT(initial_threads, 0);
const int kNumAdditionalThreads = 10;
{
- scoped_ptr<Thread> my_threads[kNumAdditionalThreads];
+ std::unique_ptr<Thread> my_threads[kNumAdditionalThreads];
for (int i = 0; i < kNumAdditionalThreads; ++i) {
my_threads[i].reset(new Thread("GetNumberOfThreadsTest"));
my_threads[i]->Start();
@@ -496,7 +496,7 @@
ASSERT_TRUE(child.IsValid());
WaitForEvent(temp_path, kSignalClosed);
- scoped_ptr<ProcessMetrics> metrics(
+ std::unique_ptr<ProcessMetrics> metrics(
ProcessMetrics::CreateProcessMetrics(child.Handle()));
EXPECT_EQ(0, metrics->GetOpenFdCount());
ASSERT_TRUE(child.Terminate(0, true));
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
index 5034f1f..69b3551 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -17,7 +17,6 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/kill.h"
diff --git a/base/profiler/native_stack_sampler.h b/base/profiler/native_stack_sampler.h
index 40be5cd..c7ef84a 100644
--- a/base/profiler/native_stack_sampler.h
+++ b/base/profiler/native_stack_sampler.h
@@ -5,9 +5,10 @@
#ifndef BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
#define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/profiler/stack_sampling_profiler.h"
#include "base/threading/platform_thread.h"
@@ -24,7 +25,7 @@
// Creates a stack sampler that records samples for |thread_handle|. Returns
// null if this platform does not support stack sampling.
- static scoped_ptr<NativeStackSampler> Create(
+ static std::unique_ptr<NativeStackSampler> Create(
PlatformThreadId thread_id,
NativeStackSamplerTestDelegate* test_delegate);
diff --git a/base/profiler/native_stack_sampler_posix.cc b/base/profiler/native_stack_sampler_posix.cc
index c67d885..a386766 100644
--- a/base/profiler/native_stack_sampler_posix.cc
+++ b/base/profiler/native_stack_sampler_posix.cc
@@ -6,10 +6,10 @@
namespace base {
-scoped_ptr<NativeStackSampler> NativeStackSampler::Create(
+std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
PlatformThreadId thread_id,
NativeStackSamplerTestDelegate* test_delegate) {
- return scoped_ptr<NativeStackSampler>();
+ return std::unique_ptr<NativeStackSampler>();
}
} // namespace base
diff --git a/base/profiler/stack_sampling_profiler.cc b/base/profiler/stack_sampling_profiler.cc
index 0749ae5..2ece509 100644
--- a/base/profiler/stack_sampling_profiler.cc
+++ b/base/profiler/stack_sampling_profiler.cc
@@ -42,12 +42,12 @@
// Runs the callback and deletes the AsyncRunner instance.
static void RunCallbackAndDeleteInstance(
- scoped_ptr<AsyncRunner> object_to_be_deleted,
+ std::unique_ptr<AsyncRunner> object_to_be_deleted,
const StackSamplingProfiler::CompletedCallback& callback,
scoped_refptr<SingleThreadTaskRunner> task_runner,
const StackSamplingProfiler::CallStackProfiles& profiles);
- scoped_ptr<StackSamplingProfiler> profiler_;
+ std::unique_ptr<StackSamplingProfiler> profiler_;
DISALLOW_COPY_AND_ASSIGN(AsyncRunner);
};
@@ -57,7 +57,7 @@
PlatformThreadId thread_id,
const StackSamplingProfiler::SamplingParams& params,
const StackSamplingProfiler::CompletedCallback &callback) {
- scoped_ptr<AsyncRunner> runner(new AsyncRunner);
+ std::unique_ptr<AsyncRunner> runner(new AsyncRunner);
AsyncRunner* temp_ptr = runner.get();
temp_ptr->profiler_.reset(
new StackSamplingProfiler(thread_id, params,
@@ -72,7 +72,7 @@
AsyncRunner::AsyncRunner() {}
void AsyncRunner::RunCallbackAndDeleteInstance(
- scoped_ptr<AsyncRunner> object_to_be_deleted,
+ std::unique_ptr<AsyncRunner> object_to_be_deleted,
const StackSamplingProfiler::CompletedCallback& callback,
scoped_refptr<SingleThreadTaskRunner> task_runner,
const StackSamplingProfiler::CallStackProfiles& profiles) {
@@ -115,7 +115,7 @@
// StackSamplingProfiler::SamplingThread --------------------------------------
StackSamplingProfiler::SamplingThread::SamplingThread(
- scoped_ptr<NativeStackSampler> native_sampler,
+ std::unique_ptr<NativeStackSampler> native_sampler,
const SamplingParams& params,
const CompletedCallback& completed_callback)
: native_sampler_(std::move(native_sampler)),
@@ -255,7 +255,7 @@
if (completed_callback_.is_null())
return;
- scoped_ptr<NativeStackSampler> native_sampler =
+ std::unique_ptr<NativeStackSampler> native_sampler =
NativeStackSampler::Create(thread_id_, test_delegate_);
if (!native_sampler)
return;
diff --git a/base/profiler/stack_sampling_profiler.h b/base/profiler/stack_sampling_profiler.h
index e972d57..9424ca0 100644
--- a/base/profiler/stack_sampling_profiler.h
+++ b/base/profiler/stack_sampling_profiler.h
@@ -7,6 +7,7 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
@@ -14,7 +15,6 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
@@ -197,7 +197,7 @@
// Samples stacks using |native_sampler|. When complete, invokes
// |completed_callback| with the collected call stack profiles.
// |completed_callback| must be callable on any thread.
- SamplingThread(scoped_ptr<NativeStackSampler> native_sampler,
+ SamplingThread(std::unique_ptr<NativeStackSampler> native_sampler,
const SamplingParams& params,
const CompletedCallback& completed_callback);
~SamplingThread() override;
@@ -219,7 +219,7 @@
// |call_stack_profiles| may contain a partial burst.
void CollectProfiles(CallStackProfiles* profiles);
- scoped_ptr<NativeStackSampler> native_sampler_;
+ std::unique_ptr<NativeStackSampler> native_sampler_;
const SamplingParams params_;
// If Stop() is called, it signals this event to force the sampling to
@@ -236,7 +236,7 @@
const SamplingParams params_;
- scoped_ptr<SamplingThread> sampling_thread_;
+ std::unique_ptr<SamplingThread> sampling_thread_;
PlatformThreadHandle sampling_thread_handle_;
const CompletedCallback completed_callback_;
diff --git a/base/profiler/stack_sampling_profiler_unittest.cc b/base/profiler/stack_sampling_profiler_unittest.cc
index fad25a5..12a05e1 100644
--- a/base/profiler/stack_sampling_profiler_unittest.cc
+++ b/base/profiler/stack_sampling_profiler_unittest.cc
@@ -790,7 +790,7 @@
CallStackProfiles profiles;
WithTargetThread([¶ms, &profiles](PlatformThreadId target_thread_id) {
- scoped_ptr<StackSamplingProfiler> profiler;
+ std::unique_ptr<StackSamplingProfiler> profiler;
profiler.reset(new StackSamplingProfiler(
target_thread_id, params, Bind(&SaveProfiles, Unretained(&profiles))));
profiler->Start();
diff --git a/base/profiler/win32_stack_frame_unwinder.cc b/base/profiler/win32_stack_frame_unwinder.cc
index 472f4f1..9e6ab39 100644
--- a/base/profiler/win32_stack_frame_unwinder.cc
+++ b/base/profiler/win32_stack_frame_unwinder.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/macros.h"
#include "base/profiler/win32_stack_frame_unwinder.h"
#include <windows.h>
+
#include <utility>
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+
namespace base {
// Win32UnwindFunctions -------------------------------------------------------
@@ -109,8 +112,7 @@
Win32StackFrameUnwinder::UnwindFunctions::UnwindFunctions() {}
Win32StackFrameUnwinder::Win32StackFrameUnwinder()
- : Win32StackFrameUnwinder(make_scoped_ptr(new Win32UnwindFunctions)) {
-}
+ : Win32StackFrameUnwinder(WrapUnique(new Win32UnwindFunctions)) {}
Win32StackFrameUnwinder::~Win32StackFrameUnwinder() {}
@@ -178,8 +180,7 @@
}
Win32StackFrameUnwinder::Win32StackFrameUnwinder(
- scoped_ptr<UnwindFunctions> unwind_functions)
- : at_top_frame_(true),
- unwind_functions_(std::move(unwind_functions)) {}
+ std::unique_ptr<UnwindFunctions> unwind_functions)
+ : at_top_frame_(true), unwind_functions_(std::move(unwind_functions)) {}
} // namespace base
diff --git a/base/profiler/win32_stack_frame_unwinder.h b/base/profiler/win32_stack_frame_unwinder.h
index 18cd9d6..c92d50c 100644
--- a/base/profiler/win32_stack_frame_unwinder.h
+++ b/base/profiler/win32_stack_frame_unwinder.h
@@ -7,9 +7,10 @@
#include <windows.h>
+#include <memory>
+
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/scoped_handle.h"
namespace base {
@@ -84,14 +85,14 @@
private:
// This function is for internal and test purposes only.
- Win32StackFrameUnwinder(scoped_ptr<UnwindFunctions> unwind_functions);
+ Win32StackFrameUnwinder(std::unique_ptr<UnwindFunctions> unwind_functions);
friend class Win32StackFrameUnwinderTest;
// State associated with each stack unwinding.
bool at_top_frame_;
bool unwind_info_present_for_all_frames_;
- scoped_ptr<UnwindFunctions> unwind_functions_;
+ std::unique_ptr<UnwindFunctions> unwind_functions_;
DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinder);
};
diff --git a/base/profiler/win32_stack_frame_unwinder_unittest.cc b/base/profiler/win32_stack_frame_unwinder_unittest.cc
index 264ddf3..cecfe22 100644
--- a/base/profiler/win32_stack_frame_unwinder_unittest.cc
+++ b/base/profiler/win32_stack_frame_unwinder_unittest.cc
@@ -4,12 +4,13 @@
#include "base/profiler/win32_stack_frame_unwinder.h"
+#include <memory>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -126,7 +127,7 @@
// This exists so that Win32StackFrameUnwinder's constructor can be private
// with a single friend declaration of this test fixture.
- scoped_ptr<Win32StackFrameUnwinder> CreateUnwinder();
+ std::unique_ptr<Win32StackFrameUnwinder> CreateUnwinder();
// Weak pointer to the unwind functions used by last created unwinder.
TestUnwindFunctions* unwind_functions_;
@@ -135,17 +136,18 @@
DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinderTest);
};
-scoped_ptr<Win32StackFrameUnwinder>
+std::unique_ptr<Win32StackFrameUnwinder>
Win32StackFrameUnwinderTest::CreateUnwinder() {
- scoped_ptr<TestUnwindFunctions> unwind_functions(new TestUnwindFunctions);
+ std::unique_ptr<TestUnwindFunctions> unwind_functions(
+ new TestUnwindFunctions);
unwind_functions_ = unwind_functions.get();
- return make_scoped_ptr(
+ return WrapUnique(
new Win32StackFrameUnwinder(std::move(unwind_functions)));
}
// Checks the case where all frames have unwind information.
TEST_F(Win32StackFrameUnwinderTest, FramesWithUnwindInfo) {
- scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
+ std::unique_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
CONTEXT context = {0};
ScopedModuleHandle module;
@@ -166,7 +168,7 @@
// Checks that an instruction pointer in an unloaded module fails to unwind.
TEST_F(Win32StackFrameUnwinderTest, UnloadedModule) {
- scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
+ std::unique_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
CONTEXT context = {0};
ScopedModuleHandle module;
@@ -177,7 +179,7 @@
// Checks that the CONTEXT's stack pointer gets popped when the top frame has no
// unwind information.
TEST_F(Win32StackFrameUnwinderTest, FrameAtTopWithoutUnwindInfo) {
- scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
+ std::unique_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
CONTEXT context = {0};
ScopedModuleHandle module;
DWORD64 next_ip = 0x0123456789abcdef;
@@ -206,7 +208,7 @@
TEST_F(Win32StackFrameUnwinderTest, FrameBelowTopWithoutUnwindInfo) {
{
// First stack, with a bad function below the top of the stack.
- scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
+ std::unique_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder();
CONTEXT context = {0};
ScopedModuleHandle module;
unwind_functions_->SetHasRuntimeFunction(&context);
diff --git a/base/rand_util_unittest.cc b/base/rand_util_unittest.cc
index ea803ee..4f46b80 100644
--- a/base/rand_util_unittest.cc
+++ b/base/rand_util_unittest.cc
@@ -9,9 +9,9 @@
#include <algorithm>
#include <limits>
+#include <memory>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -143,7 +143,7 @@
const int kTestIterations = 10;
const size_t kTestBufferSize = 1 * 1024 * 1024;
- scoped_ptr<uint8_t[]> buffer(new uint8_t[kTestBufferSize]);
+ std::unique_ptr<uint8_t[]> buffer(new uint8_t[kTestBufferSize]);
const base::TimeTicks now = base::TimeTicks::Now();
for (int i = 0; i < kTestIterations; ++i)
base::RandBytes(buffer.get(), kTestBufferSize);
diff --git a/base/security_unittest.cc b/base/security_unittest.cc
index 39ccdf5..c39864e 100644
--- a/base/security_unittest.cc
+++ b/base/security_unittest.cc
@@ -12,11 +12,11 @@
#include <algorithm>
#include <limits>
+#include <memory>
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -110,8 +110,8 @@
const size_t kArraySize2 = kMaxSizeT / kArraySize + 10;
const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2);
{
- scoped_ptr<char[][kArraySize]> array_pointer(new (nothrow)
- char[kDynamicArraySize2][kArraySize]);
+ std::unique_ptr<char[][kArraySize]> array_pointer(
+ new (nothrow) char[kDynamicArraySize2][kArraySize]);
OverflowTestsSoftExpectTrue(!array_pointer);
}
// On windows, the compiler prevents static array sizes of more than
@@ -120,8 +120,8 @@
ALLOW_UNUSED_LOCAL(kDynamicArraySize);
#else
{
- scoped_ptr<char[][kArraySize2]> array_pointer(new (nothrow)
- char[kDynamicArraySize][kArraySize2]);
+ std::unique_ptr<char[][kArraySize2]> array_pointer(
+ new (nothrow) char[kDynamicArraySize][kArraySize2]);
OverflowTestsSoftExpectTrue(!array_pointer);
}
#endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
@@ -157,7 +157,7 @@
// 1 MB should get us past what TCMalloc pre-allocated before initializing
// the sophisticated allocators.
size_t kAllocSize = 1<<20;
- scoped_ptr<char, base::FreeDeleter> ptr(
+ std::unique_ptr<char, base::FreeDeleter> ptr(
static_cast<char*>(malloc(kAllocSize)));
ASSERT_TRUE(ptr != NULL);
// If two pointers are separated by less than 512MB, they are considered
diff --git a/base/sequence_checker_unittest.cc b/base/sequence_checker_unittest.cc
index e261b04..1e89a5f 100644
--- a/base/sequence_checker_unittest.cc
+++ b/base/sequence_checker_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <utility>
#include "base/bind.h"
@@ -14,7 +15,6 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread.h"
@@ -94,7 +94,7 @@
}
void PostDeleteToOtherThread(
- scoped_ptr<SequenceCheckedObject> sequence_checked_object) {
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object) {
other_thread()->message_loop()->DeleteSoon(
FROM_HERE,
sequence_checked_object.release());
@@ -115,11 +115,11 @@
private:
MessageLoop message_loop_; // Needed by SequencedWorkerPool to function.
base::Thread other_thread_;
- scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
};
TEST_F(SequenceCheckerTest, CallsAllowedOnSameThread) {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
// Verify that DoStuff doesn't assert.
@@ -130,7 +130,7 @@
}
TEST_F(SequenceCheckerTest, DestructorAllowedOnDifferentThread) {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
// Verify the destructor doesn't assert when called on a different thread.
@@ -139,7 +139,7 @@
}
TEST_F(SequenceCheckerTest, DetachFromSequence) {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
// Verify that DoStuff doesn't assert when called on a different thread after
@@ -151,7 +151,7 @@
}
TEST_F(SequenceCheckerTest, SameSequenceTokenValid) {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
sequence_checked_object->DetachFromSequence();
@@ -166,7 +166,7 @@
}
TEST_F(SequenceCheckerTest, DetachSequenceTokenValid) {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
sequence_checked_object->DetachFromSequence();
@@ -186,7 +186,7 @@
#if GTEST_HAS_DEATH_TEST || !ENABLE_SEQUENCE_CHECKER
void SequenceCheckerTest::MethodOnDifferentThreadDeathTest() {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
// DoStuff should assert in debug builds only when called on a
@@ -210,7 +210,7 @@
#endif // ENABLE_SEQUENCE_CHECKER
void SequenceCheckerTest::DetachThenCallFromDifferentThreadDeathTest() {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
// DoStuff doesn't assert when called on a different thread
@@ -239,7 +239,7 @@
#endif // ENABLE_SEQUENCE_CHECKER
void SequenceCheckerTest::DifferentSequenceTokensDeathTest() {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
sequence_checked_object->DetachFromSequence();
@@ -268,7 +268,7 @@
#endif // ENABLE_SEQUENCE_CHECKER
void SequenceCheckerTest::WorkerPoolAndSimpleThreadDeathTest() {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
sequence_checked_object->DetachFromSequence();
@@ -295,7 +295,7 @@
#endif // ENABLE_SEQUENCE_CHECKER
void SequenceCheckerTest::TwoDifferentWorkerPoolsDeathTest() {
- scoped_ptr<SequenceCheckedObject> sequence_checked_object(
+ std::unique_ptr<SequenceCheckedObject> sequence_checked_object(
new SequenceCheckedObject);
sequence_checked_object->DetachFromSequence();
diff --git a/base/strings/safe_sprintf_unittest.cc b/base/strings/safe_sprintf_unittest.cc
index 931ace8..1a21728 100644
--- a/base/strings/safe_sprintf_unittest.cc
+++ b/base/strings/safe_sprintf_unittest.cc
@@ -10,10 +10,10 @@
#include <string.h>
#include <limits>
+#include <memory>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -205,7 +205,7 @@
// There is a more complicated test in PrintLongString() that covers a lot
// more edge case, but it is also harder to debug in case of a failure.
const char kTestString[] = "This is a test";
- scoped_ptr<char[]> buf(new char[sizeof(kTestString)]);
+ std::unique_ptr<char[]> buf(new char[sizeof(kTestString)]);
EXPECT_EQ(static_cast<ssize_t>(sizeof(kTestString) - 1),
SafeSNPrintf(buf.get(), sizeof(kTestString), kTestString));
EXPECT_EQ(std::string(kTestString), std::string(buf.get()));
@@ -369,7 +369,7 @@
// Allocate slightly more space, so that we can verify that SafeSPrintf()
// never writes past the end of the buffer.
- scoped_ptr<char[]> tmp(new char[sz+2]);
+ std::unique_ptr<char[]> tmp(new char[sz + 2]);
memset(tmp.get(), 'X', sz+2);
// Use SafeSPrintf() to output a complex list of arguments:
@@ -383,7 +383,7 @@
char* out = tmp.get();
size_t out_sz = sz;
size_t len;
- for (scoped_ptr<char[]> perfect_buf;;) {
+ for (std::unique_ptr<char[]> perfect_buf;;) {
size_t needed = SafeSNPrintf(out, out_sz,
#if defined(NDEBUG)
"A%2cong %s: %d %010X %d %p%7s", 'l', "string", "",
diff --git a/base/strings/utf_offset_string_conversions.cc b/base/strings/utf_offset_string_conversions.cc
index 322c7a2..79c00f0 100644
--- a/base/strings/utf_offset_string_conversions.cc
+++ b/base/strings/utf_offset_string_conversions.cc
@@ -7,9 +7,9 @@
#include <stdint.h>
#include <algorithm>
+#include <memory>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversion_utils.h"
diff --git a/base/supports_user_data.cc b/base/supports_user_data.cc
index 482a7e1..6ba3ff6 100644
--- a/base/supports_user_data.cc
+++ b/base/supports_user_data.cc
@@ -4,6 +4,8 @@
#include "base/supports_user_data.h"
+#include "base/memory/ptr_util.h"
+
namespace base {
SupportsUserData::SupportsUserData() {
@@ -21,7 +23,7 @@
void SupportsUserData::SetUserData(const void* key, Data* data) {
DCHECK(thread_checker_.CalledOnValidThread());
- user_data_[key] = make_scoped_ptr(data);
+ user_data_[key] = WrapUnique(data);
}
void SupportsUserData::RemoveUserData(const void* key) {
diff --git a/base/supports_user_data.h b/base/supports_user_data.h
index ab40c1b..a9f1c93 100644
--- a/base/supports_user_data.h
+++ b/base/supports_user_data.h
@@ -6,11 +6,11 @@
#define BASE_SUPPORTS_USER_DATA_H_
#include <map>
+#include <memory>
#include "base/base_export.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
namespace base {
@@ -47,7 +47,7 @@
virtual ~SupportsUserData();
private:
- using DataMap = std::map<const void*, scoped_ptr<Data>>;
+ using DataMap = std::map<const void*, std::unique_ptr<Data>>;
// Externally-defined data accessible by key.
DataMap user_data_;
diff --git a/base/synchronization/condition_variable_unittest.cc b/base/synchronization/condition_variable_unittest.cc
index 4503922..d60b2b8 100644
--- a/base/synchronization/condition_variable_unittest.cc
+++ b/base/synchronization/condition_variable_unittest.cc
@@ -4,16 +4,18 @@
// Multi-threaded tests of ConditionVariable class.
+#include "base/synchronization/condition_variable.h"
+
#include <time.h>
+
#include <algorithm>
+#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
-#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/spin_wait.h"
#include "base/threading/platform_thread.h"
@@ -133,7 +135,7 @@
const int thread_count_;
int waiting_thread_count_;
- scoped_ptr<PlatformThreadHandle[]> thread_handles_;
+ std::unique_ptr<PlatformThreadHandle[]> thread_handles_;
std::vector<int> assignment_history_; // Number of assignment per worker.
std::vector<int> completion_history_; // Number of completions per worker.
int thread_started_counter_; // Used to issue unique id to workers.
diff --git a/base/sys_info_chromeos.cc b/base/sys_info_chromeos.cc
index e35bd0a..3794ed9 100644
--- a/base/sys_info_chromeos.cc
+++ b/base/sys_info_chromeos.cc
@@ -60,7 +60,7 @@
is_running_on_chromeos_ = false;
std::string lsb_release, lsb_release_time_str;
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
bool parsed_from_env =
env->GetVar(kLsbReleaseKey, &lsb_release) &&
env->GetVar(kLsbReleaseTimeKey, &lsb_release_time_str);
@@ -212,7 +212,7 @@
// static
void SysInfo::SetChromeOSVersionInfoForTest(const std::string& lsb_release,
const Time& lsb_release_time) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
env->SetVar(kLsbReleaseKey, lsb_release);
env->SetVar(kLsbReleaseTimeKey,
DoubleToString(lsb_release_time.ToDoubleT()));
diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc
index a874f8b..8963f7b 100644
--- a/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -22,7 +22,7 @@
}
MessageLoop message_loop_;
- scoped_ptr<SystemMonitor> system_monitor_;
+ std::unique_ptr<SystemMonitor> system_monitor_;
private:
DISALLOW_COPY_AND_ASSIGN(SystemMonitorTest);
diff --git a/base/task_runner_util_unittest.cc b/base/task_runner_util_unittest.cc
index 0a4f22e..1df5436 100644
--- a/base/task_runner_util_unittest.cc
+++ b/base/task_runner_util_unittest.cc
@@ -36,13 +36,13 @@
}
};
-scoped_ptr<Foo> CreateFoo() {
- return scoped_ptr<Foo>(new Foo);
+std::unique_ptr<Foo> CreateFoo() {
+ return std::unique_ptr<Foo>(new Foo);
}
-void ExpectFoo(scoped_ptr<Foo> foo) {
+void ExpectFoo(std::unique_ptr<Foo> foo) {
EXPECT_TRUE(foo.get());
- scoped_ptr<Foo> local_foo(std::move(foo));
+ std::unique_ptr<Foo> local_foo(std::move(foo));
EXPECT_TRUE(local_foo.get());
EXPECT_FALSE(foo.get());
}
@@ -54,13 +54,13 @@
};
};
-scoped_ptr<Foo, FooDeleter> CreateScopedFoo() {
- return scoped_ptr<Foo, FooDeleter>(new Foo);
+std::unique_ptr<Foo, FooDeleter> CreateScopedFoo() {
+ return std::unique_ptr<Foo, FooDeleter>(new Foo);
}
-void ExpectScopedFoo(scoped_ptr<Foo, FooDeleter> foo) {
+void ExpectScopedFoo(std::unique_ptr<Foo, FooDeleter> foo) {
EXPECT_TRUE(foo.get());
- scoped_ptr<Foo, FooDeleter> local_foo(std::move(foo));
+ std::unique_ptr<Foo, FooDeleter> local_foo(std::move(foo));
EXPECT_TRUE(local_foo.get());
EXPECT_FALSE(foo.get());
}
diff --git a/base/task_scheduler/priority_queue.cc b/base/task_scheduler/priority_queue.cc
index 8eb4b86..cea62a3 100644
--- a/base/task_scheduler/priority_queue.cc
+++ b/base/task_scheduler/priority_queue.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
namespace base {
namespace internal {
@@ -40,7 +41,7 @@
}
void PriorityQueue::Transaction::Push(
- scoped_ptr<SequenceAndSortKey> sequence_and_sort_key) {
+ std::unique_ptr<SequenceAndSortKey> sequence_and_sort_key) {
DCHECK(CalledOnValidThread());
DCHECK(!sequence_and_sort_key->is_null());
@@ -81,8 +82,8 @@
PriorityQueue::~PriorityQueue() = default;
-scoped_ptr<PriorityQueue::Transaction> PriorityQueue::BeginTransaction() {
- return make_scoped_ptr(new Transaction(this));
+std::unique_ptr<PriorityQueue::Transaction> PriorityQueue::BeginTransaction() {
+ return WrapUnique(new Transaction(this));
}
} // namespace internal
diff --git a/base/task_scheduler/priority_queue.h b/base/task_scheduler/priority_queue.h
index e37dae9..c87c2b7 100644
--- a/base/task_scheduler/priority_queue.h
+++ b/base/task_scheduler/priority_queue.h
@@ -5,6 +5,7 @@
#ifndef BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_
#define BASE_TASK_SCHEDULER_PRIORITY_QUEUE_H_
+#include <memory>
#include <queue>
#include <vector>
@@ -12,7 +13,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/task_scheduler/scheduler_lock.h"
#include "base/task_scheduler/sequence.h"
#include "base/task_scheduler/sequence_sort_key.h"
@@ -57,7 +57,7 @@
~Transaction();
// Inserts |sequence_and_sort_key| in the PriorityQueue.
- void Push(scoped_ptr<SequenceAndSortKey> sequence_and_sort_key);
+ void Push(std::unique_ptr<SequenceAndSortKey> sequence_and_sort_key);
// Returns the SequenceAndSortKey with the highest priority or a null
// SequenceAndSortKey if the PriorityQueue is empty. The reference becomes
@@ -77,7 +77,7 @@
// Transaction. Using a scoped_ptr allows the destructor to release the lock
// before performing internal operations which have to be done outside of
// its scope.
- scoped_ptr<AutoSchedulerLock> auto_lock_;
+ std::unique_ptr<AutoSchedulerLock> auto_lock_;
PriorityQueue* const outer_queue_;
@@ -105,18 +105,18 @@
// active Transaction unless the last Transaction created on the thread was
// for the allowed predecessor specified in the constructor of this
// PriorityQueue.
- scoped_ptr<Transaction> BeginTransaction();
+ std::unique_ptr<Transaction> BeginTransaction();
private:
struct SequenceAndSortKeyComparator {
- bool operator()(const scoped_ptr<SequenceAndSortKey>& left,
- const scoped_ptr<SequenceAndSortKey>& right) const {
+ bool operator()(const std::unique_ptr<SequenceAndSortKey>& left,
+ const std::unique_ptr<SequenceAndSortKey>& right) const {
return left->sort_key < right->sort_key;
}
};
using ContainerType =
- std::priority_queue<scoped_ptr<SequenceAndSortKey>,
- std::vector<scoped_ptr<SequenceAndSortKey>>,
+ std::priority_queue<std::unique_ptr<SequenceAndSortKey>,
+ std::vector<std::unique_ptr<SequenceAndSortKey>>,
SequenceAndSortKeyComparator>;
// Synchronizes access to |container_|.
diff --git a/base/task_scheduler/priority_queue_unittest.cc b/base/task_scheduler/priority_queue_unittest.cc
index aef95f1..7a9fa2e 100644
--- a/base/task_scheduler/priority_queue_unittest.cc
+++ b/base/task_scheduler/priority_queue_unittest.cc
@@ -4,11 +4,13 @@
#include "base/task_scheduler/priority_queue.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/task_scheduler/sequence.h"
#include "base/task_scheduler/task.h"
@@ -43,7 +45,7 @@
// SimpleThread:
void Run() override {
- scoped_ptr<PriorityQueue::Transaction> transaction =
+ std::unique_ptr<PriorityQueue::Transaction> transaction =
priority_queue_->BeginTransaction();
transaction_began_.Signal();
}
@@ -82,25 +84,25 @@
TEST(TaskSchedulerPriorityQueueTest, PushPopPeek) {
// Create test sequences.
scoped_refptr<Sequence> sequence_a(new Sequence);
- sequence_a->PushTask(make_scoped_ptr(
+ sequence_a->PushTask(WrapUnique(
new Task(FROM_HERE, Closure(),
TaskTraits().WithPriority(TaskPriority::USER_VISIBLE))));
SequenceSortKey sort_key_a = sequence_a->GetSortKey();
scoped_refptr<Sequence> sequence_b(new Sequence);
- sequence_b->PushTask(make_scoped_ptr(
+ sequence_b->PushTask(WrapUnique(
new Task(FROM_HERE, Closure(),
TaskTraits().WithPriority(TaskPriority::USER_BLOCKING))));
SequenceSortKey sort_key_b = sequence_b->GetSortKey();
scoped_refptr<Sequence> sequence_c(new Sequence);
- sequence_c->PushTask(make_scoped_ptr(
+ sequence_c->PushTask(WrapUnique(
new Task(FROM_HERE, Closure(),
TaskTraits().WithPriority(TaskPriority::USER_BLOCKING))));
SequenceSortKey sort_key_c = sequence_c->GetSortKey();
scoped_refptr<Sequence> sequence_d(new Sequence);
- sequence_d->PushTask(make_scoped_ptr(
+ sequence_d->PushTask(WrapUnique(
new Task(FROM_HERE, Closure(),
TaskTraits().WithPriority(TaskPriority::BACKGROUND))));
SequenceSortKey sort_key_d = sequence_d->GetSortKey();
@@ -110,13 +112,14 @@
PriorityQueue pq(
Bind(&PriorityQueueCallbackMock::SequenceInsertedInPriorityQueue,
Unretained(&mock)));
- scoped_ptr<PriorityQueue::Transaction> transaction(pq.BeginTransaction());
+ std::unique_ptr<PriorityQueue::Transaction> transaction(
+ pq.BeginTransaction());
EXPECT_SEQUENCE_AND_SORT_KEY_EQ(PriorityQueue::SequenceAndSortKey(),
transaction->Peek());
// Push |sequence_a| in the PriorityQueue. It becomes the sequence with the
// highest priority.
- transaction->Push(make_scoped_ptr(
+ transaction->Push(WrapUnique(
new PriorityQueue::SequenceAndSortKey(sequence_a, sort_key_a)));
EXPECT_SEQUENCE_AND_SORT_KEY_EQ(
PriorityQueue::SequenceAndSortKey(sequence_a, sort_key_a),
@@ -124,7 +127,7 @@
// Push |sequence_b| in the PriorityQueue. It becomes the sequence with the
// highest priority.
- transaction->Push(make_scoped_ptr(
+ transaction->Push(WrapUnique(
new PriorityQueue::SequenceAndSortKey(sequence_b, sort_key_b)));
EXPECT_SEQUENCE_AND_SORT_KEY_EQ(
PriorityQueue::SequenceAndSortKey(sequence_b, sort_key_b),
@@ -132,7 +135,7 @@
// Push |sequence_c| in the PriorityQueue. |sequence_b| is still the sequence
// with the highest priority.
- transaction->Push(make_scoped_ptr(
+ transaction->Push(WrapUnique(
new PriorityQueue::SequenceAndSortKey(sequence_c, sort_key_c)));
EXPECT_SEQUENCE_AND_SORT_KEY_EQ(
PriorityQueue::SequenceAndSortKey(sequence_b, sort_key_b),
@@ -140,7 +143,7 @@
// Push |sequence_d| in the PriorityQueue. |sequence_b| is still the sequence
// with the highest priority.
- transaction->Push(make_scoped_ptr(
+ transaction->Push(WrapUnique(
new PriorityQueue::SequenceAndSortKey(sequence_d, sort_key_d)));
EXPECT_SEQUENCE_AND_SORT_KEY_EQ(
PriorityQueue::SequenceAndSortKey(sequence_b, sort_key_b),
@@ -186,9 +189,9 @@
EXPECT_DCHECK_DEATH(
{
- scoped_ptr<PriorityQueue::Transaction> transaction_a =
+ std::unique_ptr<PriorityQueue::Transaction> transaction_a =
pq_a.BeginTransaction();
- scoped_ptr<PriorityQueue::Transaction> transaction_b =
+ std::unique_ptr<PriorityQueue::Transaction> transaction_b =
pq_b.BeginTransaction();
},
"");
@@ -201,9 +204,9 @@
PriorityQueue pq_b(Bind(&DoNothing), &pq_a);
// This shouldn't crash.
- scoped_ptr<PriorityQueue::Transaction> transaction_a =
+ std::unique_ptr<PriorityQueue::Transaction> transaction_a =
pq_a.BeginTransaction();
- scoped_ptr<PriorityQueue::Transaction> transaction_b =
+ std::unique_ptr<PriorityQueue::Transaction> transaction_b =
pq_b.BeginTransaction();
}
@@ -215,7 +218,8 @@
PriorityQueue pq(Bind(&DoNothing));
// Call BeginTransaction() on this thread and keep the Transaction alive.
- scoped_ptr<PriorityQueue::Transaction> transaction = pq.BeginTransaction();
+ std::unique_ptr<PriorityQueue::Transaction> transaction =
+ pq.BeginTransaction();
// Call BeginTransaction() on another thread.
ThreadBeginningTransaction thread_beginning_transaction(&pq);
diff --git a/base/task_scheduler/scheduler_lock.h b/base/task_scheduler/scheduler_lock.h
index be7c71c..c969eb1 100644
--- a/base/task_scheduler/scheduler_lock.h
+++ b/base/task_scheduler/scheduler_lock.h
@@ -5,9 +5,10 @@
#ifndef BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H
#define BASE_TASK_SCHEDULER_SCHEDULER_LOCK_H
+#include <memory>
+
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/task_scheduler/scheduler_lock_impl.h"
@@ -41,7 +42,7 @@
// void AssertAcquired().
// DCHECKs if the lock is not acquired.
//
-// scoped_ptr<ConditionVariable> CreateConditionVariable()
+// std::unique_ptr<ConditionVariable> CreateConditionVariable()
// Creates a condition variable using this as a lock.
#if DCHECK_IS_ON()
@@ -57,8 +58,8 @@
SchedulerLock() = default;
explicit SchedulerLock(const SchedulerLock*) {}
- scoped_ptr<ConditionVariable> CreateConditionVariable() {
- return scoped_ptr<ConditionVariable>(new ConditionVariable(this));
+ std::unique_ptr<ConditionVariable> CreateConditionVariable() {
+ return std::unique_ptr<ConditionVariable>(new ConditionVariable(this));
}
};
#endif // DCHECK_IS_ON()
diff --git a/base/task_scheduler/scheduler_lock_impl.cc b/base/task_scheduler/scheduler_lock_impl.cc
index 609ea22..7480e18 100644
--- a/base/task_scheduler/scheduler_lock_impl.cc
+++ b/base/task_scheduler/scheduler_lock_impl.cc
@@ -136,8 +136,9 @@
lock_.AssertAcquired();
}
-scoped_ptr<ConditionVariable> SchedulerLockImpl::CreateConditionVariable() {
- return scoped_ptr<ConditionVariable>(new ConditionVariable(&lock_));
+std::unique_ptr<ConditionVariable>
+SchedulerLockImpl::CreateConditionVariable() {
+ return std::unique_ptr<ConditionVariable>(new ConditionVariable(&lock_));
}
} // namespace internal
diff --git a/base/task_scheduler/scheduler_lock_impl.h b/base/task_scheduler/scheduler_lock_impl.h
index 51826fc..65699bb 100644
--- a/base/task_scheduler/scheduler_lock_impl.h
+++ b/base/task_scheduler/scheduler_lock_impl.h
@@ -5,9 +5,10 @@
#ifndef BASE_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H
#define BASE_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H
+#include <memory>
+
#include "base/base_export.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
namespace base {
@@ -31,7 +32,7 @@
void AssertAcquired() const;
- scoped_ptr<ConditionVariable> CreateConditionVariable();
+ std::unique_ptr<ConditionVariable> CreateConditionVariable();
private:
Lock lock_;
diff --git a/base/task_scheduler/scheduler_worker_thread.cc b/base/task_scheduler/scheduler_worker_thread.cc
index b9d3d2f..e03726a 100644
--- a/base/task_scheduler/scheduler_worker_thread.cc
+++ b/base/task_scheduler/scheduler_worker_thread.cc
@@ -14,16 +14,17 @@
namespace base {
namespace internal {
-scoped_ptr<SchedulerWorkerThread>
+std::unique_ptr<SchedulerWorkerThread>
SchedulerWorkerThread::CreateSchedulerWorkerThread(
ThreadPriority thread_priority,
const Closure& main_entry_callback,
const GetWorkCallback& get_work_callback,
const RanTaskFromSequenceCallback& ran_task_from_sequence_callback,
TaskTracker* task_tracker) {
- scoped_ptr<SchedulerWorkerThread> worker_thread(new SchedulerWorkerThread(
- thread_priority, main_entry_callback, get_work_callback,
- ran_task_from_sequence_callback, task_tracker));
+ std::unique_ptr<SchedulerWorkerThread> worker_thread(
+ new SchedulerWorkerThread(thread_priority, main_entry_callback,
+ get_work_callback,
+ ran_task_from_sequence_callback, task_tracker));
if (worker_thread->thread_handle_.is_null())
return nullptr;
diff --git a/base/task_scheduler/scheduler_worker_thread.h b/base/task_scheduler/scheduler_worker_thread.h
index 908eaed..8b129a3 100644
--- a/base/task_scheduler/scheduler_worker_thread.h
+++ b/base/task_scheduler/scheduler_worker_thread.h
@@ -5,11 +5,12 @@
#ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_
#define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/task_scheduler/scheduler_lock.h"
#include "base/task_scheduler/sequence.h"
@@ -49,7 +50,7 @@
// SchedulerWorkerThread has tried to run a Task from a Sequence returned by
// |get_work_callback|. |task_tracker| is used to handle shutdown behavior of
// Tasks. Returns nullptr if creating the underlying platform thread fails.
- static scoped_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread(
+ static std::unique_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread(
ThreadPriority thread_priority,
const Closure& main_entry_callback,
const GetWorkCallback& get_work_callback,
diff --git a/base/task_scheduler/scheduler_worker_thread_unittest.cc b/base/task_scheduler/scheduler_worker_thread_unittest.cc
index 9d9866e..fcccda1 100644
--- a/base/task_scheduler/scheduler_worker_thread_unittest.cc
+++ b/base/task_scheduler/scheduler_worker_thread_unittest.cc
@@ -6,12 +6,13 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/synchronization/condition_variable.h"
#include "base/task_scheduler/scheduler_lock.h"
#include "base/task_scheduler/sequence.h"
@@ -98,7 +99,7 @@
return num_get_work_callback_;
}
- scoped_ptr<SchedulerWorkerThread> worker_thread_;
+ std::unique_ptr<SchedulerWorkerThread> worker_thread_;
private:
void MainEntryCallback() {
@@ -130,7 +131,7 @@
scoped_refptr<Sequence> sequence(new Sequence);
task_tracker_.PostTask(
Bind(IgnoreResult(&Sequence::PushTask), Unretained(sequence.get())),
- make_scoped_ptr(new Task(
+ WrapUnique(new Task(
FROM_HERE, Bind(&TaskSchedulerWorkerThreadTest::RunTaskCallback,
Unretained(this)),
TaskTraits())));
@@ -167,7 +168,7 @@
size_t num_main_entry_callback_ = 0;
// Condition variable signaled when |num_main_entry_callback_| is incremented.
- scoped_ptr<ConditionVariable> num_main_entry_callback_cv_;
+ std::unique_ptr<ConditionVariable> num_main_entry_callback_cv_;
// Number of Sequences that should be created by GetWorkCallback(). When this
// is 0, GetWorkCallback() returns nullptr.
@@ -177,7 +178,7 @@
size_t num_get_work_callback_ = 0;
// Condition variable signaled when |num_get_work_callback_| is incremented.
- scoped_ptr<ConditionVariable> num_get_work_callback_cv_;
+ std::unique_ptr<ConditionVariable> num_get_work_callback_cv_;
// Sequences created by GetWorkCallback().
std::vector<scoped_refptr<Sequence>> created_sequences_;
@@ -186,7 +187,7 @@
std::vector<scoped_refptr<Sequence>> run_sequences_;
// Condition variable signaled when a Sequence is added to |run_sequences_|.
- scoped_ptr<ConditionVariable> run_sequences_cv_;
+ std::unique_ptr<ConditionVariable> run_sequences_cv_;
// Number of times that RunTaskCallback() has been called.
size_t num_run_tasks_ = 0;
diff --git a/base/task_scheduler/sequence.cc b/base/task_scheduler/sequence.cc
index a05c802..4ecb605 100644
--- a/base/task_scheduler/sequence.cc
+++ b/base/task_scheduler/sequence.cc
@@ -14,7 +14,7 @@
Sequence::Sequence() = default;
-bool Sequence::PushTask(scoped_ptr<Task> task) {
+bool Sequence::PushTask(std::unique_ptr<Task> task) {
DCHECK(task->sequenced_time.is_null());
task->sequenced_time = base::TimeTicks::Now();
diff --git a/base/task_scheduler/sequence.h b/base/task_scheduler/sequence.h
index e86cf59..b77576b 100644
--- a/base/task_scheduler/sequence.h
+++ b/base/task_scheduler/sequence.h
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <queue>
#include "base/base_export.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/task_scheduler/scheduler_lock.h"
#include "base/task_scheduler/sequence_sort_key.h"
#include "base/task_scheduler/task.h"
@@ -29,7 +29,7 @@
// Adds |task| at the end of the sequence's queue. Returns true if the
// sequence was empty before this operation.
- bool PushTask(scoped_ptr<Task> task);
+ bool PushTask(std::unique_ptr<Task> task);
// Returns the task in front of the sequence's queue, if any.
const Task* PeekTask() const;
@@ -51,7 +51,7 @@
mutable SchedulerLock lock_;
// Queue of tasks to execute.
- std::queue<scoped_ptr<Task>> queue_;
+ std::queue<std::unique_ptr<Task>> queue_;
// Number of tasks contained in the sequence for each priority.
size_t num_tasks_per_priority_[static_cast<int>(TaskPriority::HIGHEST) + 1] =
diff --git a/base/task_scheduler/sequence_unittest.cc b/base/task_scheduler/sequence_unittest.cc
index d81fece..17826a0 100644
--- a/base/task_scheduler/sequence_unittest.cc
+++ b/base/task_scheduler/sequence_unittest.cc
@@ -44,11 +44,11 @@
protected:
// Tasks to be handed off to a Sequence for testing.
- scoped_ptr<Task> task_a_owned_;
- scoped_ptr<Task> task_b_owned_;
- scoped_ptr<Task> task_c_owned_;
- scoped_ptr<Task> task_d_owned_;
- scoped_ptr<Task> task_e_owned_;
+ std::unique_ptr<Task> task_a_owned_;
+ std::unique_ptr<Task> task_b_owned_;
+ std::unique_ptr<Task> task_c_owned_;
+ std::unique_ptr<Task> task_d_owned_;
+ std::unique_ptr<Task> task_e_owned_;
// Raw pointers to those same tasks for verification. This is needed because
// the scoped_ptrs above no longer point to the tasks once they have been
diff --git a/base/task_scheduler/task_tracker.cc b/base/task_scheduler/task_tracker.cc
index 4f15b9e..50922bb 100644
--- a/base/task_scheduler/task_tracker.cc
+++ b/base/task_scheduler/task_tracker.cc
@@ -59,8 +59,8 @@
}
void TaskTracker::PostTask(
- const Callback<void(scoped_ptr<Task>)>& post_task_callback,
- scoped_ptr<Task> task) {
+ const Callback<void(std::unique_ptr<Task>)>& post_task_callback,
+ std::unique_ptr<Task> task) {
DCHECK(!post_task_callback.is_null());
DCHECK(task);
diff --git a/base/task_scheduler/task_tracker.h b/base/task_scheduler/task_tracker.h
index 5b9fd14..811bd9a 100644
--- a/base/task_scheduler/task_tracker.h
+++ b/base/task_scheduler/task_tracker.h
@@ -5,10 +5,11 @@
#ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_H_
#define BASE_TASK_SCHEDULER_TASK_TRACKER_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/synchronization/condition_variable.h"
#include "base/task_scheduler/scheduler_lock.h"
@@ -37,8 +38,8 @@
// Posts |task| by calling |post_task_callback| unless the current shutdown
// state prevents that. A task forwarded to |post_task_callback| must be
// handed back to this instance's RunTask() when it is to be executed.
- void PostTask(const Callback<void(scoped_ptr<Task>)>& post_task_callback,
- scoped_ptr<Task> task);
+ void PostTask(const Callback<void(std::unique_ptr<Task>)>& post_task_callback,
+ std::unique_ptr<Task> task);
// Runs |task| unless the current shutdown state prevents that. |task| must
// have been successfully posted via PostTask() first.
@@ -75,7 +76,7 @@
// Condition variable signaled when |num_tasks_blocking_shutdown_| reaches
// zero while shutdown is in progress. Null if shutdown isn't in progress.
- scoped_ptr<ConditionVariable> shutdown_cv_;
+ std::unique_ptr<ConditionVariable> shutdown_cv_;
// Number of tasks blocking shutdown.
size_t num_tasks_blocking_shutdown_ = 0;
diff --git a/base/task_scheduler/task_tracker_unittest.cc b/base/task_scheduler/task_tracker_unittest.cc
index 7235a8a..2a08bc1 100644
--- a/base/task_scheduler/task_tracker_unittest.cc
+++ b/base/task_scheduler/task_tracker_unittest.cc
@@ -4,12 +4,13 @@
#include "base/task_scheduler/task_tracker.h"
+#include <memory>
#include <queue>
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/task_scheduler/task.h"
#include "base/task_scheduler/task_traits.h"
@@ -67,8 +68,8 @@
TaskSchedulerTaskTrackerTest() = default;
// Creates a task with |shutdown_behavior|.
- scoped_ptr<Task> CreateTask(TaskShutdownBehavior shutdown_behavior) {
- return make_scoped_ptr(new Task(
+ std::unique_ptr<Task> CreateTask(TaskShutdownBehavior shutdown_behavior) {
+ return WrapUnique(new Task(
FROM_HERE,
Bind(&TaskSchedulerTaskTrackerTest::RunTaskCallback, Unretained(this)),
TaskTraits().WithShutdownBehavior(shutdown_behavior)));
@@ -76,7 +77,7 @@
// Tries to post |task| via |tracker_|. If |tracker_| approves the operation,
// |task| is added to |posted_tasks_|.
- void PostTaskViaTracker(scoped_ptr<Task> task) {
+ void PostTaskViaTracker(std::unique_ptr<Task> task) {
tracker_.PostTask(
Bind(&TaskSchedulerTaskTrackerTest::PostTaskCallback, Unretained(this)),
std::move(task));
@@ -118,16 +119,16 @@
TaskTracker tracker_;
size_t num_tasks_executed_ = 0;
- std::queue<scoped_ptr<Task>> posted_tasks_;
+ std::queue<std::unique_ptr<Task>> posted_tasks_;
private:
- void PostTaskCallback(scoped_ptr<Task> task) {
+ void PostTaskCallback(std::unique_ptr<Task> task) {
posted_tasks_.push(std::move(task));
}
void RunTaskCallback() { ++num_tasks_executed_; }
- scoped_ptr<ThreadCallingShutdown> thread_calling_shutdown_;
+ std::unique_ptr<ThreadCallingShutdown> thread_calling_shutdown_;
DISALLOW_COPY_AND_ASSIGN(TaskSchedulerTaskTrackerTest);
};
@@ -147,7 +148,7 @@
} // namespace
TEST_P(TaskSchedulerTaskTrackerTest, PostAndRunBeforeShutdown) {
- scoped_ptr<Task> task_to_post(CreateTask(GetParam()));
+ std::unique_ptr<Task> task_to_post(CreateTask(GetParam()));
const Task* task_to_post_raw = task_to_post.get();
// Post the task.
@@ -169,7 +170,7 @@
// Post a task that will block until |event| is signaled.
EXPECT_TRUE(posted_tasks_.empty());
WaitableEvent event(false, false);
- PostTaskViaTracker(make_scoped_ptr(
+ PostTaskViaTracker(WrapUnique(
new Task(FROM_HERE, Bind(&WaitableEvent::Wait, Unretained(&event)),
TaskTraits().WithShutdownBehavior(GetParam()))));
EXPECT_EQ(1U, posted_tasks_.size());
@@ -199,7 +200,7 @@
}
TEST_P(TaskSchedulerTaskTrackerTest, PostBeforeShutdownRunDuringShutdown) {
- scoped_ptr<Task> task_to_post(CreateTask(GetParam()));
+ std::unique_ptr<Task> task_to_post(CreateTask(GetParam()));
const Task* task_to_post_raw = task_to_post.get();
// Post the task.
@@ -231,7 +232,7 @@
}
TEST_P(TaskSchedulerTaskTrackerTest, PostBeforeShutdownRunAfterShutdown) {
- scoped_ptr<Task> task_to_post(CreateTask(GetParam()));
+ std::unique_ptr<Task> task_to_post(CreateTask(GetParam()));
const Task* task_to_post_raw = task_to_post.get();
// Post the task.
@@ -267,7 +268,7 @@
TEST_P(TaskSchedulerTaskTrackerTest, PostAndRunDuringShutdown) {
// Post a BLOCK_SHUTDOWN task just to block shutdown.
PostTaskViaTracker(CreateTask(TaskShutdownBehavior::BLOCK_SHUTDOWN));
- scoped_ptr<Task> block_shutdown_task = std::move(posted_tasks_.front());
+ std::unique_ptr<Task> block_shutdown_task = std::move(posted_tasks_.front());
posted_tasks_.pop();
// Call Shutdown() asynchronously.
diff --git a/base/test/gtest_util.cc b/base/test/gtest_util.cc
index 8ad5436..b062343 100644
--- a/base/test/gtest_util.cc
+++ b/base/test/gtest_util.cc
@@ -64,7 +64,7 @@
JSONFileValueDeserializer deserializer(path);
int error_code = 0;
std::string error_message;
- scoped_ptr<base::Value> value =
+ std::unique_ptr<base::Value> value =
deserializer.Deserialize(&error_code, &error_message);
if (!value.get())
return false;
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index 5fb01fb..27cb673 100644
--- a/base/test/histogram_tester.cc
+++ b/base/test/histogram_tester.cc
@@ -43,7 +43,8 @@
<< "Histogram \"" << name << "\" does not exist.";
if (histogram) {
- scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
+ std::unique_ptr<base::HistogramSamples> samples(
+ histogram->SnapshotSamples());
CheckBucketCount(name, sample, expected_count, *samples);
CheckTotalCount(name, expected_count, *samples);
}
@@ -59,7 +60,8 @@
<< "Histogram \"" << name << "\" does not exist.";
if (histogram) {
- scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
+ std::unique_ptr<base::HistogramSamples> samples(
+ histogram->SnapshotSamples());
CheckBucketCount(name, sample, expected_count, *samples);
}
}
@@ -69,7 +71,8 @@
base::HistogramBase* histogram =
base::StatisticsRecorder::FindHistogram(name);
if (histogram) {
- scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples());
+ std::unique_ptr<base::HistogramSamples> samples(
+ histogram->SnapshotSamples());
CheckTotalCount(name, count, *samples);
} else {
// No histogram means there were zero samples.
@@ -80,7 +83,7 @@
std::vector<Bucket> HistogramTester::GetAllSamples(
const std::string& name) const {
std::vector<Bucket> samples;
- scoped_ptr<HistogramSamples> snapshot =
+ std::unique_ptr<HistogramSamples> snapshot =
GetHistogramSamplesSinceCreation(name);
if (snapshot) {
for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) {
@@ -105,7 +108,7 @@
CountsMap result;
for (base::HistogramBase* histogram : query_matches) {
- scoped_ptr<HistogramSamples> new_samples =
+ std::unique_ptr<HistogramSamples> new_samples =
GetHistogramSamplesSinceCreation(histogram->histogram_name());
// Omit unchanged histograms from the result.
if (new_samples->TotalCount()) {
@@ -115,7 +118,8 @@
return result;
}
-scoped_ptr<HistogramSamples> HistogramTester::GetHistogramSamplesSinceCreation(
+std::unique_ptr<HistogramSamples>
+HistogramTester::GetHistogramSamplesSinceCreation(
const std::string& histogram_name) const {
HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name);
// Whether the histogram exists or not may not depend on the current test
@@ -125,10 +129,10 @@
// creates empty samples in the absence of the histogram, rather than
// returning null.
if (!histogram) {
- return scoped_ptr<HistogramSamples>(
+ return std::unique_ptr<HistogramSamples>(
new SampleMap(HashMetricName(histogram_name)));
}
- scoped_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples());
+ std::unique_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples());
auto original_samples_it = histograms_snapshot_.find(histogram_name);
if (original_samples_it != histograms_snapshot_.end())
named_samples->Subtract(*original_samples_it->second);
diff --git a/base/test/histogram_tester.h b/base/test/histogram_tester.h
index 604ba83..f11f854 100644
--- a/base/test/histogram_tester.h
+++ b/base/test/histogram_tester.h
@@ -6,13 +6,13 @@
#define BASE_TEST_HISTOGRAM_TESTER_H_
#include <map>
+#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
@@ -93,7 +93,7 @@
// Access a modified HistogramSamples containing only what has been logged
// to the histogram since the creation of this object.
- scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation(
+ std::unique_ptr<HistogramSamples> GetHistogramSamplesSinceCreation(
const std::string& histogram_name) const;
private:
diff --git a/base/test/histogram_tester_unittest.cc b/base/test/histogram_tester_unittest.cc
index 21b8170..c4d49af 100644
--- a/base/test/histogram_tester_unittest.cc
+++ b/base/test/histogram_tester_unittest.cc
@@ -4,7 +4,8 @@
#include "base/test/histogram_tester.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_samples.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -40,7 +41,7 @@
UMA_HISTOGRAM_BOOLEAN(kHistogram1, true);
// Verify that one histogram is recorded.
- scoped_ptr<HistogramSamples> samples(
+ std::unique_ptr<HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(kHistogram1));
EXPECT_TRUE(samples);
EXPECT_EQ(1, samples->TotalCount());
@@ -54,7 +55,7 @@
HistogramTester tester;
// Verify that the returned samples are empty but not null.
- scoped_ptr<HistogramSamples> samples(
+ std::unique_ptr<HistogramSamples> samples(
tester.GetHistogramSamplesSinceCreation(kHistogram1));
EXPECT_TRUE(samples);
tester.ExpectTotalCount(kHistogram, 0);
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 65471c7..df5ca0a 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -4,6 +4,8 @@
#include "base/test/launcher/test_launcher.h"
+#include <memory>
+
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -17,7 +19,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
@@ -170,7 +171,7 @@
// true. If it is set, unsets it then converts it to Int32 before
// returning it in |result|. Returns true on success.
bool TakeInt32FromEnvironment(const char* const var, int32_t* result) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
std::string str_val;
if (!env->GetVar(var, &str_val))
@@ -192,7 +193,7 @@
// Unsets the environment variable |name| and returns true on success.
// Also returns true if the variable just doesn't exist.
bool UnsetEnvironmentVariableIfExists(const std::string& name) {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
std::string str_val;
if (!env->GetVar(name.c_str(), &str_val))
@@ -205,7 +206,7 @@
// for continuous integration bots. This way developers don't have to remember
// special command-line flags.
bool BotModeEnabled() {
- scoped_ptr<Environment> env(Environment::Create());
+ std::unique_ptr<Environment> env(Environment::Create());
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTestLauncherBotMode) ||
env->HasVar("CHROMIUM_TEST_LAUNCHER_BOT_MODE");
diff --git a/base/test/launcher/test_launcher.h b/base/test/launcher/test_launcher.h
index c311fed..38980cf 100644
--- a/base/test/launcher/test_launcher.h
+++ b/base/test/launcher/test_launcher.h
@@ -228,7 +228,7 @@
size_t parallel_jobs_;
// Worker pool used to launch processes in parallel.
- scoped_ptr<SequencedWorkerPoolOwner> worker_pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> worker_pool_owner_;
DISALLOW_COPY_AND_ASSIGN(TestLauncher);
};
diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc
index 813e8e4..ab7d9a2 100644
--- a/base/test/launcher/test_results_tracker.cc
+++ b/base/test/launcher/test_results_tracker.cc
@@ -224,41 +224,42 @@
}
bool TestResultsTracker::SaveSummaryAsJSON(const FilePath& path) const {
- scoped_ptr<DictionaryValue> summary_root(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> summary_root(new DictionaryValue);
- scoped_ptr<ListValue> global_tags(new ListValue);
+ std::unique_ptr<ListValue> global_tags(new ListValue);
for (const auto& global_tag : global_tags_) {
global_tags->AppendString(global_tag);
}
summary_root->Set("global_tags", std::move(global_tags));
- scoped_ptr<ListValue> all_tests(new ListValue);
+ std::unique_ptr<ListValue> all_tests(new ListValue);
for (const auto& test : all_tests_) {
all_tests->AppendString(test);
}
summary_root->Set("all_tests", std::move(all_tests));
- scoped_ptr<ListValue> disabled_tests(new ListValue);
+ std::unique_ptr<ListValue> disabled_tests(new ListValue);
for (const auto& disabled_test : disabled_tests_) {
disabled_tests->AppendString(disabled_test);
}
summary_root->Set("disabled_tests", std::move(disabled_tests));
- scoped_ptr<ListValue> per_iteration_data(new ListValue);
+ std::unique_ptr<ListValue> per_iteration_data(new ListValue);
for (int i = 0; i <= iteration_; i++) {
- scoped_ptr<DictionaryValue> current_iteration_data(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> current_iteration_data(
+ new DictionaryValue);
for (PerIterationData::ResultsMap::const_iterator j =
per_iteration_data_[i].results.begin();
j != per_iteration_data_[i].results.end();
++j) {
- scoped_ptr<ListValue> test_results(new ListValue);
+ std::unique_ptr<ListValue> test_results(new ListValue);
for (size_t k = 0; k < j->second.test_results.size(); k++) {
const TestResult& test_result = j->second.test_results[k];
- scoped_ptr<DictionaryValue> test_result_value(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> test_result_value(new DictionaryValue);
test_result_value->SetString("status", test_result.StatusAsString());
test_result_value->SetInteger(
diff --git a/base/test/test_discardable_memory_allocator.cc b/base/test/test_discardable_memory_allocator.cc
index 0f8e8ce..cd96149 100644
--- a/base/test/test_discardable_memory_allocator.cc
+++ b/base/test/test_discardable_memory_allocator.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/memory/discardable_memory.h"
+#include "base/memory/ptr_util.h"
namespace base {
namespace {
@@ -46,7 +47,7 @@
private:
bool is_locked_ = true;
- scoped_ptr<uint8_t[]> data_;
+ std::unique_ptr<uint8_t[]> data_;
size_t size_;
};
@@ -58,9 +59,9 @@
TestDiscardableMemoryAllocator::~TestDiscardableMemoryAllocator() {
}
-scoped_ptr<DiscardableMemory>
+std::unique_ptr<DiscardableMemory>
TestDiscardableMemoryAllocator::AllocateLockedDiscardableMemory(size_t size) {
- return make_scoped_ptr(new DiscardableMemoryImpl(size));
+ return WrapUnique(new DiscardableMemoryImpl(size));
}
} // namespace base
diff --git a/base/test/test_discardable_memory_allocator.h b/base/test/test_discardable_memory_allocator.h
index 142b328..a6a4351 100644
--- a/base/test/test_discardable_memory_allocator.h
+++ b/base/test/test_discardable_memory_allocator.h
@@ -21,7 +21,7 @@
~TestDiscardableMemoryAllocator() override;
// Overridden from DiscardableMemoryAllocator:
- scoped_ptr<DiscardableMemory> AllocateLockedDiscardableMemory(
+ std::unique_ptr<DiscardableMemory> AllocateLockedDiscardableMemory(
size_t size) override;
private:
diff --git a/base/test/test_mock_time_task_runner.cc b/base/test/test_mock_time_task_runner.cc
index 655a674..7dca3a9 100644
--- a/base/test/test_mock_time_task_runner.cc
+++ b/base/test/test_mock_time_task_runner.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/time/clock.h"
#include "base/time/tick_clock.h"
@@ -162,14 +163,14 @@
return now_ticks_;
}
-scoped_ptr<Clock> TestMockTimeTaskRunner::GetMockClock() const {
+std::unique_ptr<Clock> TestMockTimeTaskRunner::GetMockClock() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return make_scoped_ptr(new MockClock(this));
+ return WrapUnique(new MockClock(this));
}
-scoped_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const {
+std::unique_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return make_scoped_ptr(new MockTickClock(this));
+ return WrapUnique(new MockTickClock(this));
}
bool TestMockTimeTaskRunner::HasPendingTask() const {
diff --git a/base/test/test_mock_time_task_runner.h b/base/test/test_mock_time_task_runner.h
index 7a71e01..624f739 100644
--- a/base/test/test_mock_time_task_runner.h
+++ b/base/test/test_mock_time_task_runner.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <queue>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/test/test_pending_task.h"
@@ -77,11 +77,11 @@
// Returns a Clock that uses the virtual time of |this| as its time source.
// The returned Clock will hold a reference to |this|.
- scoped_ptr<Clock> GetMockClock() const;
+ std::unique_ptr<Clock> GetMockClock() const;
// Returns a TickClock that uses the virtual time ticks of |this| as its tick
// source. The returned TickClock will hold a reference to |this|.
- scoped_ptr<TickClock> GetMockTickClock() const;
+ std::unique_ptr<TickClock> GetMockTickClock() const;
bool HasPendingTask() const;
size_t GetPendingTaskCount() const;
diff --git a/base/test/test_pending_task.cc b/base/test/test_pending_task.cc
index d912df4..87b107e 100644
--- a/base/test/test_pending_task.cc
+++ b/base/test/test_pending_task.cc
@@ -52,9 +52,9 @@
state->SetInteger("delay", delay.ToInternalValue());
}
-scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
TestPendingTask::AsValue() const {
- scoped_ptr<base::trace_event::TracedValue> state(
+ std::unique_ptr<base::trace_event::TracedValue> state(
new base::trace_event::TracedValue());
AsValueInto(state.get());
return std::move(state);
diff --git a/base/test/test_pending_task.h b/base/test/test_pending_task.h
index 3b29961..2dbdb7e 100644
--- a/base/test/test_pending_task.h
+++ b/base/test/test_pending_task.h
@@ -59,7 +59,7 @@
// Functions for using test pending task with tracing, useful in unit
// testing.
void AsValueInto(base::trace_event::TracedValue* state) const;
- scoped_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
std::string ToString() const;
};
diff --git a/base/test/test_pending_task_unittest.cc b/base/test/test_pending_task_unittest.cc
index 39a6a43..6e01c8c 100644
--- a/base/test/test_pending_task_unittest.cc
+++ b/base/test/test_pending_task_unittest.cc
@@ -19,7 +19,7 @@
TRACE_EVENT1("test", "TestPendingTask::TraceSupport", "task", task.AsValue());
// Just a basic check that the trace output has *something* in it.
- scoped_ptr<base::trace_event::ConvertableToTraceFormat> task_value(
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat> task_value(
task.AsValue());
EXPECT_THAT(task_value->ToString(), ::testing::HasSubstr("post_time"));
}
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 74bd9dd..7211ff5 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -4,6 +4,8 @@
#include "base/test/test_suite.h"
+#include <memory>
+
#include "base/at_exit.h"
#include "base/base_paths.h"
#include "base/base_switches.h"
@@ -17,7 +19,7 @@
#include "base/i18n/icu_util.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/memory.h"
@@ -226,7 +228,7 @@
// Set up a FeatureList instance, so that code using that API will not hit a
// an error that it's not set. Cleared by ClearInstanceForTesting() below.
- base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList));
+ base::FeatureList::SetInstance(WrapUnique(new base::FeatureList));
int result = RUN_ALL_TESTS();
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index 68590eb..deef72d 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -9,11 +9,11 @@
// instantiate this class in your main function and call its Run method to run
// any gtest based tests that are linked into your executable.
+#include <memory>
#include <string>
#include "base/at_exit.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/test/trace_to_file.h"
#include "build/build_config.h"
@@ -67,7 +67,7 @@
// Make sure that we setup an AtExitManager so Singleton objects will be
// destroyed.
- scoped_ptr<base::AtExitManager> at_exit_manager_;
+ std::unique_ptr<base::AtExitManager> at_exit_manager_;
private:
void InitializeFromCommandLine(int argc, char** argv);
diff --git a/base/test/test_support_android.cc b/base/test/test_support_android.cc
index a8cadec..08a2820 100644
--- a/base/test/test_support_android.cc
+++ b/base/test/test_support_android.cc
@@ -127,8 +127,8 @@
}
};
-scoped_ptr<base::MessagePump> CreateMessagePumpForUIStub() {
- return scoped_ptr<base::MessagePump>(new MessagePumpForUIStub());
+std::unique_ptr<base::MessagePump> CreateMessagePumpForUIStub() {
+ return std::unique_ptr<base::MessagePump>(new MessagePumpForUIStub());
};
// Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA.
diff --git a/base/test/trace_event_analyzer.cc b/base/test/trace_event_analyzer.cc
index 18bfe38..64436dc 100644
--- a/base/test/trace_event_analyzer.cc
+++ b/base/test/trace_event_analyzer.cc
@@ -7,10 +7,10 @@
#include <math.h>
#include <algorithm>
+#include <memory>
#include <set>
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/pattern.h"
#include "base/values.h"
@@ -144,7 +144,7 @@
}
bool TraceEvent::GetArgAsValue(const std::string& name,
- scoped_ptr<base::Value>* arg) const {
+ std::unique_ptr<base::Value>* arg) const {
const auto it = arg_values.find(name);
if (it != arg_values.end()) {
*arg = it->second->CreateDeepCopy();
@@ -193,9 +193,9 @@
return (arg_double != 0.0);
}
-scoped_ptr<base::Value> TraceEvent::GetKnownArgAsValue(
+std::unique_ptr<base::Value> TraceEvent::GetKnownArgAsValue(
const std::string& name) const {
- scoped_ptr<base::Value> arg_value;
+ std::unique_ptr<base::Value> arg_value;
bool result = GetArgAsValue(name, &arg_value);
DCHECK(result);
return arg_value;
@@ -679,7 +679,7 @@
bool ParseEventsFromJson(const std::string& json,
std::vector<TraceEvent>* output) {
- scoped_ptr<base::Value> root = base::JSONReader::Read(json);
+ std::unique_ptr<base::Value> root = base::JSONReader::Read(json);
base::ListValue* root_list = NULL;
if (!root.get() || !root->GetAsList(&root_list))
@@ -712,7 +712,7 @@
// static
TraceAnalyzer* TraceAnalyzer::Create(const std::string& json_events) {
- scoped_ptr<TraceAnalyzer> analyzer(new TraceAnalyzer());
+ std::unique_ptr<TraceAnalyzer> analyzer(new TraceAnalyzer());
if (analyzer->SetEvents(json_events))
return analyzer.release();
return NULL;
diff --git a/base/test/trace_event_analyzer.h b/base/test/trace_event_analyzer.h
index 8087ec5..0e2366b 100644
--- a/base/test/trace_event_analyzer.h
+++ b/base/test/trace_event_analyzer.h
@@ -135,7 +135,7 @@
bool GetArgAsNumber(const std::string& name, double* arg) const;
// Return the argument value if it exists.
bool GetArgAsValue(const std::string& name,
- scoped_ptr<base::Value>* arg) const;
+ std::unique_ptr<base::Value>* arg) const;
// Check if argument exists and is string.
bool HasStringArg(const std::string& name) const;
@@ -151,7 +151,8 @@
double GetKnownArgAsDouble(const std::string& name) const;
int GetKnownArgAsInt(const std::string& name) const;
bool GetKnownArgAsBool(const std::string& name) const;
- scoped_ptr<base::Value> GetKnownArgAsValue(const std::string& name) const;
+ std::unique_ptr<base::Value> GetKnownArgAsValue(
+ const std::string& name) const;
// Process ID and Thread ID.
ProcessThreadID thread;
@@ -169,7 +170,7 @@
// bool becomes 1.0 (true) or 0.0 (false).
std::map<std::string, double> arg_numbers;
std::map<std::string, std::string> arg_strings;
- std::map<std::string, scoped_ptr<base::Value>> arg_values;
+ std::map<std::string, std::unique_ptr<base::Value>> arg_values;
// The other event associated with this event (or NULL).
const TraceEvent* other_event;
diff --git a/base/test/trace_event_analyzer_unittest.cc b/base/test/trace_event_analyzer_unittest.cc
index b133cae..e73dd65 100644
--- a/base/test/trace_event_analyzer_unittest.cc
+++ b/base/test/trace_event_analyzer_unittest.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/test/trace_event_analyzer.h"
+
#include <stddef.h>
#include <stdint.h>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/synchronization/waitable_event.h"
-#include "base/test/trace_event_analyzer.h"
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_buffer.h"
#include "base/trace_event/trace_event_argument.h"
@@ -76,8 +78,8 @@
buffer_.Start();
buffer_.Finish();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
// Search for all events and verify that nothing is returned.
@@ -99,7 +101,7 @@
event.arg_numbers["int"] = static_cast<double>(int_num);
event.arg_numbers["double"] = double_num;
event.arg_strings["string"] = str;
- event.arg_values["dict"] = make_scoped_ptr(new base::DictionaryValue());
+ event.arg_values["dict"] = WrapUnique(new base::DictionaryValue());
ASSERT_TRUE(event.HasNumberArg("false"));
ASSERT_TRUE(event.HasNumberArg("true"));
@@ -117,7 +119,7 @@
EXPECT_EQ(double_num, event.GetKnownArgAsDouble("double"));
EXPECT_STREQ(str, event.GetKnownArgAsString("string").c_str());
- scoped_ptr<base::Value> arg;
+ std::unique_ptr<base::Value> arg;
EXPECT_TRUE(event.GetArgAsValue("dict", &arg));
EXPECT_EQ(base::Value::TYPE_DICTIONARY, arg->GetType());
}
@@ -235,8 +237,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer);
analyzer->SetIgnoreMetadataEvents(true);
@@ -326,8 +328,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
TraceEventVector found;
@@ -381,8 +383,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->SetIgnoreMetadataEvents(true);
@@ -431,8 +433,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateBeginEndEvents();
@@ -473,8 +475,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateBeginEndEvents();
@@ -505,8 +507,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateBeginEndEvents();
@@ -528,8 +530,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateBeginEndEvents();
@@ -561,8 +563,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateAsyncBeginEndEvents();
@@ -593,8 +595,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
analyzer->AssociateAsyncBeginEndEvents();
@@ -646,8 +648,8 @@
}
EndTracing();
- scoped_ptr<TraceAnalyzer>
- analyzer(TraceAnalyzer::Create(output_.json_output));
+ std::unique_ptr<TraceAnalyzer> analyzer(
+ TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
// begin, end, and match queries to find proper begin/end pairs.
@@ -920,14 +922,14 @@
BeginTracing();
{
- scoped_ptr<base::trace_event::TracedValue> value(
+ std::unique_ptr<base::trace_event::TracedValue> value(
new base::trace_event::TracedValue);
value->SetString("property", "value");
TRACE_EVENT1("cat", "name", "arg", std::move(value));
}
EndTracing();
- scoped_ptr<TraceAnalyzer> analyzer(
+ std::unique_ptr<TraceAnalyzer> analyzer(
TraceAnalyzer::Create(output_.json_output));
ASSERT_TRUE(analyzer.get());
@@ -939,7 +941,7 @@
EXPECT_EQ("name", events[0]->name);
EXPECT_TRUE(events[0]->HasArg("arg"));
- scoped_ptr<base::Value> arg;
+ std::unique_ptr<base::Value> arg;
events[0]->GetArgAsValue("arg", &arg);
base::DictionaryValue* arg_dict;
EXPECT_TRUE(arg->GetAsDictionary(&arg_dict));
diff --git a/base/test/values_test_util.cc b/base/test/values_test_util.cc
index f974c14..6c1ee7d 100644
--- a/base/test/values_test_util.cc
+++ b/base/test/values_test_util.cc
@@ -4,8 +4,9 @@
#include "base/test/values_test_util.h"
+#include <memory>
+
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -54,7 +55,7 @@
void ExpectStringValue(const std::string& expected_str,
StringValue* actual) {
- scoped_ptr<StringValue> scoped_actual(actual);
+ std::unique_ptr<StringValue> scoped_actual(actual);
std::string actual_str;
EXPECT_TRUE(scoped_actual->GetAsString(&actual_str));
EXPECT_EQ(expected_str, actual_str);
@@ -62,9 +63,9 @@
namespace test {
-scoped_ptr<Value> ParseJson(base::StringPiece json) {
+std::unique_ptr<Value> ParseJson(base::StringPiece json) {
std::string error_msg;
- scoped_ptr<Value> result = base::JSONReader::ReadAndReturnError(
+ std::unique_ptr<Value> result = base::JSONReader::ReadAndReturnError(
json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg);
if (!result) {
ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg;
diff --git a/base/test/values_test_util.h b/base/test/values_test_util.h
index 86d91c3..886c17d 100644
--- a/base/test/values_test_util.h
+++ b/base/test/values_test_util.h
@@ -5,9 +5,9 @@
#ifndef BASE_TEST_VALUES_TEST_UTIL_H_
#define BASE_TEST_VALUES_TEST_UTIL_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
namespace base {
@@ -48,7 +48,7 @@
// Parses |json| as JSON, allowing trailing commas, and returns the
// resulting value. If the json fails to parse, causes an EXPECT
// failure and returns the Null Value (but never a NULL pointer).
-scoped_ptr<Value> ParseJson(base::StringPiece json);
+std::unique_ptr<Value> ParseJson(base::StringPiece json);
} // namespace test
} // namespace base
diff --git a/base/threading/non_thread_safe_unittest.cc b/base/threading/non_thread_safe_unittest.cc
index 2a27c3f..d523fc5 100644
--- a/base/threading/non_thread_safe_unittest.cc
+++ b/base/threading/non_thread_safe_unittest.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/threading/non_thread_safe.h"
+
+#include <memory>
+
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/threading/non_thread_safe.h"
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -72,7 +74,7 @@
void Run() override { non_thread_safe_class_.reset(); }
private:
- scoped_ptr<NonThreadSafeClass> non_thread_safe_class_;
+ std::unique_ptr<NonThreadSafeClass> non_thread_safe_class_;
DISALLOW_COPY_AND_ASSIGN(DeleteNonThreadSafeClassOnThread);
};
@@ -80,7 +82,7 @@
} // namespace
TEST(NonThreadSafeTest, CallsAllowedOnSameThread) {
- scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
+ std::unique_ptr<NonThreadSafeClass> non_thread_safe_class(
new NonThreadSafeClass);
// Verify that DoStuff doesn't assert.
@@ -91,7 +93,7 @@
}
TEST(NonThreadSafeTest, DetachThenDestructOnDifferentThread) {
- scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
+ std::unique_ptr<NonThreadSafeClass> non_thread_safe_class(
new NonThreadSafeClass);
// Verify that the destructor doesn't assert when called on a different thread
@@ -107,7 +109,7 @@
#if GTEST_HAS_DEATH_TEST || !ENABLE_NON_THREAD_SAFE
void NonThreadSafeClass::MethodOnDifferentThreadImpl() {
- scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
+ std::unique_ptr<NonThreadSafeClass> non_thread_safe_class(
new NonThreadSafeClass);
// Verify that DoStuff asserts in debug builds only when called
@@ -131,7 +133,7 @@
#endif // ENABLE_NON_THREAD_SAFE
void NonThreadSafeClass::DestructorOnDifferentThreadImpl() {
- scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
+ std::unique_ptr<NonThreadSafeClass> non_thread_safe_class(
new NonThreadSafeClass);
// Verify that the destructor asserts in debug builds only
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index bd6ae2d..d8bcf92 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -12,9 +12,10 @@
#include <sys/resource.h>
#include <sys/time.h>
+#include <memory>
+
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/platform_thread_internal_posix.h"
#include "base/threading/thread_id_name_manager.h"
#include "base/threading/thread_restrictions.h"
@@ -47,7 +48,8 @@
PlatformThread::Delegate* delegate = nullptr;
{
- scoped_ptr<ThreadParams> thread_params(static_cast<ThreadParams*>(params));
+ std::unique_ptr<ThreadParams> thread_params(
+ static_cast<ThreadParams*>(params));
delegate = thread_params->delegate;
if (!thread_params->joinable)
@@ -98,7 +100,7 @@
if (stack_size > 0)
pthread_attr_setstacksize(&attributes, stack_size);
- scoped_ptr<ThreadParams> params(new ThreadParams);
+ std::unique_ptr<ThreadParams> params(new ThreadParams);
params->delegate = delegate;
params->joinable = joinable;
params->priority = priority;
diff --git a/base/threading/sequenced_task_runner_handle_unittest.cc b/base/threading/sequenced_task_runner_handle_unittest.cc
index 1e624f4..ad7d70c 100644
--- a/base/threading/sequenced_task_runner_handle_unittest.cc
+++ b/base/threading/sequenced_task_runner_handle_unittest.cc
@@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/threading/sequenced_task_runner_handle.h"
+
+#include <memory>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/sequence_checker_impl.h"
#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/sequenced_worker_pool_owner.h"
-#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -30,7 +32,8 @@
ASSERT_TRUE(task_runner);
// Use SequenceCheckerImpl to make sure it's not a no-op in Release builds.
- scoped_ptr<SequenceCheckerImpl> sequence_checker(new SequenceCheckerImpl);
+ std::unique_ptr<SequenceCheckerImpl> sequence_checker(
+ new SequenceCheckerImpl);
task_runner->PostTask(
FROM_HERE,
base::Bind(&SequencedTaskRunnerHandleTest::CheckValidSequence,
@@ -39,7 +42,7 @@
private:
static void CheckValidSequence(
- scoped_ptr<SequenceCheckerImpl> sequence_checker,
+ std::unique_ptr<SequenceCheckerImpl> sequence_checker,
const Closure& callback) {
EXPECT_TRUE(sequence_checker->CalledOnValidSequencedThread());
callback.Run();
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 086f54b..24a0751 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -8,6 +8,7 @@
#include <list>
#include <map>
+#include <memory>
#include <set>
#include <utility>
#include <vector>
@@ -19,7 +20,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/condition_variable.h"
@@ -445,7 +446,7 @@
// Owning pointers to all threads we've created so far, indexed by
// ID. Since we lazily create threads, this may be less than
// max_threads_ and will be initially empty.
- using ThreadMap = std::map<PlatformThreadId, scoped_ptr<Worker>>;
+ using ThreadMap = std::map<PlatformThreadId, std::unique_ptr<Worker>>;
ThreadMap threads_;
// Set to true when we're in the process of creating another thread.
@@ -786,7 +787,7 @@
DCHECK(thread_being_created_);
thread_being_created_ = false;
auto result = threads_.insert(
- std::make_pair(this_worker->tid(), make_scoped_ptr(this_worker)));
+ std::make_pair(this_worker->tid(), WrapUnique(this_worker)));
DCHECK(result.second);
while (true) {
diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h
index ba0e444..cbec395 100644
--- a/base/threading/sequenced_worker_pool.h
+++ b/base/threading/sequenced_worker_pool.h
@@ -8,13 +8,13 @@
#include <stddef.h>
#include <cstddef>
+#include <memory>
#include <string>
#include "base/base_export.h"
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner.h"
@@ -374,7 +374,7 @@
// Avoid pulling in too many headers by putting (almost) everything
// into |inner_|.
- const scoped_ptr<Inner> inner_;
+ const std::unique_ptr<Inner> inner_;
DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool);
};
diff --git a/base/threading/sequenced_worker_pool_unittest.cc b/base/threading/sequenced_worker_pool_unittest.cc
index a0be607..58dc317 100644
--- a/base/threading/sequenced_worker_pool_unittest.cc
+++ b/base/threading/sequenced_worker_pool_unittest.cc
@@ -7,12 +7,12 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/sequence_checker_impl.h"
#include "base/stl_util.h"
@@ -294,7 +294,7 @@
private:
MessageLoop message_loop_;
- scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
const scoped_refptr<TestTracker> tracker_;
};
@@ -1067,7 +1067,7 @@
private:
MessageLoop message_loop_;
- scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
};
INSTANTIATE_TYPED_TEST_CASE_P(
@@ -1105,7 +1105,7 @@
private:
MessageLoop message_loop_;
- scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
scoped_refptr<TaskRunner> task_runner_;
};
@@ -1145,7 +1145,7 @@
private:
MessageLoop message_loop_;
- scoped_ptr<SequencedWorkerPoolOwner> pool_owner_;
+ std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
scoped_refptr<SequencedTaskRunner> task_runner_;
};
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index 1d2ae64..5863130 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -104,8 +104,8 @@
type = MessageLoop::TYPE_CUSTOM;
message_loop_timer_slack_ = options.timer_slack;
- scoped_ptr<MessageLoop> message_loop = MessageLoop::CreateUnbound(
- type, options.message_pump_factory);
+ std::unique_ptr<MessageLoop> message_loop =
+ MessageLoop::CreateUnbound(type, options.message_pump_factory);
message_loop_ = message_loop.get();
start_event_.Reset();
@@ -227,13 +227,13 @@
// Lazily initialize the message_loop so that it can run on this thread.
DCHECK(message_loop_);
- scoped_ptr<MessageLoop> message_loop(message_loop_);
+ std::unique_ptr<MessageLoop> message_loop(message_loop_);
message_loop_->BindToCurrentThread();
message_loop_->set_thread_name(name_);
message_loop_->SetTimerSlack(message_loop_timer_slack_);
#if defined(OS_WIN)
- scoped_ptr<win::ScopedCOMInitializer> com_initializer;
+ std::unique_ptr<win::ScopedCOMInitializer> com_initializer;
if (com_status_ != NONE) {
com_initializer.reset((com_status_ == STA) ?
new win::ScopedCOMInitializer() :
diff --git a/base/threading/thread.h b/base/threading/thread.h
index ec19722..c9a77d7 100644
--- a/base/threading/thread.h
+++ b/base/threading/thread.h
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include "base/base_export.h"
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/timer_slack.h"
#include "base/single_thread_task_runner.h"
@@ -41,7 +41,7 @@
class BASE_EXPORT Thread : PlatformThread::Delegate {
public:
struct BASE_EXPORT Options {
- typedef Callback<scoped_ptr<MessagePump>()> MessagePumpFactory;
+ typedef Callback<std::unique_ptr<MessagePump>()> MessagePumpFactory;
Options();
Options(MessageLoop::Type type, size_t size);
diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc
index fd98f76..bc5b1e4 100644
--- a/base/threading/thread_checker_unittest.cc
+++ b/base/threading/thread_checker_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/threading/thread_checker.h"
+
+#include <memory>
+
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/simple_thread.h"
-#include "base/threading/thread_checker.h"
#include "testing/gtest/include/gtest/gtest.h"
// Duplicated from base/threading/thread_checker.h so that we can be
@@ -72,7 +74,7 @@
void Run() override { thread_checker_class_.reset(); }
private:
- scoped_ptr<ThreadCheckerClass> thread_checker_class_;
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class_;
DISALLOW_COPY_AND_ASSIGN(DeleteThreadCheckerClassOnThread);
};
@@ -80,7 +82,7 @@
} // namespace
TEST(ThreadCheckerTest, CallsAllowedOnSameThread) {
- scoped_ptr<ThreadCheckerClass> thread_checker_class(
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass);
// Verify that DoStuff doesn't assert.
@@ -91,7 +93,7 @@
}
TEST(ThreadCheckerTest, DestructorAllowedOnDifferentThread) {
- scoped_ptr<ThreadCheckerClass> thread_checker_class(
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass);
// Verify that the destructor doesn't assert
@@ -104,7 +106,7 @@
}
TEST(ThreadCheckerTest, DetachFromThread) {
- scoped_ptr<ThreadCheckerClass> thread_checker_class(
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass);
// Verify that DoStuff doesn't assert when called on a different thread after
@@ -119,7 +121,7 @@
#if GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER
void ThreadCheckerClass::MethodOnDifferentThreadImpl() {
- scoped_ptr<ThreadCheckerClass> thread_checker_class(
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass);
// DoStuff should assert in debug builds only when called on a
@@ -143,7 +145,7 @@
#endif // ENABLE_THREAD_CHECKER
void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() {
- scoped_ptr<ThreadCheckerClass> thread_checker_class(
+ std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass);
// DoStuff doesn't assert when called on a different thread
diff --git a/base/threading/thread_collision_warner_unittest.cc b/base/threading/thread_collision_warner_unittest.cc
index 79ca7e2..71447ef 100644
--- a/base/threading/thread_collision_warner_unittest.cc
+++ b/base/threading/thread_collision_warner_unittest.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/threading/thread_collision_warner.h"
+
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
-#include "base/threading/thread_collision_warner.h"
#include "testing/gtest/include/gtest/gtest.h"
// '' : local class member function does not have a body
@@ -19,7 +21,7 @@
// Would cause a memory leak otherwise.
#undef DFAKE_MUTEX
-#define DFAKE_MUTEX(obj) scoped_ptr<base::AsserterBase> obj
+#define DFAKE_MUTEX(obj) std::unique_ptr<base::AsserterBase> obj
// In Release, we expect the AsserterBase::warn() to not happen.
#define EXPECT_NDEBUG_FALSE_DEBUG_TRUE EXPECT_FALSE
diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h
index f8971ac..628e2b6 100644
--- a/base/threading/worker_pool_posix.h
+++ b/base/threading/worker_pool_posix.h
@@ -24,6 +24,7 @@
#ifndef BASE_THREADING_WORKER_POOL_POSIX_H_
#define BASE_THREADING_WORKER_POOL_POSIX_H_
+#include <memory>
#include <queue>
#include <string>
@@ -31,7 +32,6 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/pending_task.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
@@ -88,7 +88,7 @@
bool terminated_;
// Only used for tests to ensure correct thread ordering. It will always be
// NULL in non-test code.
- scoped_ptr<ConditionVariable> num_idle_threads_cv_;
+ std::unique_ptr<ConditionVariable> num_idle_threads_cv_;
DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool);
};
diff --git a/base/timer/hi_res_timer_manager_unittest.cc b/base/timer/hi_res_timer_manager_unittest.cc
index 9416048..a0b0f93 100644
--- a/base/timer/hi_res_timer_manager_unittest.cc
+++ b/base/timer/hi_res_timer_manager_unittest.cc
@@ -4,9 +4,9 @@
#include "base/timer/hi_res_timer_manager.h"
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
@@ -22,9 +22,9 @@
// Windows, which makes this test flaky if you run while the machine
// goes in or out of AC power.
base::MessageLoop loop(base::MessageLoop::TYPE_UI);
- scoped_ptr<base::PowerMonitorSource> power_monitor_source(
+ std::unique_ptr<base::PowerMonitorSource> power_monitor_source(
new base::PowerMonitorDeviceSource());
- scoped_ptr<base::PowerMonitor> power_monitor(
+ std::unique_ptr<base::PowerMonitor> power_monitor(
new base::PowerMonitor(std::move(power_monitor_source)));
HighResolutionTimerManager manager;
diff --git a/base/timer/timer_unittest.cc b/base/timer/timer_unittest.cc
index b1d3c3e..e56efac 100644
--- a/base/timer/timer_unittest.cc
+++ b/base/timer/timer_unittest.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/timer/timer.h"
+
#include <stddef.h>
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/test/test_simple_task_runner.h"
-#include "base/timer/timer.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -78,7 +80,7 @@
}
bool* did_run_;
- scoped_ptr<base::OneShotTimer> timer_;
+ std::unique_ptr<base::OneShotTimer> timer_;
};
class RepeatingTimerTester {
diff --git a/base/trace_event/blame_context.cc b/base/trace_event/blame_context.cc
index 0bf7896..27d2d2e 100644
--- a/base/trace_event/blame_context.cc
+++ b/base/trace_event/blame_context.cc
@@ -57,12 +57,13 @@
DCHECK(WasInitialized());
if (!*category_group_enabled_)
return;
- scoped_ptr<trace_event::TracedValue> snapshot(new trace_event::TracedValue);
+ std::unique_ptr<trace_event::TracedValue> snapshot(
+ new trace_event::TracedValue);
AsValueInto(snapshot.get());
static const char* kArgName = "snapshot";
const int kNumArgs = 1;
unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE};
- scoped_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = {
+ std::unique_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = {
std::move(snapshot)};
TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT,
category_group_enabled_, type_, scope_, id_,
diff --git a/base/trace_event/blame_context_unittest.cc b/base/trace_event/blame_context_unittest.cc
index 7217d8f..3ecf3e3 100644
--- a/base/trace_event/blame_context_unittest.cc
+++ b/base/trace_event/blame_context_unittest.cc
@@ -5,6 +5,7 @@
#include "base/trace_event/blame_context.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/run_loop.h"
#include "base/test/trace_event_analyzer.h"
@@ -71,7 +72,7 @@
public:
void StartTracing();
void StopTracing();
- scoped_ptr<trace_analyzer::TraceAnalyzer> CreateTraceAnalyzer();
+ std::unique_ptr<trace_analyzer::TraceAnalyzer> CreateTraceAnalyzer();
};
void BlameContextTest::StartTracing() {
@@ -83,7 +84,7 @@
trace_event::TraceLog::GetInstance()->SetDisabled();
}
-scoped_ptr<trace_analyzer::TraceAnalyzer>
+std::unique_ptr<trace_analyzer::TraceAnalyzer>
BlameContextTest::CreateTraceAnalyzer() {
trace_event::TraceResultBuffer buffer;
trace_event::TraceResultBuffer::SimpleOutput trace_output;
@@ -95,7 +96,7 @@
run_loop.Run();
buffer.Finish();
- return make_scoped_ptr(
+ return WrapUnique(
trace_analyzer::TraceAnalyzer::Create(trace_output.json_output));
}
@@ -109,7 +110,8 @@
blame_context.Leave();
}
StopTracing();
- scoped_ptr<trace_analyzer::TraceAnalyzer> analyzer = CreateTraceAnalyzer();
+ std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer =
+ CreateTraceAnalyzer();
trace_analyzer::TraceEventVector events;
Query q = Query::EventPhaseIs(TRACE_EVENT_PHASE_ENTER_CONTEXT) ||
@@ -143,7 +145,8 @@
disabled_blame_context.Leave();
}
StopTracing();
- scoped_ptr<trace_analyzer::TraceAnalyzer> analyzer = CreateTraceAnalyzer();
+ std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer =
+ CreateTraceAnalyzer();
trace_analyzer::TraceEventVector events;
Query q = Query::EventPhaseIs(TRACE_EVENT_PHASE_ENTER_CONTEXT) ||
@@ -173,7 +176,8 @@
blame_context.TakeSnapshot();
}
StopTracing();
- scoped_ptr<trace_analyzer::TraceAnalyzer> analyzer = CreateTraceAnalyzer();
+ std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer =
+ CreateTraceAnalyzer();
trace_analyzer::TraceEventVector events;
Query q = Query::EventPhaseIs(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT);
diff --git a/base/trace_event/common/trace_event_common.h b/base/trace_event/common/trace_event_common.h
index 0b549d4..7a1533e 100644
--- a/base/trace_event/common/trace_event_common.h
+++ b/base/trace_event/common/trace_event_common.h
@@ -156,7 +156,7 @@
// };
//
// TRACE_EVENT1("foo", "bar", "data",
-// scoped_ptr<ConvertableToTraceFormat>(new MyData()));
+// std::unique_ptr<ConvertableToTraceFormat>(new MyData()));
//
// The trace framework will take ownership if the passed pointer and it will
// be free'd when the trace buffer is flushed.
diff --git a/base/trace_event/heap_profiler_heap_dump_writer.cc b/base/trace_event/heap_profiler_heap_dump_writer.cc
index b94c312..fe99e48 100644
--- a/base/trace_event/heap_profiler_heap_dump_writer.cc
+++ b/base/trace_event/heap_profiler_heap_dump_writer.cc
@@ -248,9 +248,9 @@
return entries_;
}
-scoped_ptr<TracedValue> Serialize(const std::set<Entry>& entries) {
+std::unique_ptr<TracedValue> Serialize(const std::set<Entry>& entries) {
std::string buffer;
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
traced_value->BeginArray("entries");
@@ -289,7 +289,7 @@
} // namespace internal
-scoped_ptr<TracedValue> ExportHeapDump(
+std::unique_ptr<TracedValue> ExportHeapDump(
const hash_map<AllocationContext, size_t>& bytes_by_size,
StackFrameDeduplicator* stack_frame_deduplicator,
TypeNameDeduplicator* type_name_deduplicator) {
diff --git a/base/trace_event/heap_profiler_heap_dump_writer.h b/base/trace_event/heap_profiler_heap_dump_writer.h
index e6cf93b..fa24b2b 100644
--- a/base/trace_event/heap_profiler_heap_dump_writer.h
+++ b/base/trace_event/heap_profiler_heap_dump_writer.h
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <set>
#include "base/base_export.h"
#include "base/containers/hash_tables.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
namespace base {
@@ -26,7 +26,7 @@
// a traced value with an "entries" array that can be dumped in the trace log,
// following the format described in https://goo.gl/KY7zVE. The number of
// entries is kept reasonable because long tails are not included.
-BASE_EXPORT scoped_ptr<TracedValue> ExportHeapDump(
+BASE_EXPORT std::unique_ptr<TracedValue> ExportHeapDump(
const hash_map<AllocationContext, size_t>& bytes_by_context,
StackFrameDeduplicator* stack_frame_deduplicator,
TypeNameDeduplicator* type_name_deduplicator);
@@ -54,7 +54,7 @@
BASE_EXPORT bool operator<(Entry lhs, Entry rhs);
// Serializes entries to an "entries" array in a traced value.
-BASE_EXPORT scoped_ptr<TracedValue> Serialize(const std::set<Entry>& dump);
+BASE_EXPORT std::unique_ptr<TracedValue> Serialize(const std::set<Entry>& dump);
// Helper class to dump a snapshot of an |AllocationRegister| or other heap
// bookkeeping structure into a |TracedValue|. This class is intended to be
diff --git a/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc b/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
index fefd346..894de69 100644
--- a/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
+++ b/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/trace_event/heap_profiler_heap_dump_writer.h"
+
#include <stddef.h>
+#include <memory>
#include <set>
#include <string>
#include "base/json/json_reader.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
-#include "base/trace_event/heap_profiler_heap_dump_writer.h"
#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
#include "base/trace_event/heap_profiler_type_name_deduplicator.h"
#include "base/trace_event/trace_event_argument.h"
@@ -38,18 +40,18 @@
namespace trace_event {
namespace internal {
-scoped_ptr<const Value> WriteAndReadBack(const std::set<Entry>& entries) {
- scoped_ptr<TracedValue> traced_value = Serialize(entries);
+std::unique_ptr<const Value> WriteAndReadBack(const std::set<Entry>& entries) {
+ std::unique_ptr<TracedValue> traced_value = Serialize(entries);
std::string json;
traced_value->AppendAsTraceFormat(&json);
return JSONReader::Read(json);
}
-scoped_ptr<const DictionaryValue> WriteAndReadBackEntry(Entry entry) {
+std::unique_ptr<const DictionaryValue> WriteAndReadBackEntry(Entry entry) {
std::set<Entry> input_entries;
input_entries.insert(entry);
- scoped_ptr<const Value> json_dict = WriteAndReadBack(input_entries);
+ std::unique_ptr<const Value> json_dict = WriteAndReadBack(input_entries);
// Note: Ideally these should use |ASSERT_TRUE| instead of |EXPECT_TRUE|, but
// |ASSERT_TRUE| can only be used in void functions.
@@ -106,7 +108,8 @@
entry.type_id = 0;
entry.size = 1;
- scoped_ptr<const DictionaryValue> json_entry = WriteAndReadBackEntry(entry);
+ std::unique_ptr<const DictionaryValue> json_entry =
+ WriteAndReadBackEntry(entry);
// For an empty backtrace, the "bt" key cannot reference a stack frame.
// Instead it should be set to the empty string.
@@ -127,7 +130,8 @@
entry.stack_frame_id = 0;
entry.size = 1;
- scoped_ptr<const DictionaryValue> json_entry = WriteAndReadBackEntry(entry);
+ std::unique_ptr<const DictionaryValue> json_entry =
+ WriteAndReadBackEntry(entry);
// Entries for the cumulative size of all types should not have the "type"
// key set.
@@ -153,7 +157,8 @@
entry.stack_frame_id = 0;
entry.size = large_value;
- scoped_ptr<const DictionaryValue> json_entry = WriteAndReadBackEntry(entry);
+ std::unique_ptr<const DictionaryValue> json_entry =
+ WriteAndReadBackEntry(entry);
std::string size;
ASSERT_TRUE(json_entry->GetString("size", &size));
@@ -197,8 +202,8 @@
// +--------+--------------------+-----------------+-----+
// | Sum | 28 | 49 | 77 |
- auto sf_deduplicator = make_scoped_ptr(new StackFrameDeduplicator);
- auto tn_deduplicator = make_scoped_ptr(new TypeNameDeduplicator);
+ auto sf_deduplicator = WrapUnique(new StackFrameDeduplicator);
+ auto tn_deduplicator = WrapUnique(new TypeNameDeduplicator);
HeapDumpWriter writer(sf_deduplicator.get(), tn_deduplicator.get());
const std::set<Entry>& dump = writer.Summarize(bytes_by_context);
@@ -262,8 +267,8 @@
ctx.backtrace.frames[2] = kInitialize;
bytes_by_context[ctx] = 512;
- auto sf_deduplicator = make_scoped_ptr(new StackFrameDeduplicator);
- auto tn_deduplicator = make_scoped_ptr(new TypeNameDeduplicator);
+ auto sf_deduplicator = WrapUnique(new StackFrameDeduplicator);
+ auto tn_deduplicator = WrapUnique(new TypeNameDeduplicator);
HeapDumpWriter writer(sf_deduplicator.get(), tn_deduplicator.get());
const std::set<Entry>& dump = writer.Summarize(bytes_by_context);
diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
index 9568525..1212193 100644
--- a/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
+++ b/base/trace_event/heap_profiler_stack_frame_deduplicator.cc
@@ -77,7 +77,7 @@
SStringPrintf(&stringify_buffer, "\"%d\":", i);
out->append(stringify_buffer);
- scoped_ptr<TracedValue> frame_node_value(new TracedValue);
+ std::unique_ptr<TracedValue> frame_node_value(new TracedValue);
frame_node_value->SetString("name", frame_node->frame);
if (frame_node->parent_frame_index >= 0) {
SStringPrintf(&stringify_buffer, "%d", frame_node->parent_frame_index);
diff --git a/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc b/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc
index 2464036..72cb743 100644
--- a/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc
+++ b/base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
+
#include <iterator>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
-#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -30,7 +31,7 @@
// CreateWidget [1]
// malloc [2]
- scoped_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
+ std::unique_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
ASSERT_EQ(2, dedup->Insert(std::begin(bt), std::end(bt)));
auto iter = dedup->begin();
@@ -63,7 +64,7 @@
// Note that there will be two instances of CreateWidget,
// with different parents.
- scoped_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
+ std::unique_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
ASSERT_EQ(1, dedup->Insert(std::begin(bt0), std::end(bt0)));
ASSERT_EQ(3, dedup->Insert(std::begin(bt1), std::end(bt1)));
@@ -95,7 +96,7 @@
//
// Note that BrowserMain will be re-used.
- scoped_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
+ std::unique_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
ASSERT_EQ(1, dedup->Insert(std::begin(bt0), std::end(bt0)));
ASSERT_EQ(2, dedup->Insert(std::begin(bt1), std::end(bt1)));
@@ -121,7 +122,7 @@
TEST(StackFrameDeduplicatorTest, NullPaddingIsRemoved) {
StackFrame bt0[] = {kBrowserMain, nullptr, nullptr, nullptr};
- scoped_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
+ std::unique_ptr<StackFrameDeduplicator> dedup(new StackFrameDeduplicator);
// There are four frames in the backtrace, but the null pointers should be
// skipped, so only one frame is inserted, which will have index 0.
diff --git a/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc b/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
index 8ab3f37..b2e681a 100644
--- a/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
+++ b/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <string>
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/heap_profiler_type_name_deduplicator.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -30,7 +30,8 @@
const char kTaskPath[] = "base\\memory";
#endif
-scoped_ptr<Value> DumpAndReadBack(const TypeNameDeduplicator& deduplicator) {
+std::unique_ptr<Value> DumpAndReadBack(
+ const TypeNameDeduplicator& deduplicator) {
std::string json;
deduplicator.AppendAsTraceFormat(&json);
return JSONReader::Read(json);
@@ -41,10 +42,10 @@
// the same as |expected_value|.
void TestInsertTypeAndReadback(const char* type_name,
const char* expected_value) {
- scoped_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
+ std::unique_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
ASSERT_EQ(1, dedup->Insert(type_name));
- scoped_ptr<Value> type_names = DumpAndReadBack(*dedup);
+ std::unique_ptr<Value> type_names = DumpAndReadBack(*dedup);
ASSERT_NE(nullptr, type_names);
const DictionaryValue* dictionary;
@@ -66,7 +67,7 @@
// 2: bool
// 3: string
- scoped_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
+ std::unique_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
ASSERT_EQ(1, dedup->Insert(kInt));
ASSERT_EQ(2, dedup->Insert(kBool));
ASSERT_EQ(3, dedup->Insert(kString));
diff --git a/base/trace_event/java_heap_dump_provider_android_unittest.cc b/base/trace_event/java_heap_dump_provider_android_unittest.cc
index 35f3f17..6b31bd6 100644
--- a/base/trace_event/java_heap_dump_provider_android_unittest.cc
+++ b/base/trace_event/java_heap_dump_provider_android_unittest.cc
@@ -12,7 +12,7 @@
TEST(JavaHeapDumpProviderTest, JavaHeapDump) {
auto jhdp = JavaHeapDumpProvider::GetInstance();
- scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
jhdp->OnMemoryDump(dump_args, pmd.get());
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index d8f82ed..17e5c1e 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -191,7 +191,7 @@
} // lock(allocation_register_lock_)
if (!bytes_by_context.empty()) {
- scoped_ptr<TracedValue> heap_dump = ExportHeapDump(
+ std::unique_ptr<TracedValue> heap_dump = ExportHeapDump(
bytes_by_context, pmd->session_state()->stack_frame_deduplicator(),
pmd->session_state()->type_name_deduplicator());
pmd->AddHeapDump("malloc", std::move(heap_dump));
diff --git a/base/trace_event/malloc_dump_provider.h b/base/trace_event/malloc_dump_provider.h
index d9d7021..4746cf5 100644
--- a/base/trace_event/malloc_dump_provider.h
+++ b/base/trace_event/malloc_dump_provider.h
@@ -6,9 +6,9 @@
#define BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
#include <istream>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
@@ -52,7 +52,7 @@
// For heap profiling.
bool heap_profiler_enabled_;
- scoped_ptr<AllocationRegister> allocation_register_;
+ std::unique_ptr<AllocationRegister> allocation_register_;
Lock allocation_register_lock_;
// When in OnMemoryDump(), this contains the current thread ID.
diff --git a/base/trace_event/memory_allocator_dump.h b/base/trace_event/memory_allocator_dump.h
index 9f91de9..7d10236 100644
--- a/base/trace_event/memory_allocator_dump.h
+++ b/base/trace_event/memory_allocator_dump.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/base_export.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/memory_allocator_dump_guid.h"
#include "base/values.h"
@@ -93,7 +93,7 @@
private:
const std::string absolute_name_;
ProcessMemoryDump* const process_memory_dump_; // Not owned (PMD owns this).
- scoped_ptr<TracedValue> attributes_;
+ std::unique_ptr<TracedValue> attributes_;
MemoryAllocatorDumpGuid guid_;
int flags_; // See enum Flags.
diff --git a/base/trace_event/memory_allocator_dump_unittest.cc b/base/trace_event/memory_allocator_dump_unittest.cc
index 649991b..359f081 100644
--- a/base/trace_event/memory_allocator_dump_unittest.cc
+++ b/base/trace_event/memory_allocator_dump_unittest.cc
@@ -52,11 +52,12 @@
}
};
-scoped_ptr<Value> CheckAttribute(const MemoryAllocatorDump* dump,
- const std::string& name,
- const char* expected_type,
- const char* expected_units) {
- scoped_ptr<Value> raw_attrs = dump->attributes_for_testing()->ToBaseValue();
+std::unique_ptr<Value> CheckAttribute(const MemoryAllocatorDump* dump,
+ const std::string& name,
+ const char* expected_type,
+ const char* expected_units) {
+ std::unique_ptr<Value> raw_attrs =
+ dump->attributes_for_testing()->ToBaseValue();
DictionaryValue* args = nullptr;
DictionaryValue* arg = nullptr;
std::string arg_value;
@@ -68,7 +69,7 @@
EXPECT_TRUE(arg->GetString("units", &arg_value));
EXPECT_EQ(expected_units, arg_value);
EXPECT_TRUE(arg->Get("value", &out_value));
- return out_value ? out_value->CreateDeepCopy() : scoped_ptr<Value>();
+ return out_value ? out_value->CreateDeepCopy() : std::unique_ptr<Value>();
}
void CheckString(const MemoryAllocatorDump* dump,
@@ -104,7 +105,7 @@
} // namespace
TEST(MemoryAllocatorDumpTest, GuidGeneration) {
- scoped_ptr<MemoryAllocatorDump> mad(
+ std::unique_ptr<MemoryAllocatorDump> mad(
new MemoryAllocatorDump("foo", nullptr, MemoryAllocatorDumpGuid(0x42u)));
ASSERT_EQ("42", mad->guid().ToString());
@@ -167,7 +168,7 @@
ASSERT_FALSE(attrs->HasKey(MemoryAllocatorDump::kNameObjectCount));
// Check that the AsValueInfo doesn't hit any DCHECK.
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
pmd.AsValueInto(traced_value.get());
}
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index 56cc902..35b27d9 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -11,6 +11,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/memory/ptr_util.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
@@ -81,7 +82,7 @@
// Proxy class which wraps a ConvertableToTraceFormat owned by the
// |session_state| into a proxy object that can be added to the trace event log.
// This is to solve the problem that the MemoryDumpSessionState is refcounted
-// but the tracing subsystem wants a scoped_ptr<ConvertableToTraceFormat>.
+// but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>.
template <typename T>
struct SessionStateConvertableProxy : public ConvertableToTraceFormat {
using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const;
@@ -267,14 +268,14 @@
}
void MemoryDumpManager::UnregisterAndDeleteDumpProviderSoon(
- scoped_ptr<MemoryDumpProvider> mdp) {
+ std::unique_ptr<MemoryDumpProvider> mdp) {
UnregisterDumpProviderInternal(mdp.release(), true /* delete_async */);
}
void MemoryDumpManager::UnregisterDumpProviderInternal(
MemoryDumpProvider* mdp,
bool take_mdp_ownership_and_delete_async) {
- scoped_ptr<MemoryDumpProvider> owned_mdp;
+ std::unique_ptr<MemoryDumpProvider> owned_mdp;
if (take_mdp_ownership_and_delete_async)
owned_mdp.reset(mdp);
@@ -370,7 +371,7 @@
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(kTraceCategory, "ProcessMemoryDump",
TRACE_ID_MANGLE(args.dump_guid));
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state;
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state;
{
AutoLock lock(lock_);
// |dump_thread_| can be nullptr is tracing was disabled before reaching
@@ -400,7 +401,7 @@
// |lock_| is used in these functions purely to ensure consistency w.r.t.
// (un)registrations of |dump_providers_|.
void MemoryDumpManager::SetupNextMemoryDump(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
// Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs
// in the PostTask below don't end up registering their own dump providers
// (for discounting trace memory overhead) while holding the |lock_|.
@@ -482,7 +483,7 @@
// Unfortunately, PostTask() destroys the scoped_ptr arguments upon failure
// to prevent accidental leaks. Using a scoped_ptr would prevent us to to
// skip the hop and move on. Hence the manual naked -> scoped ptr juggling.
- auto pmd_async_state = make_scoped_ptr(owned_pmd_async_state);
+ auto pmd_async_state = WrapUnique(owned_pmd_async_state);
owned_pmd_async_state = nullptr;
// Read MemoryDumpProviderInfo thread safety considerations in
@@ -535,7 +536,7 @@
// static
void MemoryDumpManager::FinalizeDumpAndAddToTrace(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
DCHECK(pmd_async_state->pending_dump_providers.empty());
const uint64_t dump_guid = pmd_async_state->req_args.dump_guid;
if (!pmd_async_state->callback_task_runner->BelongsToCurrentThread()) {
@@ -554,7 +555,7 @@
for (const auto& kv : pmd_async_state->process_dumps) {
ProcessId pid = kv.first; // kNullProcessId for the current process.
ProcessMemoryDump* process_memory_dump = kv.second.get();
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
process_memory_dump->AsValueInto(traced_value.get());
traced_value->SetString("level_of_detail",
MemoryDumpLevelOfDetailToString(
@@ -562,7 +563,8 @@
const char* const event_name =
MemoryDumpTypeToString(pmd_async_state->req_args.dump_type);
- scoped_ptr<ConvertableToTraceFormat> event_value(std::move(traced_value));
+ std::unique_ptr<ConvertableToTraceFormat> event_value(
+ std::move(traced_value));
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID(
TRACE_EVENT_PHASE_MEMORY_DUMP,
TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name,
@@ -598,7 +600,7 @@
TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
// Spin-up the thread used to invoke unbound dump providers.
- scoped_ptr<Thread> dump_thread(new Thread("MemoryInfra"));
+ std::unique_ptr<Thread> dump_thread(new Thread("MemoryInfra"));
if (!dump_thread->Start()) {
LOG(ERROR) << "Failed to start the memory-infra thread for tracing";
return;
@@ -614,15 +616,15 @@
// deduplicator will be in use. Add a metadata events to write the frames
// and type IDs.
session_state_->SetStackFrameDeduplicator(
- make_scoped_ptr(new StackFrameDeduplicator));
+ WrapUnique(new StackFrameDeduplicator));
session_state_->SetTypeNameDeduplicator(
- make_scoped_ptr(new TypeNameDeduplicator));
+ WrapUnique(new TypeNameDeduplicator));
TRACE_EVENT_API_ADD_METADATA_EVENT(
TraceLog::GetCategoryGroupEnabled("__metadata"), "stackFrames",
"stackFrames",
- make_scoped_ptr(
+ WrapUnique(
new SessionStateConvertableProxy<StackFrameDeduplicator>(
session_state_,
&MemoryDumpSessionState::stack_frame_deduplicator)));
@@ -630,7 +632,7 @@
TRACE_EVENT_API_ADD_METADATA_EVENT(
TraceLog::GetCategoryGroupEnabled("__metadata"), "typeNames",
"typeNames",
- make_scoped_ptr(new SessionStateConvertableProxy<TypeNameDeduplicator>(
+ WrapUnique(new SessionStateConvertableProxy<TypeNameDeduplicator>(
session_state_, &MemoryDumpSessionState::type_name_deduplicator)));
}
@@ -682,7 +684,7 @@
// ensure that the MDM state which depends on the tracing enabled / disabled
// state is always accessed by the dumping methods holding the |lock_|.
subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
- scoped_ptr<Thread> dump_thread;
+ std::unique_ptr<Thread> dump_thread;
{
AutoLock lock(lock_);
dump_thread = std::move(dump_thread_);
@@ -749,7 +751,8 @@
GetOrCreateMemoryDumpContainerForProcess(ProcessId pid) {
auto iter = process_dumps.find(pid);
if (iter == process_dumps.end()) {
- scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state));
+ std::unique_ptr<ProcessMemoryDump> new_pmd(
+ new ProcessMemoryDump(session_state));
iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
}
return iter->second.get();
diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h
index 79686c8..817768a 100644
--- a/base/trace_event/memory_dump_manager.h
+++ b/base/trace_event/memory_dump_manager.h
@@ -94,7 +94,8 @@
// - The |mdp| will be deleted at some point in the near future.
// - Its deletion will not happen concurrently with the OnMemoryDump() call.
// Note that OnMemoryDump() calls can still happen after this method returns.
- void UnregisterAndDeleteDumpProviderSoon(scoped_ptr<MemoryDumpProvider> mdp);
+ void UnregisterAndDeleteDumpProviderSoon(
+ std::unique_ptr<MemoryDumpProvider> mdp);
// Requests a memory dump. The dump might happen or not depending on the
// filters and categories specified when enabling tracing.
@@ -181,7 +182,7 @@
// Used to transfer ownership for UnregisterAndDeleteDumpProviderSoon().
// nullptr in all other cases.
- scoped_ptr<MemoryDumpProvider> owned_dump_provider;
+ std::unique_ptr<MemoryDumpProvider> owned_dump_provider;
// Human readable name, for debugging and testing. Not necessarily unique.
const char* const name;
@@ -226,7 +227,7 @@
// being dumped from the current process. Typically each process dumps only
// for itself, unless dump providers specify a different |target_process| in
// MemoryDumpProvider::Options.
- std::map<ProcessId, scoped_ptr<ProcessMemoryDump>> process_dumps;
+ std::map<ProcessId, std::unique_ptr<ProcessMemoryDump>> process_dumps;
// The arguments passed to the initial CreateProcessDump() request.
const MemoryDumpRequestArgs req_args;
@@ -269,7 +270,7 @@
static void SetInstanceForTesting(MemoryDumpManager* instance);
static void FinalizeDumpAndAddToTrace(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
// Enable heap profiling if kEnableHeapProfiling is specified.
void EnableHeapProfilingIfNeeded();
@@ -285,7 +286,7 @@
// the MDP while registration. On failure to do so, skips and continues to
// next MDP.
void SetupNextMemoryDump(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
// Invokes OnMemoryDump() of the next MDP and calls SetupNextMemoryDump() at
// the end to continue the ProcessMemoryDump. Should be called on the MDP task
@@ -328,7 +329,7 @@
// Thread used for MemoryDumpProviders which don't specify a task runner
// affinity.
- scoped_ptr<Thread> dump_thread_;
+ std::unique_ptr<Thread> dump_thread_;
// The unique id of the child process. This is created only for tracing and is
// expected to be valid only when tracing is enabled.
diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc
index 12227ee..2461e61 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -6,11 +6,12 @@
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/bind_helpers.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
@@ -233,12 +234,12 @@
}
const MemoryDumpProvider::Options kDefaultOptions;
- scoped_ptr<MemoryDumpManager> mdm_;
- scoped_ptr<MemoryDumpManagerDelegateForTesting> delegate_;
+ std::unique_ptr<MemoryDumpManager> mdm_;
+ std::unique_ptr<MemoryDumpManagerDelegateForTesting> delegate_;
bool last_callback_success_;
private:
- scoped_ptr<MessageLoop> message_loop_;
+ std::unique_ptr<MessageLoop> message_loop_;
// We want our singleton torn down after each test.
ShadowingAtExitManager at_exit_manager_;
@@ -445,18 +446,18 @@
InitializeMemoryDumpManager(false /* is_coordinator */);
const uint32_t kNumInitialThreads = 8;
- std::vector<scoped_ptr<Thread>> threads;
- std::vector<scoped_ptr<MockMemoryDumpProvider>> mdps;
+ std::vector<std::unique_ptr<Thread>> threads;
+ std::vector<std::unique_ptr<MockMemoryDumpProvider>> mdps;
// Create the threads and setup the expectations. Given that at each iteration
// we will pop out one thread/MemoryDumpProvider, each MDP is supposed to be
// invoked a number of times equal to its index.
for (uint32_t i = kNumInitialThreads; i > 0; --i) {
- threads.push_back(make_scoped_ptr(new Thread("test thread")));
+ threads.push_back(WrapUnique(new Thread("test thread")));
auto thread = threads.back().get();
thread->Start();
scoped_refptr<SingleThreadTaskRunner> task_runner = thread->task_runner();
- mdps.push_back(make_scoped_ptr(new MockMemoryDumpProvider()));
+ mdps.push_back(WrapUnique(new MockMemoryDumpProvider()));
auto mdp = mdps.back().get();
RegisterDumpProvider(mdp, task_runner, kDefaultOptions);
EXPECT_CALL(*mdp, OnMemoryDump(_, _))
@@ -650,13 +651,13 @@
// dumping from a different thread than the dumping thread.
TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) {
InitializeMemoryDumpManager(false /* is_coordinator */);
- std::vector<scoped_ptr<TestIOThread>> threads;
- std::vector<scoped_ptr<MockMemoryDumpProvider>> mdps;
+ std::vector<std::unique_ptr<TestIOThread>> threads;
+ std::vector<std::unique_ptr<MockMemoryDumpProvider>> mdps;
for (int i = 0; i < 2; i++) {
threads.push_back(
- make_scoped_ptr(new TestIOThread(TestIOThread::kAutoStart)));
- mdps.push_back(make_scoped_ptr(new MockMemoryDumpProvider()));
+ WrapUnique(new TestIOThread(TestIOThread::kAutoStart)));
+ mdps.push_back(WrapUnique(new MockMemoryDumpProvider()));
RegisterDumpProvider(mdps.back().get(), threads.back()->task_runner(),
kDefaultOptions);
}
@@ -665,7 +666,7 @@
// When OnMemoryDump is called on either of the dump providers, it will
// unregister the other one.
- for (const scoped_ptr<MockMemoryDumpProvider>& mdp : mdps) {
+ for (const std::unique_ptr<MockMemoryDumpProvider>& mdp : mdps) {
int other_idx = (mdps.front() == mdp);
TestIOThread* other_thread = threads[other_idx].get();
MockMemoryDumpProvider* other_mdp = mdps[other_idx].get();
@@ -700,13 +701,13 @@
// its dump provider should be skipped but the dump itself should succeed.
TEST_F(MemoryDumpManagerTest, TearDownThreadWhileDumping) {
InitializeMemoryDumpManager(false /* is_coordinator */);
- std::vector<scoped_ptr<TestIOThread>> threads;
- std::vector<scoped_ptr<MockMemoryDumpProvider>> mdps;
+ std::vector<std::unique_ptr<TestIOThread>> threads;
+ std::vector<std::unique_ptr<MockMemoryDumpProvider>> mdps;
for (int i = 0; i < 2; i++) {
threads.push_back(
- make_scoped_ptr(new TestIOThread(TestIOThread::kAutoStart)));
- mdps.push_back(make_scoped_ptr(new MockMemoryDumpProvider()));
+ WrapUnique(new TestIOThread(TestIOThread::kAutoStart)));
+ mdps.push_back(WrapUnique(new MockMemoryDumpProvider()));
RegisterDumpProvider(mdps.back().get(), threads.back()->task_runner(),
kDefaultOptions);
}
@@ -715,7 +716,7 @@
// When OnMemoryDump is called on either of the dump providers, it will
// tear down the thread of the other one.
- for (const scoped_ptr<MockMemoryDumpProvider>& mdp : mdps) {
+ for (const std::unique_ptr<MockMemoryDumpProvider>& mdp : mdps) {
int other_idx = (mdps.front() == mdp);
TestIOThread* other_thread = threads[other_idx].get();
auto on_dump = [other_thread, &on_memory_dump_call_count](
@@ -888,7 +889,7 @@
InitializeMemoryDumpManager(false /* is_coordinator */);
// Register a bound dump provider.
- scoped_ptr<Thread> mdp_thread(new Thread("test thread"));
+ std::unique_ptr<Thread> mdp_thread(new Thread("test thread"));
mdp_thread->Start();
MockMemoryDumpProvider mdp_with_affinity;
RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(),
@@ -995,7 +996,7 @@
buffer.Finish();
// Analyze the JSON.
- scoped_ptr<trace_analyzer::TraceAnalyzer> analyzer = make_scoped_ptr(
+ std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer = WrapUnique(
trace_analyzer::TraceAnalyzer::Create(trace_output.json_output));
trace_analyzer::TraceEventVector events;
analyzer->FindEvents(Query::EventPhaseIs(TRACE_EVENT_PHASE_MEMORY_DUMP),
@@ -1016,9 +1017,9 @@
InitializeMemoryDumpManager(false /* is_coordinator */);
static const int kNumProviders = 3;
int dtor_count = 0;
- std::vector<scoped_ptr<MemoryDumpProvider>> mdps;
+ std::vector<std::unique_ptr<MemoryDumpProvider>> mdps;
for (int i = 0; i < kNumProviders; ++i) {
- scoped_ptr<MockMemoryDumpProvider> mdp(new MockMemoryDumpProvider);
+ std::unique_ptr<MockMemoryDumpProvider> mdp(new MockMemoryDumpProvider);
mdp->enable_mock_destructor = true;
EXPECT_CALL(*mdp, Destructor())
.WillOnce(Invoke([&dtor_count]() { dtor_count++; }));
@@ -1041,7 +1042,7 @@
// happen on the same thread (the MemoryDumpManager utility thread).
TEST_F(MemoryDumpManagerTest, UnregisterAndDeleteDumpProviderSoonDuringDump) {
InitializeMemoryDumpManager(false /* is_coordinator */);
- scoped_ptr<MockMemoryDumpProvider> mdp(new MockMemoryDumpProvider);
+ std::unique_ptr<MockMemoryDumpProvider> mdp(new MockMemoryDumpProvider);
mdp->enable_mock_destructor = true;
RegisterDumpProvider(mdp.get(), nullptr, kDefaultOptions);
@@ -1055,7 +1056,7 @@
base::Bind(
&MemoryDumpManager::UnregisterAndDeleteDumpProviderSoon,
base::Unretained(MemoryDumpManager::GetInstance()),
- base::Passed(scoped_ptr<MemoryDumpProvider>(std::move(mdp)))));
+ base::Passed(std::unique_ptr<MemoryDumpProvider>(std::move(mdp)))));
thread_for_unregistration.Stop();
return true;
};
diff --git a/base/trace_event/memory_dump_session_state.cc b/base/trace_event/memory_dump_session_state.cc
index 576da31..e06062d 100644
--- a/base/trace_event/memory_dump_session_state.cc
+++ b/base/trace_event/memory_dump_session_state.cc
@@ -12,13 +12,13 @@
MemoryDumpSessionState::~MemoryDumpSessionState() {}
void MemoryDumpSessionState::SetStackFrameDeduplicator(
- scoped_ptr<StackFrameDeduplicator> stack_frame_deduplicator) {
+ std::unique_ptr<StackFrameDeduplicator> stack_frame_deduplicator) {
DCHECK(!stack_frame_deduplicator_);
stack_frame_deduplicator_ = std::move(stack_frame_deduplicator);
}
void MemoryDumpSessionState::SetTypeNameDeduplicator(
- scoped_ptr<TypeNameDeduplicator> type_name_deduplicator) {
+ std::unique_ptr<TypeNameDeduplicator> type_name_deduplicator) {
DCHECK(!type_name_deduplicator_);
type_name_deduplicator_ = std::move(type_name_deduplicator);
}
diff --git a/base/trace_event/memory_dump_session_state.h b/base/trace_event/memory_dump_session_state.h
index 879545f..7d87198 100644
--- a/base/trace_event/memory_dump_session_state.h
+++ b/base/trace_event/memory_dump_session_state.h
@@ -5,8 +5,9 @@
#ifndef BASE_TRACE_EVENT_MEMORY_DUMP_SESSION_STATE_H_
#define BASE_TRACE_EVENT_MEMORY_DUMP_SESSION_STATE_H_
+#include <memory>
+
#include "base/base_export.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
#include "base/trace_event/heap_profiler_type_name_deduplicator.h"
@@ -27,7 +28,7 @@
}
void SetStackFrameDeduplicator(
- scoped_ptr<StackFrameDeduplicator> stack_frame_deduplicator);
+ std::unique_ptr<StackFrameDeduplicator> stack_frame_deduplicator);
// Returns the type name deduplicator that should be used by memory dump
// providers when doing a heap dump.
@@ -36,7 +37,7 @@
}
void SetTypeNameDeduplicator(
- scoped_ptr<TypeNameDeduplicator> type_name_deduplicator);
+ std::unique_ptr<TypeNameDeduplicator> type_name_deduplicator);
private:
friend class RefCountedThreadSafe<MemoryDumpSessionState>;
@@ -44,11 +45,11 @@
// Deduplicates backtraces in heap dumps so they can be written once when the
// trace is finalized.
- scoped_ptr<StackFrameDeduplicator> stack_frame_deduplicator_;
+ std::unique_ptr<StackFrameDeduplicator> stack_frame_deduplicator_;
// Deduplicates type names in heap dumps so they can be written once when the
// trace is finalized.
- scoped_ptr<TypeNameDeduplicator> type_name_deduplicator_;
+ std::unique_ptr<TypeNameDeduplicator> type_name_deduplicator_;
};
} // namespace trace_event
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 1642e5a..56fda80 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -5,8 +5,10 @@
#include "base/trace_event/process_memory_dump.h"
#include <errno.h>
+
#include <vector>
+#include "base/memory/ptr_util.h"
#include "base/process/process_metrics.h"
#include "base/trace_event/process_memory_totals.h"
#include "base/trace_event/trace_event_argument.h"
@@ -82,12 +84,12 @@
size_t max_vec_size =
GetSystemPageCount(std::min(mapped_size, kMaxChunkSize), page_size);
#if defined(OS_MACOSX) || defined(OS_IOS)
- scoped_ptr<char[]> vec(new char[max_vec_size]);
+ std::unique_ptr<char[]> vec(new char[max_vec_size]);
#elif defined(OS_WIN)
- scoped_ptr<PSAPI_WORKING_SET_EX_INFORMATION[]> vec(
+ std::unique_ptr<PSAPI_WORKING_SET_EX_INFORMATION[]> vec(
new PSAPI_WORKING_SET_EX_INFORMATION[max_vec_size]);
#elif defined(OS_POSIX)
- scoped_ptr<unsigned char[]> vec(new unsigned char[max_vec_size]);
+ std::unique_ptr<unsigned char[]> vec(new unsigned char[max_vec_size]);
#endif
while (offset < mapped_size) {
@@ -154,18 +156,18 @@
MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
const std::string& absolute_name) {
return AddAllocatorDumpInternal(
- make_scoped_ptr(new MemoryAllocatorDump(absolute_name, this)));
+ WrapUnique(new MemoryAllocatorDump(absolute_name, this)));
}
MemoryAllocatorDump* ProcessMemoryDump::CreateAllocatorDump(
const std::string& absolute_name,
const MemoryAllocatorDumpGuid& guid) {
return AddAllocatorDumpInternal(
- make_scoped_ptr(new MemoryAllocatorDump(absolute_name, this, guid)));
+ WrapUnique(new MemoryAllocatorDump(absolute_name, this, guid)));
}
MemoryAllocatorDump* ProcessMemoryDump::AddAllocatorDumpInternal(
- scoped_ptr<MemoryAllocatorDump> mad) {
+ std::unique_ptr<MemoryAllocatorDump> mad) {
auto insertion_result = allocator_dumps_.insert(
std::make_pair(mad->absolute_name(), std::move(mad)));
DCHECK(insertion_result.second) << "Duplicate name: " << mad->absolute_name();
@@ -214,7 +216,7 @@
}
void ProcessMemoryDump::AddHeapDump(const std::string& absolute_name,
- scoped_ptr<TracedValue> heap_dump) {
+ std::unique_ptr<TracedValue> heap_dump) {
DCHECK_EQ(0ul, heap_dumps_.count(absolute_name));
heap_dumps_[absolute_name] = std::move(heap_dump);
}
diff --git a/base/trace_event/process_memory_dump.h b/base/trace_event/process_memory_dump.h
index 41efc73..5ac14fe 100644
--- a/base/trace_event/process_memory_dump.h
+++ b/base/trace_event/process_memory_dump.h
@@ -48,9 +48,10 @@
// Maps allocator dumps absolute names (allocator_name/heap/subheap) to
// MemoryAllocatorDump instances.
using AllocatorDumpsMap =
- std::unordered_map<std::string, scoped_ptr<MemoryAllocatorDump>>;
+ std::unordered_map<std::string, std::unique_ptr<MemoryAllocatorDump>>;
- using HeapDumpsMap = std::unordered_map<std::string, scoped_ptr<TracedValue>>;
+ using HeapDumpsMap =
+ std::unordered_map<std::string, std::unique_ptr<TracedValue>>;
#if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
// Returns the number of bytes in a kernel memory page. Some platforms may
@@ -119,7 +120,7 @@
// must have the correct format. |trace_event::HeapDumper| will generate such
// a value from a |trace_event::AllocationRegister|.
void AddHeapDump(const std::string& absolute_name,
- scoped_ptr<TracedValue> heap_dump);
+ std::unique_ptr<TracedValue> heap_dump);
// Adds an ownership relationship between two MemoryAllocatorDump(s) with the
// semantics: |source| owns |target|, and has the effect of attributing
@@ -175,7 +176,7 @@
private:
MemoryAllocatorDump* AddAllocatorDumpInternal(
- scoped_ptr<MemoryAllocatorDump> mad);
+ std::unique_ptr<MemoryAllocatorDump> mad);
ProcessMemoryTotals process_totals_;
bool has_process_totals_;
diff --git a/base/trace_event/process_memory_dump_unittest.cc b/base/trace_event/process_memory_dump_unittest.cc
index e7fe960..3a93b2c 100644
--- a/base/trace_event/process_memory_dump_unittest.cc
+++ b/base/trace_event/process_memory_dump_unittest.cc
@@ -23,7 +23,7 @@
} // namespace
TEST(ProcessMemoryDumpTest, Clear) {
- scoped_ptr<ProcessMemoryDump> pmd1(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd1(new ProcessMemoryDump(nullptr));
pmd1->CreateAllocatorDump("mad1");
pmd1->CreateAllocatorDump("mad2");
ASSERT_FALSE(pmd1->allocator_dumps().empty());
@@ -54,7 +54,7 @@
ASSERT_EQ(nullptr, pmd1->GetSharedGlobalAllocatorDump(shared_mad_guid2));
// Check that calling AsValueInto() doesn't cause a crash.
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
pmd1->AsValueInto(traced_value.get());
// Check that the pmd can be reused and behaves as expected.
@@ -79,11 +79,11 @@
}
TEST(ProcessMemoryDumpTest, TakeAllDumpsFrom) {
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
TracedValue* heap_dumps_ptr[4];
- scoped_ptr<TracedValue> heap_dump;
+ std::unique_ptr<TracedValue> heap_dump;
- scoped_ptr<ProcessMemoryDump> pmd1(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd1(new ProcessMemoryDump(nullptr));
auto mad1_1 = pmd1->CreateAllocatorDump("pmd1/mad1");
auto mad1_2 = pmd1->CreateAllocatorDump("pmd1/mad2");
pmd1->AddOwnershipEdge(mad1_1->guid(), mad1_2->guid());
@@ -94,7 +94,7 @@
heap_dumps_ptr[1] = heap_dump.get();
pmd1->AddHeapDump("pmd1/heap_dump2", std::move(heap_dump));
- scoped_ptr<ProcessMemoryDump> pmd2(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd2(new ProcessMemoryDump(nullptr));
auto mad2_1 = pmd2->CreateAllocatorDump("pmd2/mad1");
auto mad2_2 = pmd2->CreateAllocatorDump("pmd2/mad2");
pmd2->AddOwnershipEdge(mad2_1->guid(), mad2_2->guid());
@@ -154,7 +154,7 @@
}
TEST(ProcessMemoryDumpTest, Suballocations) {
- scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
const std::string allocator_dump_name = "fakealloc/allocated_objects";
pmd->CreateAllocatorDump(allocator_dump_name);
@@ -191,14 +191,14 @@
ASSERT_TRUE(found_edge[1]);
// Check that calling AsValueInto() doesn't cause a crash.
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
pmd->AsValueInto(traced_value.get());
pmd.reset();
}
TEST(ProcessMemoryDumpTest, GlobalAllocatorDumpTest) {
- scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
+ std::unique_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
MemoryAllocatorDumpGuid shared_mad_guid(1);
auto shared_mad1 = pmd->CreateWeakSharedGlobalAllocatorDump(shared_mad_guid);
ASSERT_EQ(shared_mad_guid, shared_mad1->guid());
@@ -227,7 +227,7 @@
// Allocate few page of dirty memory and check if it is resident.
const size_t size1 = 5 * page_size;
- scoped_ptr<char, base::AlignedFreeDeleter> memory1(
+ std::unique_ptr<char, base::AlignedFreeDeleter> memory1(
static_cast<char*>(base::AlignedAlloc(size1, page_size)));
memset(memory1.get(), 0, size1);
size_t res1 = ProcessMemoryDump::CountResidentBytes(memory1.get(), size1);
@@ -235,7 +235,7 @@
// Allocate a large memory segment (> 8Mib).
const size_t kVeryLargeMemorySize = 15 * 1024 * 1024;
- scoped_ptr<char, base::AlignedFreeDeleter> memory2(
+ std::unique_ptr<char, base::AlignedFreeDeleter> memory2(
static_cast<char*>(base::AlignedAlloc(kVeryLargeMemorySize, page_size)));
memset(memory2.get(), 0, kVeryLargeMemorySize);
size_t res2 = ProcessMemoryDump::CountResidentBytes(memory2.get(),
diff --git a/base/trace_event/trace_buffer.cc b/base/trace_event/trace_buffer.cc
index 9630a7a..b9f80b2 100644
--- a/base/trace_event/trace_buffer.cc
+++ b/base/trace_event/trace_buffer.cc
@@ -4,11 +4,11 @@
#include "base/trace_event/trace_buffer.h"
+#include <memory>
#include <utility>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event_impl.h"
namespace base {
@@ -30,7 +30,7 @@
recyclable_chunks_queue_[i] = i;
}
- scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) override {
+ std::unique_ptr<TraceBufferChunk> GetChunk(size_t* index) override {
// Because the number of threads is much less than the number of chunks,
// the queue should never be empty.
DCHECK(!QueueIsEmpty());
@@ -49,10 +49,11 @@
else
chunk = new TraceBufferChunk(current_chunk_seq_++);
- return scoped_ptr<TraceBufferChunk>(chunk);
+ return std::unique_ptr<TraceBufferChunk>(chunk);
}
- void ReturnChunk(size_t index, scoped_ptr<TraceBufferChunk> chunk) override {
+ void ReturnChunk(size_t index,
+ std::unique_ptr<TraceBufferChunk> chunk) override {
// When this method is called, the queue should not be full because it
// can contain all chunks including the one to be returned.
DCHECK(!QueueIsFull());
@@ -135,9 +136,9 @@
}
size_t max_chunks_;
- std::vector<scoped_ptr<TraceBufferChunk>> chunks_;
+ std::vector<std::unique_ptr<TraceBufferChunk>> chunks_;
- scoped_ptr<size_t[]> recyclable_chunks_queue_;
+ std::unique_ptr<size_t[]> recyclable_chunks_queue_;
size_t queue_head_;
size_t queue_tail_;
@@ -156,7 +157,7 @@
chunks_.reserve(max_chunks_);
}
- scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) override {
+ std::unique_ptr<TraceBufferChunk> GetChunk(size_t* index) override {
// This function may be called when adding normal events or indirectly from
// AddMetadataEventsWhileLocked(). We can not DECHECK(!IsFull()) because we
// have to add the metadata events and flush thread-local buffers even if
@@ -165,11 +166,12 @@
chunks_.push_back(NULL); // Put NULL in the slot of a in-flight chunk.
++in_flight_chunk_count_;
// + 1 because zero chunk_seq is not allowed.
- return scoped_ptr<TraceBufferChunk>(
+ return std::unique_ptr<TraceBufferChunk>(
new TraceBufferChunk(static_cast<uint32_t>(*index) + 1));
}
- void ReturnChunk(size_t index, scoped_ptr<TraceBufferChunk> chunk) override {
+ void ReturnChunk(size_t index,
+ std::unique_ptr<TraceBufferChunk> chunk) override {
DCHECK_GT(in_flight_chunk_count_, 0u);
DCHECK_LT(index, chunks_.size());
DCHECK(!chunks_[index]);
diff --git a/base/trace_event/trace_buffer.h b/base/trace_event/trace_buffer.h
index c4c1c2b..4885a3c 100644
--- a/base/trace_event/trace_buffer.h
+++ b/base/trace_event/trace_buffer.h
@@ -49,7 +49,7 @@
private:
size_t next_free_;
- scoped_ptr<TraceEventMemoryOverhead> cached_overhead_estimate_;
+ std::unique_ptr<TraceEventMemoryOverhead> cached_overhead_estimate_;
TraceEvent chunk_[kTraceBufferChunkSize];
uint32_t seq_;
};
@@ -59,9 +59,9 @@
public:
virtual ~TraceBuffer() {}
- virtual scoped_ptr<TraceBufferChunk> GetChunk(size_t* index) = 0;
+ virtual std::unique_ptr<TraceBufferChunk> GetChunk(size_t* index) = 0;
virtual void ReturnChunk(size_t index,
- scoped_ptr<TraceBufferChunk> chunk) = 0;
+ std::unique_ptr<TraceBufferChunk> chunk) = 0;
virtual bool IsFull() const = 0;
virtual size_t Size() const = 0;
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
index c2c7ad7..e9e5a09 100644
--- a/base/trace_event/trace_config.cc
+++ b/base/trace_event/trace_config.cc
@@ -10,6 +10,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h"
@@ -160,9 +161,9 @@
return json;
}
-scoped_ptr<ConvertableToTraceFormat> TraceConfig::AsConvertableToTraceFormat()
- const {
- return make_scoped_ptr(new ConvertableTraceConfigToTraceFormat(*this));
+std::unique_ptr<ConvertableToTraceFormat>
+TraceConfig::AsConvertableToTraceFormat() const {
+ return WrapUnique(new ConvertableTraceConfigToTraceFormat(*this));
}
std::string TraceConfig::ToCategoryFilterString() const {
@@ -345,7 +346,7 @@
}
void TraceConfig::InitializeFromConfigString(const std::string& config_string) {
- scoped_ptr<Value> value(JSONReader::Read(config_string));
+ std::unique_ptr<Value> value(JSONReader::Read(config_string));
if (!value)
return InitializeDefault();
@@ -476,7 +477,7 @@
if (categories.empty())
return;
- scoped_ptr<base::ListValue> list(new base::ListValue());
+ std::unique_ptr<base::ListValue> list(new base::ListValue());
for (StringList::const_iterator ci = categories.begin();
ci != categories.end();
++ci) {
@@ -565,11 +566,11 @@
AddCategoryToDict(dict, kSyntheticDelaysParam, synthetic_delays_);
if (IsCategoryEnabled(MemoryDumpManager::kTraceCategory)) {
- scoped_ptr<base::DictionaryValue> memory_dump_config(
+ std::unique_ptr<base::DictionaryValue> memory_dump_config(
new base::DictionaryValue());
- scoped_ptr<base::ListValue> triggers_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> triggers_list(new base::ListValue());
for (const MemoryDumpTriggerConfig& config : memory_dump_config_) {
- scoped_ptr<base::DictionaryValue> trigger_dict(
+ std::unique_ptr<base::DictionaryValue> trigger_dict(
new base::DictionaryValue());
trigger_dict->SetInteger(kPeriodicIntervalParam,
static_cast<int>(config.periodic_interval_ms));
diff --git a/base/trace_event/trace_config.h b/base/trace_event/trace_config.h
index 75e001b..72ca5f8 100644
--- a/base/trace_event/trace_config.h
+++ b/base/trace_event/trace_config.h
@@ -158,7 +158,7 @@
std::string ToString() const;
// Returns a copy of the TraceConfig wrapped in a ConvertableToTraceFormat
- scoped_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const;
+ std::unique_ptr<ConvertableToTraceFormat> AsConvertableToTraceFormat() const;
// Write the string representation of the CategoryFilter part.
std::string ToCategoryFilterString() const;
diff --git a/base/trace_event/trace_config_unittest.cc b/base/trace_event/trace_config_unittest.cc
index 1b49fdc..1fb41f8 100644
--- a/base/trace_event/trace_config_unittest.cc
+++ b/base/trace_event/trace_config_unittest.cc
@@ -292,7 +292,8 @@
EXPECT_FALSE(tc.IsArgumentFilterEnabled());
EXPECT_STREQ("", tc.ToCategoryFilterString().c_str());
- scoped_ptr<Value> default_value(JSONReader::Read(kDefaultTraceConfigString));
+ std::unique_ptr<Value> default_value(
+ JSONReader::Read(kDefaultTraceConfigString));
DCHECK(default_value);
const DictionaryValue* default_dict = nullptr;
bool is_dict = default_value->GetAsDictionary(&default_dict);
@@ -305,7 +306,8 @@
EXPECT_FALSE(default_tc.IsArgumentFilterEnabled());
EXPECT_STREQ("-*Debug,-*Test", default_tc.ToCategoryFilterString().c_str());
- scoped_ptr<Value> custom_value(JSONReader::Read(kCustomTraceConfigString));
+ std::unique_ptr<Value> custom_value(
+ JSONReader::Read(kCustomTraceConfigString));
DCHECK(custom_value);
const DictionaryValue* custom_dict = nullptr;
is_dict = custom_value->GetAsDictionary(&custom_dict);
diff --git a/base/trace_event/trace_event.h b/base/trace_event/trace_event.h
index e7801e6..ef452f6 100644
--- a/base/trace_event/trace_event.h
+++ b/base/trace_event/trace_event.h
@@ -111,7 +111,7 @@
// const char** arg_names,
// const unsigned char* arg_types,
// const unsigned long long* arg_values,
-// scoped_ptr<ConvertableToTraceFormat>*
+// std::unique_ptr<ConvertableToTraceFormat>*
// convertable_values,
// unsigned int flags)
#define TRACE_EVENT_API_ADD_TRACE_EVENT \
@@ -130,7 +130,7 @@
// const char** arg_names,
// const unsigned char* arg_types,
// const unsigned long long* arg_values,
-// scoped_ptr<ConvertableToTraceFormat>*
+// std::unique_ptr<ConvertableToTraceFormat>*
// convertable_values,
// unsigned int flags)
#define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID \
@@ -150,7 +150,7 @@
// const char** arg_names,
// const unsigned char* arg_types,
// const unsigned long long* arg_values,
-// scoped_ptr<ConvertableToTraceFormat>*
+// std::unique_ptr<ConvertableToTraceFormat>*
// convertable_values,
// unsigned int flags)
#define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID \
@@ -170,7 +170,7 @@
// const char** arg_names,
// const unsigned char* arg_types,
// const unsigned long long* arg_values,
-// scoped_ptr<ConvertableToTraceFormat>*
+// std::unique_ptr<ConvertableToTraceFormat>*
// convertable_values,
// unsigned int flags)
#define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \
@@ -191,7 +191,7 @@
// const unsigned char* category_group_enabled,
// const char* event_name,
// const char* arg_name,
-// scoped_ptr<ConvertableToTraceFormat> arg_value)
+// std::unique_ptr<ConvertableToTraceFormat> arg_value)
#define TRACE_EVENT_API_ADD_METADATA_EVENT \
trace_event_internal::AddMetadataEvent
@@ -629,10 +629,10 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val) {
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val) {
const int num_args = 1;
unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE };
- scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
convertable_values[1] = {std::move(arg1_val)};
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
@@ -655,7 +655,7 @@
const char* arg1_name,
const ARG1_TYPE& arg1_val,
const char* arg2_name,
- scoped_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
+ std::unique_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
const int num_args = 2;
const char* arg_names[2] = { arg1_name, arg2_name };
@@ -663,7 +663,7 @@
unsigned long long arg_values[2];
SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
arg_types[1] = TRACE_VALUE_TYPE_CONVERTABLE;
- scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
convertable_values[2] = {nullptr, std::move(arg2_val)};
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
@@ -684,7 +684,7 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
const char* arg2_name,
const ARG2_TYPE& arg2_val) {
const int num_args = 2;
@@ -695,7 +695,7 @@
arg_types[0] = TRACE_VALUE_TYPE_CONVERTABLE;
arg_values[0] = 0;
SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
- scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
convertable_values[2] = {std::move(arg1_val), nullptr};
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
@@ -716,14 +716,14 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
const char* arg2_name,
- scoped_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
+ std::unique_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
const int num_args = 2;
const char* arg_names[2] = { arg1_name, arg2_name };
unsigned char arg_types[2] =
{ TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE };
- scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
convertable_values[2] = {std::move(arg1_val), std::move(arg2_val)};
return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
phase, category_group_enabled, name, scope, id, bind_id, thread_id,
@@ -813,7 +813,7 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val) {
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
base::TimeTicks now = base::TimeTicks::Now();
return AddTraceEventWithThreadIdAndTimestamp(
@@ -858,7 +858,7 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
const char* arg2_name,
const ARG2_TYPE& arg2_val) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
@@ -880,7 +880,7 @@
const char* arg1_name,
const ARG1_TYPE& arg1_val,
const char* arg2_name,
- scoped_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
+ std::unique_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
base::TimeTicks now = base::TimeTicks::Now();
return AddTraceEventWithThreadIdAndTimestamp(
@@ -898,9 +898,9 @@
unsigned int flags,
unsigned long long bind_id,
const char* arg1_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg1_val,
const char* arg2_name,
- scoped_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
+ std::unique_ptr<ARG2_CONVERTABLE_TYPE> arg2_val) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
base::TimeTicks now = base::TimeTicks::Now();
return AddTraceEventWithThreadIdAndTimestamp(
@@ -933,10 +933,10 @@
const unsigned char* category_group_enabled,
const char* event_name,
const char* arg_name,
- scoped_ptr<ARG1_CONVERTABLE_TYPE> arg_value) {
+ std::unique_ptr<ARG1_CONVERTABLE_TYPE> arg_value) {
const char* arg_names[1] = {arg_name};
unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE};
- scoped_ptr<base::trace_event::ConvertableToTraceFormat>
+ std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
convertable_values[1] = {std::move(arg_value)};
base::trace_event::TraceLog::GetInstance()->AddMetadataEvent(
category_group_enabled, event_name,
diff --git a/base/trace_event/trace_event_android.cc b/base/trace_event/trace_event_android.cc
index 0053ca6..d406d2c 100644
--- a/base/trace_event/trace_event_android.cc
+++ b/base/trace_event/trace_event_android.cc
@@ -38,15 +38,16 @@
}
}
-void WriteEvent(char phase,
- const char* category_group,
- const char* name,
- unsigned long long id,
- const char** arg_names,
- const unsigned char* arg_types,
- const TraceEvent::TraceValue* arg_values,
- const scoped_ptr<ConvertableToTraceFormat>* convertable_values,
- unsigned int flags) {
+void WriteEvent(
+ char phase,
+ const char* category_group,
+ const char* name,
+ unsigned long long id,
+ const char** arg_names,
+ const unsigned char* arg_types,
+ const TraceEvent::TraceValue* arg_values,
+ const std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
+ unsigned int flags) {
std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name);
if (flags & TRACE_EVENT_FLAG_HAS_ID)
StringAppendF(&out, "-%" PRIx64, static_cast<uint64_t>(id));
diff --git a/base/trace_event/trace_event_argument.cc b/base/trace_event/trace_event_argument.cc
index 6d787c8..f86ac57 100644
--- a/base/trace_event/trace_event_argument.cc
+++ b/base/trace_event/trace_event_argument.cc
@@ -10,6 +10,7 @@
#include "base/bits.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event_memory_overhead.h"
#include "base/values.h"
@@ -234,7 +235,8 @@
pickle_.WriteBytes(&kTypeEndArray, 1);
}
-void TracedValue::SetValue(const char* name, scoped_ptr<base::Value> value) {
+void TracedValue::SetValue(const char* name,
+ std::unique_ptr<base::Value> value) {
SetBaseValueWithCopiedName(name, *value);
}
@@ -347,8 +349,8 @@
}
}
-scoped_ptr<base::Value> TracedValue::ToBaseValue() const {
- scoped_ptr<DictionaryValue> root(new DictionaryValue);
+std::unique_ptr<base::Value> TracedValue::ToBaseValue() const {
+ std::unique_ptr<DictionaryValue> root(new DictionaryValue);
DictionaryValue* cur_dict = root.get();
ListValue* cur_list = nullptr;
std::vector<Value*> stack;
@@ -362,11 +364,11 @@
auto new_dict = new DictionaryValue();
if (cur_dict) {
cur_dict->SetWithoutPathExpansion(ReadKeyName(it),
- make_scoped_ptr(new_dict));
+ WrapUnique(new_dict));
stack.push_back(cur_dict);
cur_dict = new_dict;
} else {
- cur_list->Append(make_scoped_ptr(new_dict));
+ cur_list->Append(WrapUnique(new_dict));
stack.push_back(cur_list);
cur_list = nullptr;
cur_dict = new_dict;
@@ -387,12 +389,12 @@
auto new_list = new ListValue();
if (cur_dict) {
cur_dict->SetWithoutPathExpansion(ReadKeyName(it),
- make_scoped_ptr(new_list));
+ WrapUnique(new_list));
stack.push_back(cur_dict);
cur_dict = nullptr;
cur_list = new_list;
} else {
- cur_list->Append(make_scoped_ptr(new_list));
+ cur_list->Append(WrapUnique(new_list));
stack.push_back(cur_list);
cur_list = new_list;
}
diff --git a/base/trace_event/trace_event_argument.h b/base/trace_event/trace_event_argument.h
index d706479..81d8c01 100644
--- a/base/trace_event/trace_event_argument.h
+++ b/base/trace_event/trace_event_argument.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "base/strings/string_piece.h"
#include "base/trace_event/trace_event_impl.h"
@@ -67,13 +67,13 @@
// a copy-and-translation of the base::Value into the equivalent TracedValue.
// TODO(primiano): migrate the (three) existing clients to the cheaper
// SetValue(TracedValue) API. crbug.com/495628.
- void SetValue(const char* name, scoped_ptr<base::Value> value);
+ void SetValue(const char* name, std::unique_ptr<base::Value> value);
void SetBaseValueWithCopiedName(base::StringPiece name,
const base::Value& value);
void AppendBaseValue(const base::Value& value);
// Public for tests only.
- scoped_ptr<base::Value> ToBaseValue() const;
+ std::unique_ptr<base::Value> ToBaseValue() const;
private:
Pickle pickle_;
diff --git a/base/trace_event/trace_event_argument_unittest.cc b/base/trace_event/trace_event_argument_unittest.cc
index 644d494..61395f4 100644
--- a/base/trace_event/trace_event_argument_unittest.cc
+++ b/base/trace_event/trace_event_argument_unittest.cc
@@ -8,6 +8,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,7 +16,7 @@
namespace trace_event {
TEST(TraceEventArgumentTest, FlatDictionary) {
- scoped_ptr<TracedValue> value(new TracedValue());
+ std::unique_ptr<TracedValue> value(new TracedValue());
value->SetInteger("int", 2014);
value->SetDouble("double", 0.0);
value->SetBoolean("bool", true);
@@ -28,7 +29,7 @@
}
TEST(TraceEventArgumentTest, NoDotPathExpansion) {
- scoped_ptr<TracedValue> value(new TracedValue());
+ std::unique_ptr<TracedValue> value(new TracedValue());
value->SetInteger("in.t", 2014);
value->SetDouble("doub.le", 0.0);
value->SetBoolean("bo.ol", true);
@@ -41,7 +42,7 @@
}
TEST(TraceEventArgumentTest, Hierarchy) {
- scoped_ptr<TracedValue> value(new TracedValue());
+ std::unique_ptr<TracedValue> value(new TracedValue());
value->SetInteger("i0", 2014);
value->BeginDictionary("dict1");
value->SetInteger("i1", 2014);
@@ -77,7 +78,7 @@
kLongString3[i] = 'a' + (i % 25);
kLongString3[sizeof(kLongString3) - 1] = '\0';
- scoped_ptr<TracedValue> value(new TracedValue());
+ std::unique_ptr<TracedValue> value(new TracedValue());
value->SetString("a", "short");
value->SetString("b", kLongString);
value->BeginArray("c");
@@ -100,20 +101,20 @@
FundamentalValue bool_value(true);
FundamentalValue double_value(42.0f);
- auto dict_value = make_scoped_ptr(new DictionaryValue);
+ auto dict_value = WrapUnique(new DictionaryValue);
dict_value->SetBoolean("bool", true);
dict_value->SetInteger("int", 42);
dict_value->SetDouble("double", 42.0f);
dict_value->SetString("string", std::string("a") + "b");
dict_value->SetString("string", std::string("a") + "b");
- auto list_value = make_scoped_ptr(new ListValue);
+ auto list_value = WrapUnique(new ListValue);
list_value->AppendBoolean(false);
list_value->AppendInteger(1);
list_value->AppendString("in_list");
list_value->Append(std::move(dict_value));
- scoped_ptr<TracedValue> value(new TracedValue());
+ std::unique_ptr<TracedValue> value(new TracedValue());
value->BeginDictionary("outer_dict");
value->SetValue("inner_list", std::move(list_value));
value->EndDictionary();
@@ -130,10 +131,10 @@
}
TEST(TraceEventArgumentTest, PassTracedValue) {
- auto dict_value = make_scoped_ptr(new TracedValue());
+ auto dict_value = WrapUnique(new TracedValue());
dict_value->SetInteger("a", 1);
- auto nested_dict_value = make_scoped_ptr(new TracedValue());
+ auto nested_dict_value = WrapUnique(new TracedValue());
nested_dict_value->SetInteger("b", 2);
nested_dict_value->BeginArray("c");
nested_dict_value->AppendString("foo");
diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc
index c0dc843..4ab0d35 100644
--- a/base/trace_event/trace_event_impl.cc
+++ b/base/trace_event/trace_event_impl.cc
@@ -56,7 +56,7 @@
TraceEvent::~TraceEvent() {
}
-void TraceEvent::MoveFrom(scoped_ptr<TraceEvent> other) {
+void TraceEvent::MoveFrom(std::unique_ptr<TraceEvent> other) {
timestamp_ = other->timestamp_;
thread_timestamp_ = other->thread_timestamp_;
duration_ = other->duration_;
@@ -94,7 +94,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
timestamp_ = timestamp;
thread_timestamp_ = thread_timestamp;
diff --git a/base/trace_event/trace_event_impl.h b/base/trace_event/trace_event_impl.h
index df7151a..4382217 100644
--- a/base/trace_event/trace_event_impl.h
+++ b/base/trace_event/trace_event_impl.h
@@ -8,6 +8,7 @@
#include <stdint.h>
+#include <memory>
#include <stack>
#include <string>
#include <vector>
@@ -17,7 +18,6 @@
#include "base/callback.h"
#include "base/containers/hash_tables.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
@@ -92,7 +92,7 @@
TraceEvent();
~TraceEvent();
- void MoveFrom(scoped_ptr<TraceEvent> other);
+ void MoveFrom(std::unique_ptr<TraceEvent> other);
void Initialize(int thread_id,
TimeTicks timestamp,
@@ -107,7 +107,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
void Reset();
@@ -163,10 +163,11 @@
unsigned long long id_;
TraceValue arg_values_[kTraceMaxNumArgs];
const char* arg_names_[kTraceMaxNumArgs];
- scoped_ptr<ConvertableToTraceFormat> convertable_values_[kTraceMaxNumArgs];
+ std::unique_ptr<ConvertableToTraceFormat>
+ convertable_values_[kTraceMaxNumArgs];
const unsigned char* category_group_enabled_;
const char* name_;
- scoped_ptr<std::string> parameter_copy_storage_;
+ std::unique_ptr<std::string> parameter_copy_storage_;
// Depending on TRACE_EVENT_FLAG_HAS_PROCESS_ID the event will have either:
// tid: thread_id_, pid: current_process_id (default case).
// tid: -1, pid: process_id_ (when flags_ & TRACE_EVENT_FLAG_HAS_PROCESS_ID).
diff --git a/base/trace_event/trace_event_system_stats_monitor.cc b/base/trace_event/trace_event_system_stats_monitor.cc
index d42ad00..54fe8e6 100644
--- a/base/trace_event/trace_event_system_stats_monitor.cc
+++ b/base/trace_event/trace_event_system_stats_monitor.cc
@@ -4,12 +4,13 @@
#include "base/trace_event/trace_event_system_stats_monitor.h"
+#include <memory>
+
#include "base/debug/leak_annotations.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
@@ -104,7 +105,7 @@
// If system tracing is enabled, dumps a profile to the tracing system.
void TraceEventSystemStatsMonitor::DumpSystemStats() {
- scoped_ptr<SystemStatsHolder> dump_holder(new SystemStatsHolder());
+ std::unique_ptr<SystemStatsHolder> dump_holder(new SystemStatsHolder());
dump_holder->GetSystemProfilingStats();
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
diff --git a/base/trace_event/trace_event_system_stats_monitor_unittest.cc b/base/trace_event/trace_event_system_stats_monitor_unittest.cc
index a90e74d..e834ded 100644
--- a/base/trace_event/trace_event_system_stats_monitor_unittest.cc
+++ b/base/trace_event/trace_event_system_stats_monitor_unittest.cc
@@ -36,7 +36,7 @@
EXPECT_EQ(0u, TraceLog::GetInstance()->GetObserverCountForTest());
// Creating a system stats monitor adds it to the TraceLog observer list.
- scoped_ptr<TraceEventSystemStatsMonitor> system_stats_monitor(
+ std::unique_ptr<TraceEventSystemStatsMonitor> system_stats_monitor(
new TraceEventSystemStatsMonitor(message_loop.task_runner()));
EXPECT_EQ(1u, TraceLog::GetInstance()->GetObserverCountForTest());
EXPECT_TRUE(
diff --git a/base/trace_event/trace_event_unittest.cc b/base/trace_event/trace_event_unittest.cc
index c98c698..91155ea 100644
--- a/base/trace_event/trace_event_unittest.cc
+++ b/base/trace_event/trace_event_unittest.cc
@@ -2,11 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/trace_event/trace_event.h"
+
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <cstdlib>
+#include <memory>
#include "base/bind.h"
#include "base/command_line.h"
@@ -15,7 +18,6 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/process/process_handle.h"
#include "base/single_thread_task_runner.h"
@@ -27,7 +29,6 @@
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/trace_event/trace_buffer.h"
-#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_synthetic_delay.h"
#include "base/values.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -183,7 +184,7 @@
trace_buffer_.AddFragment(events_str->data());
trace_buffer_.Finish();
- scoped_ptr<Value> root = base::JSONReader::Read(
+ std::unique_ptr<Value> root = base::JSONReader::Read(
json_output_.json_output, JSON_PARSE_RFC | JSON_DETACHABLE_CHILDREN);
if (!root.get()) {
@@ -196,7 +197,7 @@
// Move items into our aggregate collection
while (root_list->GetSize()) {
- scoped_ptr<Value> item;
+ std::unique_ptr<Value> item;
root_list->Remove(0, &item);
trace_parsed_.Append(item.release());
}
@@ -266,7 +267,7 @@
}
void TraceEventTestFixture::DropTracedMetadataRecords() {
- scoped_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy());
+ std::unique_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy());
size_t old_trace_parsed_size = old_trace_parsed->GetSize();
trace_parsed_.Clear();
@@ -1247,8 +1248,8 @@
int* num_calls_;
};
- scoped_ptr<ConvertableToTraceFormat> conv1(new Convertable(&num_calls));
- scoped_ptr<Convertable> conv2(new Convertable(&num_calls));
+ std::unique_ptr<ConvertableToTraceFormat> conv1(new Convertable(&num_calls));
+ std::unique_ptr<Convertable> conv2(new Convertable(&num_calls));
BeginTrace();
TRACE_EVENT_API_ADD_METADATA_EVENT(
@@ -2054,19 +2055,20 @@
TraceLog::GetInstance()->SetEnabled(TraceConfig(kRecordAllCategoryFilter, ""),
TraceLog::RECORDING_MODE);
- scoped_ptr<ConvertableToTraceFormat> data(new MyData());
- scoped_ptr<ConvertableToTraceFormat> data1(new MyData());
- scoped_ptr<ConvertableToTraceFormat> data2(new MyData());
+ std::unique_ptr<ConvertableToTraceFormat> data(new MyData());
+ std::unique_ptr<ConvertableToTraceFormat> data1(new MyData());
+ std::unique_ptr<ConvertableToTraceFormat> data2(new MyData());
TRACE_EVENT1("foo", "bar", "data", std::move(data));
TRACE_EVENT2("foo", "baz", "data1", std::move(data1), "data2",
std::move(data2));
- // Check that scoped_ptr<DerivedClassOfConvertable> are properly treated as
+ // Check that std::unique_ptr<DerivedClassOfConvertable> are properly treated
+ // as
// convertable and not accidentally casted to bool.
- scoped_ptr<MyData> convertData1(new MyData());
- scoped_ptr<MyData> convertData2(new MyData());
- scoped_ptr<MyData> convertData3(new MyData());
- scoped_ptr<MyData> convertData4(new MyData());
+ std::unique_ptr<MyData> convertData1(new MyData());
+ std::unique_ptr<MyData> convertData2(new MyData());
+ std::unique_ptr<MyData> convertData3(new MyData());
+ std::unique_ptr<MyData> convertData4(new MyData());
TRACE_EVENT2("foo", "string_first", "str", "string value 1", "convert",
std::move(convertData1));
TRACE_EVENT2("foo", "string_second", "convert", std::move(convertData2),
@@ -2686,7 +2688,8 @@
size_t chunk_index;
EXPECT_EQ(0u, buffer->Size());
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]);
+ std::unique_ptr<TraceBufferChunk* []> chunks(
+ new TraceBufferChunk*[num_chunks]);
for (size_t i = 0; i < num_chunks; ++i) {
chunks[i] = buffer->GetChunk(&chunk_index).release();
EXPECT_TRUE(chunks[i]);
@@ -2702,7 +2705,7 @@
// Return all chunks in original order.
for (size_t i = 0; i < num_chunks; ++i)
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i]));
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i]));
// Should recycle the chunks in the returned order.
for (size_t i = 0; i < num_chunks; ++i) {
@@ -2715,9 +2718,8 @@
// Return all chunks in reverse order.
for (size_t i = 0; i < num_chunks; ++i) {
- buffer->ReturnChunk(
- num_chunks - i - 1,
- scoped_ptr<TraceBufferChunk>(chunks[num_chunks - i - 1]));
+ buffer->ReturnChunk(num_chunks - i - 1, std::unique_ptr<TraceBufferChunk>(
+ chunks[num_chunks - i - 1]));
}
// Should recycle the chunks in the returned order.
@@ -2730,7 +2732,7 @@
}
for (size_t i = 0; i < num_chunks; ++i)
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i]));
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i]));
TraceLog::GetInstance()->SetDisabled();
}
@@ -2747,7 +2749,8 @@
EXPECT_FALSE(buffer->NextChunk());
size_t half_chunks = num_chunks / 2;
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[half_chunks]);
+ std::unique_ptr<TraceBufferChunk* []> chunks(
+ new TraceBufferChunk*[half_chunks]);
for (size_t i = 0; i < half_chunks; ++i) {
chunks[i] = buffer->GetChunk(&chunk_index).release();
@@ -2755,7 +2758,7 @@
EXPECT_EQ(i, chunk_index);
}
for (size_t i = 0; i < half_chunks; ++i)
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i]));
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i]));
for (size_t i = 0; i < half_chunks; ++i)
EXPECT_EQ(chunks[i], buffer->NextChunk());
@@ -2774,7 +2777,8 @@
EXPECT_EQ(0u, buffer->Size());
EXPECT_FALSE(buffer->NextChunk());
- scoped_ptr<TraceBufferChunk*[]> chunks(new TraceBufferChunk*[num_chunks]);
+ std::unique_ptr<TraceBufferChunk* []> chunks(
+ new TraceBufferChunk*[num_chunks]);
for (size_t i = 0; i < num_chunks; ++i) {
chunks[i] = buffer->GetChunk(&chunk_index).release();
@@ -2782,7 +2786,7 @@
EXPECT_EQ(i, chunk_index);
}
for (size_t i = 0; i < num_chunks; ++i)
- buffer->ReturnChunk(i, scoped_ptr<TraceBufferChunk>(chunks[i]));
+ buffer->ReturnChunk(i, std::unique_ptr<TraceBufferChunk>(chunks[i]));
for (size_t i = 0; i < num_chunks; ++i)
EXPECT_TRUE(chunks[i] == buffer->NextChunk());
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index 1da4a63..a0b12fb 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <cmath>
+#include <memory>
#include <utility>
#include "base/base_switches.h"
@@ -16,7 +17,6 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/process/process_metrics.h"
#include "base/stl_util.h"
@@ -241,7 +241,7 @@
// Since TraceLog is a leaky singleton, trace_log_ will always be valid
// as long as the thread exists.
TraceLog* trace_log_;
- scoped_ptr<TraceBufferChunk> chunk_;
+ std::unique_ptr<TraceBufferChunk> chunk_;
size_t chunk_index_;
int generation_;
@@ -901,7 +901,7 @@
// Usually it runs on a different thread.
void TraceLog::ConvertTraceEventsToTraceFormat(
- scoped_ptr<TraceBuffer> logged_events,
+ std::unique_ptr<TraceBuffer> logged_events,
const OutputCallback& flush_output_callback,
const ArgumentFilterPredicate& argument_filter_predicate) {
if (flush_output_callback.is_null())
@@ -927,7 +927,7 @@
}
void TraceLog::FinishFlush(int generation, bool discard_events) {
- scoped_ptr<TraceBuffer> previous_logged_events;
+ std::unique_ptr<TraceBuffer> previous_logged_events;
OutputCallback flush_output_callback;
ArgumentFilterPredicate argument_filter_predicate;
@@ -1035,7 +1035,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
base::TimeTicks now = base::TimeTicks::Now();
@@ -1067,7 +1067,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
base::TimeTicks now = base::TimeTicks::Now();
@@ -1099,7 +1099,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
base::TimeTicks now = base::TimeTicks::Now();
return AddTraceEventWithThreadIdAndTimestamp(
@@ -1133,7 +1133,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
return AddTraceEventWithThreadIdAndTimestamp(
phase,
@@ -1165,7 +1165,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
TraceEventHandle handle = {0, 0, 0};
if (!*category_group_enabled)
@@ -1339,9 +1339,9 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags) {
- scoped_ptr<TraceEvent> trace_event(new TraceEvent);
+ std::unique_ptr<TraceEvent> trace_event(new TraceEvent);
int thread_id = static_cast<int>(base::PlatformThread::CurrentId());
ThreadTicks thread_now = ThreadNow();
TimeTicks now = OffsetNow();
diff --git a/base/trace_event/trace_log.h b/base/trace_event/trace_log.h
index 67477c4..3f09674 100644
--- a/base/trace_event/trace_log.h
+++ b/base/trace_event/trace_log.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/containers/hash_tables.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/trace_config.h"
@@ -191,7 +191,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
TraceEventHandle AddTraceEventWithBindId(
char phase,
@@ -204,7 +204,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
TraceEventHandle AddTraceEventWithProcessId(
char phase,
@@ -217,7 +217,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
TraceEventHandle AddTraceEventWithThreadIdAndTimestamp(
char phase,
@@ -231,7 +231,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
TraceEventHandle AddTraceEventWithThreadIdAndTimestamp(
char phase,
@@ -246,7 +246,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
// Adds a metadata event that will be written when the trace log is flushed.
@@ -257,7 +257,7 @@
const char** arg_names,
const unsigned char* arg_types,
const unsigned long long* arg_values,
- scoped_ptr<ConvertableToTraceFormat>* convertable_values,
+ std::unique_ptr<ConvertableToTraceFormat>* convertable_values,
unsigned int flags);
void UpdateTraceEventDuration(const unsigned char* category_group_enabled,
@@ -400,7 +400,7 @@
void FlushCurrentThread(int generation, bool discard_events);
// Usually it runs on a different thread.
static void ConvertTraceEventsToTraceFormat(
- scoped_ptr<TraceBuffer> logged_events,
+ std::unique_ptr<TraceBuffer> logged_events,
const TraceLog::OutputCallback& flush_output_callback,
const ArgumentFilterPredicate& argument_filter_predicate);
void FinishFlush(int generation, bool discard_events);
@@ -437,8 +437,8 @@
Lock thread_info_lock_;
Mode mode_;
int num_traces_recorded_;
- scoped_ptr<TraceBuffer> logged_events_;
- std::vector<scoped_ptr<TraceEvent>> metadata_events_;
+ std::unique_ptr<TraceBuffer> logged_events_;
+ std::vector<std::unique_ptr<TraceEvent>> metadata_events_;
subtle::AtomicWord /* EventCallback */ event_callback_;
bool dispatching_to_observer_list_;
std::vector<EnabledStateObserver*> enabled_state_observer_list_;
@@ -470,7 +470,7 @@
subtle::AtomicWord /* Options */ trace_options_;
// Sampling thread handles.
- scoped_ptr<TraceSamplingThread> sampling_thread_;
+ std::unique_ptr<TraceSamplingThread> sampling_thread_;
PlatformThreadHandle sampling_thread_handle_;
TraceConfig trace_config_;
@@ -487,7 +487,7 @@
// For events which can't be added into the thread local buffer, e.g. events
// from threads without a message loop.
- scoped_ptr<TraceBufferChunk> thread_shared_chunk_;
+ std::unique_ptr<TraceBufferChunk> thread_shared_chunk_;
size_t thread_shared_chunk_index_;
// Set when asynchronous Flush is in progress.
diff --git a/base/tracked_objects_unittest.cc b/base/tracked_objects_unittest.cc
index be86cbb..70d9601 100644
--- a/base/tracked_objects_unittest.cc
+++ b/base/tracked_objects_unittest.cc
@@ -9,7 +9,8 @@
#include <stddef.h>
#include <stdint.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/process/process_handle.h"
#include "base/time/time.h"
#include "base/tracking_info.h"
@@ -239,7 +240,7 @@
TEST_F(TrackedObjectsTest, DeathDataTestRecordDeath) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
- scoped_ptr<DeathData> data(new DeathData());
+ std::unique_ptr<DeathData> data(new DeathData());
ASSERT_NE(data, nullptr);
EXPECT_EQ(data->run_duration_sum(), 0);
EXPECT_EQ(data->run_duration_max(), 0);
@@ -278,7 +279,7 @@
TEST_F(TrackedObjectsTest, DeathDataTest2Phases) {
ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE);
- scoped_ptr<DeathData> data(new DeathData());
+ std::unique_ptr<DeathData> data(new DeathData());
ASSERT_NE(data, nullptr);
int32_t run_ms = 42;
diff --git a/base/values.cc b/base/values.cc
index 5a789e9..1b87498 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -13,6 +13,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/move.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -21,15 +22,15 @@
namespace {
-scoped_ptr<Value> CopyWithoutEmptyChildren(const Value& node);
+std::unique_ptr<Value> CopyWithoutEmptyChildren(const Value& node);
// Make a deep copy of |node|, but don't include empty lists or dictionaries
// in the copy. It's possible for this function to return NULL and it
// expects |node| to always be non-NULL.
-scoped_ptr<ListValue> CopyListWithoutEmptyChildren(const ListValue& list) {
- scoped_ptr<ListValue> copy;
+std::unique_ptr<ListValue> CopyListWithoutEmptyChildren(const ListValue& list) {
+ std::unique_ptr<ListValue> copy;
for (ListValue::const_iterator it = list.begin(); it != list.end(); ++it) {
- scoped_ptr<Value> child_copy = CopyWithoutEmptyChildren(**it);
+ std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(**it);
if (child_copy) {
if (!copy)
copy.reset(new ListValue);
@@ -39,11 +40,11 @@
return copy;
}
-scoped_ptr<DictionaryValue> CopyDictionaryWithoutEmptyChildren(
+std::unique_ptr<DictionaryValue> CopyDictionaryWithoutEmptyChildren(
const DictionaryValue& dict) {
- scoped_ptr<DictionaryValue> copy;
+ std::unique_ptr<DictionaryValue> copy;
for (DictionaryValue::Iterator it(dict); !it.IsAtEnd(); it.Advance()) {
- scoped_ptr<Value> child_copy = CopyWithoutEmptyChildren(it.value());
+ std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(it.value());
if (child_copy) {
if (!copy)
copy.reset(new DictionaryValue);
@@ -53,7 +54,7 @@
return copy;
}
-scoped_ptr<Value> CopyWithoutEmptyChildren(const Value& node) {
+std::unique_ptr<Value> CopyWithoutEmptyChildren(const Value& node) {
switch (node.GetType()) {
case Value::TYPE_LIST:
return CopyListWithoutEmptyChildren(static_cast<const ListValue&>(node));
@@ -89,8 +90,8 @@
}
// static
-scoped_ptr<Value> Value::CreateNullValue() {
- return make_scoped_ptr(new Value(TYPE_NULL));
+std::unique_ptr<Value> Value::CreateNullValue() {
+ return WrapUnique(new Value(TYPE_NULL));
}
bool Value::GetAsBinary(const BinaryValue** out_value) const {
@@ -144,8 +145,8 @@
return CreateNullValue().release();
}
-scoped_ptr<Value> Value::CreateDeepCopy() const {
- return make_scoped_ptr(DeepCopy());
+std::unique_ptr<Value> Value::CreateDeepCopy() const {
+ return WrapUnique(DeepCopy());
}
bool Value::Equals(const Value* other) const {
@@ -313,7 +314,7 @@
size_(0) {
}
-BinaryValue::BinaryValue(scoped_ptr<char[]> buffer, size_t size)
+BinaryValue::BinaryValue(std::unique_ptr<char[]> buffer, size_t size)
: Value(TYPE_BINARY), buffer_(std::move(buffer)), size_(size) {}
BinaryValue::~BinaryValue() {
@@ -324,7 +325,7 @@
size_t size) {
char* buffer_copy = new char[size];
memcpy(buffer_copy, buffer, size);
- scoped_ptr<char[]> scoped_buffer_copy(buffer_copy);
+ std::unique_ptr<char[]> scoped_buffer_copy(buffer_copy);
return new BinaryValue(std::move(scoped_buffer_copy), size);
}
@@ -350,11 +351,12 @@
///////////////////// DictionaryValue ////////////////////
// static
-scoped_ptr<DictionaryValue> DictionaryValue::From(scoped_ptr<Value> value) {
+std::unique_ptr<DictionaryValue> DictionaryValue::From(
+ std::unique_ptr<Value> value) {
DictionaryValue* out;
if (value && value->GetAsDictionary(&out)) {
ignore_result(value.release());
- return make_scoped_ptr(out);
+ return WrapUnique(out);
}
return nullptr;
}
@@ -396,7 +398,8 @@
dictionary_.clear();
}
-void DictionaryValue::Set(const std::string& path, scoped_ptr<Value> in_value) {
+void DictionaryValue::Set(const std::string& path,
+ std::unique_ptr<Value> in_value) {
DCHECK(IsStringUTF8(path));
DCHECK(in_value);
@@ -422,7 +425,7 @@
}
void DictionaryValue::Set(const std::string& path, Value* in_value) {
- Set(path, make_scoped_ptr(in_value));
+ Set(path, WrapUnique(in_value));
}
void DictionaryValue::SetBoolean(const std::string& path, bool in_value) {
@@ -448,7 +451,7 @@
}
void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value> in_value) {
+ std::unique_ptr<Value> in_value) {
Value* bare_ptr = in_value.release();
// If there's an existing value here, we need to delete it, because
// we own all our children.
@@ -463,7 +466,7 @@
void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
Value* in_value) {
- SetWithoutPathExpansion(key, make_scoped_ptr(in_value));
+ SetWithoutPathExpansion(key, WrapUnique(in_value));
}
void DictionaryValue::SetBooleanWithoutPathExpansion(
@@ -752,7 +755,7 @@
}
bool DictionaryValue::Remove(const std::string& path,
- scoped_ptr<Value>* out_value) {
+ std::unique_ptr<Value>* out_value) {
DCHECK(IsStringUTF8(path));
std::string current_path(path);
DictionaryValue* current_dictionary = this;
@@ -768,8 +771,9 @@
out_value);
}
-bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value>* out_value) {
+bool DictionaryValue::RemoveWithoutPathExpansion(
+ const std::string& key,
+ std::unique_ptr<Value>* out_value) {
DCHECK(IsStringUTF8(key));
ValueMap::iterator entry_iterator = dictionary_.find(key);
if (entry_iterator == dictionary_.end())
@@ -785,7 +789,7 @@
}
bool DictionaryValue::RemovePath(const std::string& path,
- scoped_ptr<Value>* out_value) {
+ std::unique_ptr<Value>* out_value) {
bool result = false;
size_t delimiter_position = path.find('.');
@@ -804,9 +808,10 @@
return result;
}
-scoped_ptr<DictionaryValue> DictionaryValue::DeepCopyWithoutEmptyChildren()
+std::unique_ptr<DictionaryValue> DictionaryValue::DeepCopyWithoutEmptyChildren()
const {
- scoped_ptr<DictionaryValue> copy = CopyDictionaryWithoutEmptyChildren(*this);
+ std::unique_ptr<DictionaryValue> copy =
+ CopyDictionaryWithoutEmptyChildren(*this);
if (!copy)
copy.reset(new DictionaryValue);
return copy;
@@ -853,8 +858,8 @@
return result;
}
-scoped_ptr<DictionaryValue> DictionaryValue::CreateDeepCopy() const {
- return make_scoped_ptr(DeepCopy());
+std::unique_ptr<DictionaryValue> DictionaryValue::CreateDeepCopy() const {
+ return WrapUnique(DeepCopy());
}
bool DictionaryValue::Equals(const Value* other) const {
@@ -882,11 +887,11 @@
///////////////////// ListValue ////////////////////
// static
-scoped_ptr<ListValue> ListValue::From(scoped_ptr<Value> value) {
+std::unique_ptr<ListValue> ListValue::From(std::unique_ptr<Value> value) {
ListValue* out;
if (value && value->GetAsList(&out)) {
ignore_result(value.release());
- return make_scoped_ptr(out);
+ return WrapUnique(out);
}
return nullptr;
}
@@ -921,7 +926,7 @@
return true;
}
-bool ListValue::Set(size_t index, scoped_ptr<Value> in_value) {
+bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) {
return Set(index, in_value.release());
}
@@ -1036,7 +1041,7 @@
const_cast<const ListValue**>(out_value));
}
-bool ListValue::Remove(size_t index, scoped_ptr<Value>* out_value) {
+bool ListValue::Remove(size_t index, std::unique_ptr<Value>* out_value) {
if (index >= list_.size())
return false;
@@ -1065,7 +1070,7 @@
}
ListValue::iterator ListValue::Erase(iterator iter,
- scoped_ptr<Value>* out_value) {
+ std::unique_ptr<Value>* out_value) {
if (out_value)
out_value->reset(*iter);
else
@@ -1074,7 +1079,7 @@
return list_.erase(iter);
}
-void ListValue::Append(scoped_ptr<Value> in_value) {
+void ListValue::Append(std::unique_ptr<Value> in_value) {
Append(in_value.release());
}
@@ -1167,8 +1172,8 @@
return result;
}
-scoped_ptr<ListValue> ListValue::CreateDeepCopy() const {
- return make_scoped_ptr(DeepCopy());
+std::unique_ptr<ListValue> ListValue::CreateDeepCopy() const {
+ return WrapUnique(DeepCopy());
}
bool ListValue::Equals(const Value* other) const {
diff --git a/base/values.h b/base/values.h
index 141ea93..e2506cc 100644
--- a/base/values.h
+++ b/base/values.h
@@ -22,6 +22,7 @@
#include <iosfwd>
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -29,7 +30,6 @@
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
@@ -66,7 +66,7 @@
virtual ~Value();
- static scoped_ptr<Value> CreateNullValue();
+ static std::unique_ptr<Value> CreateNullValue();
// Returns the type of the value stored by the current Value object.
// Each type will be implemented by only one subclass of Value, so it's
@@ -102,7 +102,7 @@
// this works because C++ supports covariant return types.
virtual Value* DeepCopy() const;
// Preferred version of DeepCopy. TODO(estade): remove the above.
- scoped_ptr<Value> CreateDeepCopy() const;
+ std::unique_ptr<Value> CreateDeepCopy() const;
// Compares if two Value objects have equal contents.
virtual bool Equals(const Value* other) const;
@@ -178,7 +178,7 @@
// Creates a BinaryValue, taking ownership of the bytes pointed to by
// |buffer|.
- BinaryValue(scoped_ptr<char[]> buffer, size_t size);
+ BinaryValue(std::unique_ptr<char[]> buffer, size_t size);
~BinaryValue() override;
@@ -199,7 +199,7 @@
bool Equals(const Value* other) const override;
private:
- scoped_ptr<char[]> buffer_;
+ std::unique_ptr<char[]> buffer_;
size_t size_;
DISALLOW_COPY_AND_ASSIGN(BinaryValue);
@@ -211,7 +211,7 @@
class BASE_EXPORT DictionaryValue : public Value {
public:
// Returns |value| if it is a dictionary, nullptr otherwise.
- static scoped_ptr<DictionaryValue> From(scoped_ptr<Value> value);
+ static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value);
DictionaryValue();
~DictionaryValue() override;
@@ -239,7 +239,7 @@
// If the key at any step of the way doesn't exist, or exists but isn't
// a DictionaryValue, a new DictionaryValue will be created and attached
// to the path in that location. |in_value| must be non-null.
- void Set(const std::string& path, scoped_ptr<Value> in_value);
+ void Set(const std::string& path, std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void Set(const std::string& path, Value* in_value);
@@ -254,7 +254,7 @@
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to
// be used as paths.
void SetWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value> in_value);
+ std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void SetWithoutPathExpansion(const std::string& key, Value* in_value);
@@ -329,21 +329,22 @@
// |out_value|. If |out_value| is NULL, the removed value will be deleted.
// This method returns true if |path| is a valid path; otherwise it will
// return false and the DictionaryValue object will be unchanged.
- virtual bool Remove(const std::string& path, scoped_ptr<Value>* out_value);
+ virtual bool Remove(const std::string& path,
+ std::unique_ptr<Value>* out_value);
// Like Remove(), but without special treatment of '.'. This allows e.g. URLs
// to be used as paths.
virtual bool RemoveWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value>* out_value);
+ std::unique_ptr<Value>* out_value);
// Removes a path, clearing out all dictionaries on |path| that remain empty
// after removing the value at |path|.
virtual bool RemovePath(const std::string& path,
- scoped_ptr<Value>* out_value);
+ std::unique_ptr<Value>* out_value);
// Makes a copy of |this| but doesn't include empty dictionaries and lists in
// the copy. This never returns NULL, even if |this| itself is empty.
- scoped_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
+ std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
// Merge |dictionary| into this dictionary. This is done recursively, i.e. any
// sub-dictionaries will be merged as well. In case of key collisions, the
@@ -377,7 +378,7 @@
// Overridden from Value:
DictionaryValue* DeepCopy() const override;
// Preferred version of DeepCopy. TODO(estade): remove the above.
- scoped_ptr<DictionaryValue> CreateDeepCopy() const;
+ std::unique_ptr<DictionaryValue> CreateDeepCopy() const;
bool Equals(const Value* other) const override;
private:
@@ -393,7 +394,7 @@
typedef ValueVector::const_iterator const_iterator;
// Returns |value| if it is a list, nullptr otherwise.
- static scoped_ptr<ListValue> From(scoped_ptr<Value> value);
+ static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value);
ListValue();
~ListValue() override;
@@ -414,7 +415,7 @@
// the value is a null pointer.
bool Set(size_t index, Value* in_value);
// Preferred version of the above. TODO(estade): remove the above.
- bool Set(size_t index, scoped_ptr<Value> in_value);
+ bool Set(size_t index, std::unique_ptr<Value> in_value);
// Gets the Value at the given index. Modifies |out_value| (and returns true)
// only if the index falls within the current list range.
@@ -446,7 +447,7 @@
// passed out via |out_value|. If |out_value| is NULL, the removed value will
// be deleted. This method returns true if |index| is valid; otherwise
// it will return false and the ListValue object will be unchanged.
- virtual bool Remove(size_t index, scoped_ptr<Value>* out_value);
+ virtual bool Remove(size_t index, std::unique_ptr<Value>* out_value);
// Removes the first instance of |value| found in the list, if any, and
// deletes it. |index| is the location where |value| was found. Returns false
@@ -457,10 +458,10 @@
// deleted, otherwise ownership of the value is passed back to the caller.
// Returns an iterator pointing to the location of the element that
// followed the erased element.
- iterator Erase(iterator iter, scoped_ptr<Value>* out_value);
+ iterator Erase(iterator iter, std::unique_ptr<Value>* out_value);
// Appends a Value to the end of the list.
- void Append(scoped_ptr<Value> in_value);
+ void Append(std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void Append(Value* in_value);
@@ -504,7 +505,7 @@
bool Equals(const Value* other) const override;
// Preferred version of DeepCopy. TODO(estade): remove DeepCopy.
- scoped_ptr<ListValue> CreateDeepCopy() const;
+ std::unique_ptr<ListValue> CreateDeepCopy() const;
private:
ValueVector list_;
@@ -533,8 +534,8 @@
// error_code will be set with the underlying error.
// If |error_message| is non-null, it will be filled in with a formatted
// error message including the location of the error if appropriate.
- virtual scoped_ptr<Value> Deserialize(int* error_code,
- std::string* error_str) = 0;
+ virtual std::unique_ptr<Value> Deserialize(int* error_code,
+ std::string* error_str) = 0;
};
// Stream operator so Values can be used in assertion statements. In order that
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 66453e0..ac78830 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/values.h"
+
#include <stddef.h>
#include <limits>
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -36,11 +38,11 @@
ASSERT_FALSE(
settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
- scoped_ptr<ListValue> new_toolbar_bookmarks(new ListValue);
+ std::unique_ptr<ListValue> new_toolbar_bookmarks(new ListValue);
settings.Set("global.toolbar.bookmarks", std::move(new_toolbar_bookmarks));
ASSERT_TRUE(settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
- scoped_ptr<DictionaryValue> new_bookmark(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> new_bookmark(new DictionaryValue);
new_bookmark->SetString("name", "Froogle");
new_bookmark->SetString("url", "http://froogle.com");
toolbar_bookmarks->Append(std::move(new_bookmark));
@@ -59,11 +61,11 @@
}
TEST(ValuesTest, List) {
- scoped_ptr<ListValue> mixed_list(new ListValue());
- mixed_list->Set(0, make_scoped_ptr(new FundamentalValue(true)));
- mixed_list->Set(1, make_scoped_ptr(new FundamentalValue(42)));
- mixed_list->Set(2, make_scoped_ptr(new FundamentalValue(88.8)));
- mixed_list->Set(3, make_scoped_ptr(new StringValue("foo")));
+ std::unique_ptr<ListValue> mixed_list(new ListValue());
+ mixed_list->Set(0, WrapUnique(new FundamentalValue(true)));
+ mixed_list->Set(1, WrapUnique(new FundamentalValue(42)));
+ mixed_list->Set(2, WrapUnique(new FundamentalValue(88.8)));
+ mixed_list->Set(3, WrapUnique(new StringValue("foo")));
ASSERT_EQ(4u, mixed_list->GetSize());
Value *value = NULL;
@@ -109,13 +111,13 @@
TEST(ValuesTest, BinaryValue) {
// Default constructor creates a BinaryValue with a null buffer and size 0.
- scoped_ptr<BinaryValue> binary(new BinaryValue());
+ std::unique_ptr<BinaryValue> binary(new BinaryValue());
ASSERT_TRUE(binary.get());
ASSERT_EQ(NULL, binary->GetBuffer());
ASSERT_EQ(0U, binary->GetSize());
// Test the common case of a non-empty buffer
- scoped_ptr<char[]> buffer(new char[15]);
+ std::unique_ptr<char[]> buffer(new char[15]);
char* original_buffer = buffer.get();
binary.reset(new BinaryValue(std::move(buffer), 15));
ASSERT_TRUE(binary.get());
@@ -141,10 +143,10 @@
TEST(ValuesTest, StringValue) {
// Test overloaded StringValue constructor.
- scoped_ptr<Value> narrow_value(new StringValue("narrow"));
+ std::unique_ptr<Value> narrow_value(new StringValue("narrow"));
ASSERT_TRUE(narrow_value.get());
ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING));
- scoped_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16")));
+ std::unique_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16")));
ASSERT_TRUE(utf16_value.get());
ASSERT_TRUE(utf16_value->IsType(Value::TYPE_STRING));
@@ -198,14 +200,14 @@
{
ListValue list;
- list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ list.Append(WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
}
EXPECT_TRUE(deletion_flag);
{
ListValue list;
- list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ list.Append(WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
list.Clear();
EXPECT_TRUE(deletion_flag);
@@ -213,7 +215,7 @@
{
ListValue list;
- list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ list.Append(WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(list.Set(0, Value::CreateNullValue()));
EXPECT_TRUE(deletion_flag);
@@ -222,11 +224,11 @@
TEST(ValuesTest, ListRemoval) {
bool deletion_flag = true;
- scoped_ptr<Value> removed_item;
+ std::unique_ptr<Value> removed_item;
{
ListValue list;
- list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ list.Append(WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_EQ(1U, list.GetSize());
EXPECT_FALSE(list.Remove(std::numeric_limits<size_t>::max(),
@@ -242,7 +244,7 @@
{
ListValue list;
- list.Append(make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ list.Append(WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(list.Remove(0, NULL));
EXPECT_TRUE(deletion_flag);
@@ -251,7 +253,8 @@
{
ListValue list;
- scoped_ptr<DeletionTestValue> value(new DeletionTestValue(&deletion_flag));
+ std::unique_ptr<DeletionTestValue> value(
+ new DeletionTestValue(&deletion_flag));
DeletionTestValue* original_value = value.get();
list.Append(std::move(value));
EXPECT_FALSE(deletion_flag);
@@ -269,14 +272,14 @@
{
DictionaryValue dict;
- dict.Set(key, make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ dict.Set(key, WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
}
EXPECT_TRUE(deletion_flag);
{
DictionaryValue dict;
- dict.Set(key, make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ dict.Set(key, WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
dict.Clear();
EXPECT_TRUE(deletion_flag);
@@ -284,7 +287,7 @@
{
DictionaryValue dict;
- dict.Set(key, make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ dict.Set(key, WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
dict.Set(key, Value::CreateNullValue());
EXPECT_TRUE(deletion_flag);
@@ -294,11 +297,11 @@
TEST(ValuesTest, DictionaryRemoval) {
std::string key = "test";
bool deletion_flag = true;
- scoped_ptr<Value> removed_item;
+ std::unique_ptr<Value> removed_item;
{
DictionaryValue dict;
- dict.Set(key, make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ dict.Set(key, WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(dict.HasKey(key));
EXPECT_FALSE(dict.Remove("absent key", &removed_item));
@@ -312,7 +315,7 @@
{
DictionaryValue dict;
- dict.Set(key, make_scoped_ptr(new DeletionTestValue(&deletion_flag)));
+ dict.Set(key, WrapUnique(new DeletionTestValue(&deletion_flag)));
EXPECT_FALSE(deletion_flag);
EXPECT_TRUE(dict.HasKey(key));
EXPECT_TRUE(dict.Remove(key, NULL));
@@ -372,7 +375,7 @@
dict.SetInteger("a.long.way.down", 1);
dict.SetBoolean("a.long.key.path", true);
- scoped_ptr<Value> removed_item;
+ std::unique_ptr<Value> removed_item;
EXPECT_TRUE(dict.RemovePath("a.long.way.down", &removed_item));
ASSERT_TRUE(removed_item);
EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_INTEGER));
@@ -394,49 +397,52 @@
TEST(ValuesTest, DeepCopy) {
DictionaryValue original_dict;
- scoped_ptr<Value> scoped_null = Value::CreateNullValue();
+ std::unique_ptr<Value> scoped_null = Value::CreateNullValue();
Value* original_null = scoped_null.get();
original_dict.Set("null", std::move(scoped_null));
- scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
+ std::unique_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
FundamentalValue* original_bool = scoped_bool.get();
original_dict.Set("bool", std::move(scoped_bool));
- scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
+ std::unique_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
FundamentalValue* original_int = scoped_int.get();
original_dict.Set("int", std::move(scoped_int));
- scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
+ std::unique_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
FundamentalValue* original_double = scoped_double.get();
original_dict.Set("double", std::move(scoped_double));
- scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
+ std::unique_ptr<StringValue> scoped_string(new StringValue("hello"));
StringValue* original_string = scoped_string.get();
original_dict.Set("string", std::move(scoped_string));
- scoped_ptr<StringValue> scoped_string16(
+ std::unique_ptr<StringValue> scoped_string16(
new StringValue(ASCIIToUTF16("hello16")));
StringValue* original_string16 = scoped_string16.get();
original_dict.Set("string16", std::move(scoped_string16));
- scoped_ptr<char[]> original_buffer(new char[42]);
+ std::unique_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
- scoped_ptr<BinaryValue> scoped_binary(
+ std::unique_ptr<BinaryValue> scoped_binary(
new BinaryValue(std::move(original_buffer), 42));
BinaryValue* original_binary = scoped_binary.get();
original_dict.Set("binary", std::move(scoped_binary));
- scoped_ptr<ListValue> scoped_list(new ListValue());
+ std::unique_ptr<ListValue> scoped_list(new ListValue());
Value* original_list = scoped_list.get();
- scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
+ std::unique_ptr<FundamentalValue> scoped_list_element_0(
+ new FundamentalValue(0));
Value* original_list_element_0 = scoped_list_element_0.get();
scoped_list->Append(std::move(scoped_list_element_0));
- scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
+ std::unique_ptr<FundamentalValue> scoped_list_element_1(
+ new FundamentalValue(1));
Value* original_list_element_1 = scoped_list_element_1.get();
scoped_list->Append(std::move(scoped_list_element_1));
original_dict.Set("list", std::move(scoped_list));
- scoped_ptr<DictionaryValue> scoped_nested_dictionary(new DictionaryValue());
+ std::unique_ptr<DictionaryValue> scoped_nested_dictionary(
+ new DictionaryValue());
Value* original_nested_dictionary = scoped_nested_dictionary.get();
scoped_nested_dictionary->SetString("key", "value");
original_dict.Set("dictionary", std::move(scoped_nested_dictionary));
- scoped_ptr<DictionaryValue> copy_dict = original_dict.CreateDeepCopy();
+ std::unique_ptr<DictionaryValue> copy_dict = original_dict.CreateDeepCopy();
ASSERT_TRUE(copy_dict.get());
ASSERT_NE(copy_dict.get(), &original_dict);
@@ -546,8 +552,8 @@
}
TEST(ValuesTest, Equals) {
- scoped_ptr<Value> null1(Value::CreateNullValue());
- scoped_ptr<Value> null2(Value::CreateNullValue());
+ std::unique_ptr<Value> null1(Value::CreateNullValue());
+ std::unique_ptr<Value> null2(Value::CreateNullValue());
EXPECT_NE(null1.get(), null2.get());
EXPECT_TRUE(null1->Equals(null2.get()));
@@ -562,21 +568,21 @@
dv.SetString("d2", ASCIIToUTF16("http://google.com"));
dv.Set("e", Value::CreateNullValue());
- scoped_ptr<DictionaryValue> copy = dv.CreateDeepCopy();
+ std::unique_ptr<DictionaryValue> copy = dv.CreateDeepCopy();
EXPECT_TRUE(dv.Equals(copy.get()));
- scoped_ptr<ListValue> list(new ListValue);
+ std::unique_ptr<ListValue> list(new ListValue);
ListValue* original_list = list.get();
list->Append(Value::CreateNullValue());
- list->Append(make_scoped_ptr(new DictionaryValue));
- scoped_ptr<Value> list_copy(list->CreateDeepCopy());
+ list->Append(WrapUnique(new DictionaryValue));
+ std::unique_ptr<Value> list_copy(list->CreateDeepCopy());
dv.Set("f", std::move(list));
EXPECT_FALSE(dv.Equals(copy.get()));
copy->Set("f", std::move(list_copy));
EXPECT_TRUE(dv.Equals(copy.get()));
- original_list->Append(make_scoped_ptr(new FundamentalValue(true)));
+ original_list->Append(WrapUnique(new FundamentalValue(true)));
EXPECT_FALSE(dv.Equals(copy.get()));
// Check if Equals detects differences in only the keys.
@@ -588,14 +594,14 @@
}
TEST(ValuesTest, StaticEquals) {
- scoped_ptr<Value> null1(Value::CreateNullValue());
- scoped_ptr<Value> null2(Value::CreateNullValue());
+ std::unique_ptr<Value> null1(Value::CreateNullValue());
+ std::unique_ptr<Value> null2(Value::CreateNullValue());
EXPECT_TRUE(Value::Equals(null1.get(), null2.get()));
EXPECT_TRUE(Value::Equals(NULL, NULL));
- scoped_ptr<Value> i42(new FundamentalValue(42));
- scoped_ptr<Value> j42(new FundamentalValue(42));
- scoped_ptr<Value> i17(new FundamentalValue(17));
+ std::unique_ptr<Value> i42(new FundamentalValue(42));
+ std::unique_ptr<Value> j42(new FundamentalValue(42));
+ std::unique_ptr<Value> i17(new FundamentalValue(17));
EXPECT_TRUE(Value::Equals(i42.get(), i42.get()));
EXPECT_TRUE(Value::Equals(j42.get(), i42.get()));
EXPECT_TRUE(Value::Equals(i42.get(), j42.get()));
@@ -612,50 +618,52 @@
TEST(ValuesTest, DeepCopyCovariantReturnTypes) {
DictionaryValue original_dict;
- scoped_ptr<Value> scoped_null(Value::CreateNullValue());
+ std::unique_ptr<Value> scoped_null(Value::CreateNullValue());
Value* original_null = scoped_null.get();
original_dict.Set("null", std::move(scoped_null));
- scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
+ std::unique_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
Value* original_bool = scoped_bool.get();
original_dict.Set("bool", std::move(scoped_bool));
- scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
+ std::unique_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
Value* original_int = scoped_int.get();
original_dict.Set("int", std::move(scoped_int));
- scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
+ std::unique_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
Value* original_double = scoped_double.get();
original_dict.Set("double", std::move(scoped_double));
- scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
+ std::unique_ptr<StringValue> scoped_string(new StringValue("hello"));
Value* original_string = scoped_string.get();
original_dict.Set("string", std::move(scoped_string));
- scoped_ptr<StringValue> scoped_string16(
+ std::unique_ptr<StringValue> scoped_string16(
new StringValue(ASCIIToUTF16("hello16")));
Value* original_string16 = scoped_string16.get();
original_dict.Set("string16", std::move(scoped_string16));
- scoped_ptr<char[]> original_buffer(new char[42]);
+ std::unique_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
- scoped_ptr<BinaryValue> scoped_binary(
+ std::unique_ptr<BinaryValue> scoped_binary(
new BinaryValue(std::move(original_buffer), 42));
Value* original_binary = scoped_binary.get();
original_dict.Set("binary", std::move(scoped_binary));
- scoped_ptr<ListValue> scoped_list(new ListValue());
+ std::unique_ptr<ListValue> scoped_list(new ListValue());
Value* original_list = scoped_list.get();
- scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
+ std::unique_ptr<FundamentalValue> scoped_list_element_0(
+ new FundamentalValue(0));
scoped_list->Append(std::move(scoped_list_element_0));
- scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
+ std::unique_ptr<FundamentalValue> scoped_list_element_1(
+ new FundamentalValue(1));
scoped_list->Append(std::move(scoped_list_element_1));
original_dict.Set("list", std::move(scoped_list));
- scoped_ptr<Value> copy_dict = original_dict.CreateDeepCopy();
- scoped_ptr<Value> copy_null = original_null->CreateDeepCopy();
- scoped_ptr<Value> copy_bool = original_bool->CreateDeepCopy();
- scoped_ptr<Value> copy_int = original_int->CreateDeepCopy();
- scoped_ptr<Value> copy_double = original_double->CreateDeepCopy();
- scoped_ptr<Value> copy_string = original_string->CreateDeepCopy();
- scoped_ptr<Value> copy_string16 = original_string16->CreateDeepCopy();
- scoped_ptr<Value> copy_binary = original_binary->CreateDeepCopy();
- scoped_ptr<Value> copy_list = original_list->CreateDeepCopy();
+ std::unique_ptr<Value> copy_dict = original_dict.CreateDeepCopy();
+ std::unique_ptr<Value> copy_null = original_null->CreateDeepCopy();
+ std::unique_ptr<Value> copy_bool = original_bool->CreateDeepCopy();
+ std::unique_ptr<Value> copy_int = original_int->CreateDeepCopy();
+ std::unique_ptr<Value> copy_double = original_double->CreateDeepCopy();
+ std::unique_ptr<Value> copy_string = original_string->CreateDeepCopy();
+ std::unique_ptr<Value> copy_string16 = original_string16->CreateDeepCopy();
+ std::unique_ptr<Value> copy_binary = original_binary->CreateDeepCopy();
+ std::unique_ptr<Value> copy_list = original_list->CreateDeepCopy();
EXPECT_TRUE(original_dict.Equals(copy_dict.get()));
EXPECT_TRUE(original_null->Equals(copy_null.get()));
@@ -669,18 +677,18 @@
}
TEST(ValuesTest, RemoveEmptyChildren) {
- scoped_ptr<DictionaryValue> root(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> root(new DictionaryValue);
// Remove empty lists and dictionaries.
- root->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
- root->Set("empty_list", make_scoped_ptr(new ListValue));
+ root->Set("empty_dict", WrapUnique(new DictionaryValue));
+ root->Set("empty_list", WrapUnique(new ListValue));
root->SetWithoutPathExpansion("a.b.c.d.e",
- make_scoped_ptr(new DictionaryValue));
+ WrapUnique(new DictionaryValue));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_TRUE(root->empty());
// Make sure we don't prune too much.
root->SetBoolean("bool", true);
- root->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
+ root->Set("empty_dict", WrapUnique(new DictionaryValue));
root->SetString("empty_string", std::string());
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
@@ -692,22 +700,22 @@
// Nested test cases. These should all reduce back to the bool and string
// set above.
{
- root->Set("a.b.c.d.e", make_scoped_ptr(new DictionaryValue));
+ root->Set("a.b.c.d.e", WrapUnique(new DictionaryValue));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
}
{
- scoped_ptr<DictionaryValue> inner(new DictionaryValue);
- inner->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
- inner->Set("empty_list", make_scoped_ptr(new ListValue));
+ std::unique_ptr<DictionaryValue> inner(new DictionaryValue);
+ inner->Set("empty_dict", WrapUnique(new DictionaryValue));
+ inner->Set("empty_list", WrapUnique(new ListValue));
root->Set("dict_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
}
{
- scoped_ptr<ListValue> inner(new ListValue);
- inner->Append(make_scoped_ptr(new DictionaryValue));
- inner->Append(make_scoped_ptr(new ListValue));
+ std::unique_ptr<ListValue> inner(new ListValue);
+ inner->Append(WrapUnique(new DictionaryValue));
+ inner->Append(WrapUnique(new ListValue));
root->Set("list_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
@@ -715,13 +723,13 @@
// Nested with siblings.
{
- scoped_ptr<ListValue> inner(new ListValue());
- inner->Append(make_scoped_ptr(new DictionaryValue));
- inner->Append(make_scoped_ptr(new ListValue));
+ std::unique_ptr<ListValue> inner(new ListValue());
+ inner->Append(WrapUnique(new DictionaryValue));
+ inner->Append(WrapUnique(new ListValue));
root->Set("list_with_empty_children", std::move(inner));
- scoped_ptr<DictionaryValue> inner2(new DictionaryValue);
- inner2->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
- inner2->Set("empty_list", make_scoped_ptr(new ListValue));
+ std::unique_ptr<DictionaryValue> inner2(new DictionaryValue);
+ inner2->Set("empty_dict", WrapUnique(new DictionaryValue));
+ inner2->Set("empty_list", WrapUnique(new ListValue));
root->Set("dict_with_empty_children", std::move(inner2));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
@@ -729,10 +737,10 @@
// Make sure nested values don't get pruned.
{
- scoped_ptr<ListValue> inner(new ListValue);
- scoped_ptr<ListValue> inner2(new ListValue);
- inner2->Append(make_scoped_ptr(new StringValue("hello")));
- inner->Append(make_scoped_ptr(new DictionaryValue));
+ std::unique_ptr<ListValue> inner(new ListValue);
+ std::unique_ptr<ListValue> inner2(new ListValue);
+ inner2->Append(WrapUnique(new StringValue("hello")));
+ inner->Append(WrapUnique(new DictionaryValue));
inner->Append(std::move(inner2));
root->Set("list_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
@@ -747,18 +755,18 @@
}
TEST(ValuesTest, MergeDictionary) {
- scoped_ptr<DictionaryValue> base(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> base(new DictionaryValue);
base->SetString("base_key", "base_key_value_base");
base->SetString("collide_key", "collide_key_value_base");
- scoped_ptr<DictionaryValue> base_sub_dict(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> base_sub_dict(new DictionaryValue);
base_sub_dict->SetString("sub_base_key", "sub_base_key_value_base");
base_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_base");
base->Set("sub_dict_key", std::move(base_sub_dict));
- scoped_ptr<DictionaryValue> merge(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> merge(new DictionaryValue);
merge->SetString("merge_key", "merge_key_value_merge");
merge->SetString("collide_key", "collide_key_value_merge");
- scoped_ptr<DictionaryValue> merge_sub_dict(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> merge_sub_dict(new DictionaryValue);
merge_sub_dict->SetString("sub_merge_key", "sub_merge_key_value_merge");
merge_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_merge");
merge->Set("sub_dict_key", std::move(merge_sub_dict));
@@ -792,7 +800,7 @@
}
TEST(ValuesTest, MergeDictionaryDeepCopy) {
- scoped_ptr<DictionaryValue> child(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> child(new DictionaryValue);
DictionaryValue* original_child = child.get();
child->SetString("test", "value");
EXPECT_EQ(1U, child->size());
@@ -801,7 +809,7 @@
EXPECT_TRUE(child->GetString("test", &value));
EXPECT_EQ("value", value);
- scoped_ptr<DictionaryValue> base(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> base(new DictionaryValue);
base->Set("dict", std::move(child));
EXPECT_EQ(1U, base->size());
@@ -809,7 +817,7 @@
EXPECT_TRUE(base->GetDictionary("dict", &ptr));
EXPECT_EQ(original_child, ptr);
- scoped_ptr<DictionaryValue> merged(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> merged(new DictionaryValue);
merged->MergeDictionary(base.get());
EXPECT_EQ(1U, merged->size());
EXPECT_TRUE(merged->GetDictionary("dict", &ptr));