diff options
-rw-r--r-- | base/containers/scoped_ptr_map.h | 7 | ||||
-rw-r--r-- | base/containers/scoped_ptr_map_unittest.cc | 28 | ||||
-rw-r--r-- | sync/engine/commit.cc | 8 |
3 files changed, 7 insertions, 36 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) { diff --git a/sync/engine/commit.cc b/sync/engine/commit.cc index 743996d..c089cc9 100644 --- a/sync/engine/commit.cc +++ b/sync/engine/commit.cc @@ -21,11 +21,10 @@ namespace syncer { Commit::Commit(ContributionMap contributions, const sync_pb::ClientToServerMessage& message, ExtensionsActivity::Records extensions_activity_buffer) - : contributions_(contributions.Pass()), + : contributions_(std::move(contributions)), message_(message), extensions_activity_buffer_(extensions_activity_buffer), - cleaned_up_(false) { -} + cleaned_up_(false) {} Commit::~Commit() { DCHECK(cleaned_up_); @@ -88,7 +87,8 @@ Commit* Commit::Init( } // If we made it this far, then we've successfully prepared a commit message. - return new Commit(contributions.Pass(), message, extensions_activity_buffer); + return new Commit(std::move(contributions), message, + extensions_activity_buffer); } SyncerError Commit::PostAndProcessResponse( |