summaryrefslogtreecommitdiffstats
path: root/base/containers
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2015-12-01 11:57:55 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 19:59:37 +0000
commitca21b9b2a1ddf5ffe2a81e1d9f991ea03d89a74a (patch)
tree92413d5427d2f610b3aa7cd7b5691f0a69d27a5e /base/containers
parentdad91f315c0631b8e7902049d820acec264a0c9b (diff)
downloadchromium_src-ca21b9b2a1ddf5ffe2a81e1d9f991ea03d89a74a.zip
chromium_src-ca21b9b2a1ddf5ffe2a81e1d9f991ea03d89a74a.tar.gz
chromium_src-ca21b9b2a1ddf5ffe2a81e1d9f991ea03d89a74a.tar.bz2
base: Make ScopedPtrMap use DISALLOW_COPY_AND_ASSIGN
Currently the class uses MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 which adds a .Pass() method and works for passing with Callback. But there are no users of this passing ownership in Callback, so switch to the general DISALLOW_COPY_AND_ASSIGN macro. R=Nico, zea@chromium.org BUG=557422, 554291 Review URL: https://codereview.chromium.org/1480773002 Cr-Commit-Position: refs/heads/master@{#362488}
Diffstat (limited to 'base/containers')
-rw-r--r--base/containers/scoped_ptr_map.h7
-rw-r--r--base/containers/scoped_ptr_map_unittest.cc28
2 files changed, 3 insertions, 32 deletions
diff --git a/base/containers/scoped_ptr_map.h b/base/containers/scoped_ptr_map.h
index 822cbfd..25538b9 100644
--- a/base/containers/scoped_ptr_map.h
+++ b/base/containers/scoped_ptr_map.h
@@ -10,8 +10,8 @@
#include <utility>
#include "base/basictypes.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-#include "base/move.h"
#include "base/stl_util.h"
namespace base {
@@ -27,10 +27,7 @@ namespace base {
// have support for moveable types inside containers).
template <class Key, class ScopedPtr, class Compare = std::less<Key>>
class ScopedPtrMap {
- MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(ScopedPtrMap)
-
using Container = std::map<Key, typename ScopedPtr::element_type*, Compare>;
-
public:
using allocator_type = typename Container::allocator_type;
using size_type = typename Container::size_type;
@@ -140,6 +137,8 @@ class ScopedPtrMap {
return data_.end();
return data_.find(it->first);
};
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedPtrMap);
};
} // namespace base
diff --git a/base/containers/scoped_ptr_map_unittest.cc b/base/containers/scoped_ptr_map_unittest.cc
index 6f867a9..f8a9779 100644
--- a/base/containers/scoped_ptr_map_unittest.cc
+++ b/base/containers/scoped_ptr_map_unittest.cc
@@ -232,34 +232,6 @@ TEST(ScopedPtrMapTest, MoveAssign) {
EXPECT_TRUE(destroyed);
}
-template <typename Key, typename ScopedPtr>
-ScopedPtrMap<Key, ScopedPtr> PassThru(ScopedPtrMap<Key, ScopedPtr> scoper) {
- return scoper;
-}
-
-TEST(ScopedPtrMapTest, Passed) {
- bool destroyed = false;
- ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> scoped_map;
- ScopedDestroyer* elem = new ScopedDestroyer(&destroyed);
- scoped_map.insert(0, make_scoped_ptr(elem));
- EXPECT_EQ(elem, scoped_map.find(0)->second);
- EXPECT_FALSE(destroyed);
-
- base::Callback<ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>>(void)>
- callback = base::Bind(&PassThru<int, scoped_ptr<ScopedDestroyer>>,
- base::Passed(&scoped_map));
- EXPECT_TRUE(scoped_map.empty());
- EXPECT_FALSE(destroyed);
-
- ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> result = callback.Run();
- EXPECT_TRUE(scoped_map.empty());
- EXPECT_EQ(elem, result.find(0)->second);
- EXPECT_FALSE(destroyed);
-
- result.clear();
- EXPECT_TRUE(destroyed);
-};
-
// Test that using a value type from a namespace containing an ignore_result
// function compiles correctly.
TEST(ScopedPtrMapTest, IgnoreResultCompile) {