diff options
author | mgiuca <mgiuca@chromium.org> | 2015-06-25 02:11:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 09:12:36 +0000 |
commit | f59c7a8db11a9c5f5abbba3b0fb6f42059e4ce1d (patch) | |
tree | 14e40a99849a555756cc797491fdbbc48d04edda /sync/engine/directory_update_handler_unittest.cc | |
parent | 5ef49b8f224833077cfd2ef68bfaa6cb83a2d388 (diff) | |
download | chromium_src-f59c7a8db11a9c5f5abbba3b0fb6f42059e4ce1d.zip chromium_src-f59c7a8db11a9c5f5abbba3b0fb6f42059e4ce1d.tar.gz chromium_src-f59c7a8db11a9c5f5abbba3b0fb6f42059e4ce1d.tar.bz2 |
Update usages of std::map to use ScopedPtrMap.
Almost all code that uses a std::map + STLValueDeleter has been modified
to use a ScopedPtrMap. This makes pointer ownership much clearer, and
removes a lot of manual pointer deletion.
BUG=478594
Review URL: https://codereview.chromium.org/1096983002
Cr-Commit-Position: refs/heads/master@{#336096}
Diffstat (limited to 'sync/engine/directory_update_handler_unittest.cc')
-rw-r--r-- | sync/engine/directory_update_handler_unittest.cc | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/sync/engine/directory_update_handler_unittest.cc b/sync/engine/directory_update_handler_unittest.cc index 6623cdb..9579e93 100644 --- a/sync/engine/directory_update_handler_unittest.cc +++ b/sync/engine/directory_update_handler_unittest.cc @@ -5,8 +5,9 @@ #include "sync/engine/directory_update_handler.h" #include "base/compiler_specific.h" +#include "base/containers/scoped_ptr_map.h" +#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" -#include "base/stl_util.h" #include "sync/engine/syncer_proto_util.h" #include "sync/internal_api/public/base/attachment_id_proto.h" #include "sync/internal_api/public/base/model_type.h" @@ -456,27 +457,23 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test { passive_worker_(new FakeModelWorker(GROUP_PASSIVE)), bookmarks_emitter_(BOOKMARKS, &type_observers_), passwords_emitter_(PASSWORDS, &type_observers_), - articles_emitter_(ARTICLES, &type_observers_), - update_handler_map_deleter_(&update_handler_map_) {} + articles_emitter_(ARTICLES, &type_observers_) {} void SetUp() override { dir_maker_.SetUp(); entry_factory_.reset(new TestEntryFactory(directory())); - update_handler_map_.insert(std::make_pair( + update_handler_map_.insert( BOOKMARKS, - new DirectoryUpdateHandler(directory(), BOOKMARKS, - ui_worker_, &bookmarks_emitter_))); - update_handler_map_.insert(std::make_pair( + make_scoped_ptr(new DirectoryUpdateHandler( + directory(), BOOKMARKS, ui_worker_, &bookmarks_emitter_))); + update_handler_map_.insert( PASSWORDS, - new DirectoryUpdateHandler(directory(), - PASSWORDS, - password_worker_, - &passwords_emitter_))); - update_handler_map_.insert(std::make_pair( - ARTICLES, - new DirectoryUpdateHandler( - directory(), ARTICLES, ui_worker_, &articles_emitter_))); + make_scoped_ptr(new DirectoryUpdateHandler( + directory(), PASSWORDS, password_worker_, &passwords_emitter_))); + update_handler_map_.insert( + ARTICLES, make_scoped_ptr(new DirectoryUpdateHandler( + directory(), ARTICLES, ui_worker_, &articles_emitter_))); } void TearDown() override { dir_maker_.TearDown(); } @@ -495,15 +492,15 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test { protected: void ApplyBookmarkUpdates(sessions::StatusController* status) { - update_handler_map_[BOOKMARKS]->ApplyUpdates(status); + update_handler_map_.find(BOOKMARKS)->second->ApplyUpdates(status); } void ApplyPasswordUpdates(sessions::StatusController* status) { - update_handler_map_[PASSWORDS]->ApplyUpdates(status); + update_handler_map_.find(PASSWORDS)->second->ApplyUpdates(status); } void ApplyArticlesUpdates(sessions::StatusController* status) { - update_handler_map_[ARTICLES]->ApplyUpdates(status); + update_handler_map_.find(ARTICLES)->second->ApplyUpdates(status); } TestEntryFactory* entry_factory() { @@ -515,8 +512,6 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test { } private: - typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; - base::MessageLoop loop_; // Needed to initialize the directory. TestDirectorySetterUpper dir_maker_; scoped_ptr<TestEntryFactory> entry_factory_; @@ -530,8 +525,7 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test { DirectoryTypeDebugInfoEmitter passwords_emitter_; DirectoryTypeDebugInfoEmitter articles_emitter_; - UpdateHandlerMap update_handler_map_; - STLValueDeleter<UpdateHandlerMap> update_handler_map_deleter_; + base::ScopedPtrMap<ModelType, scoped_ptr<UpdateHandler>> update_handler_map_; }; namespace { |