Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: components/gcm_driver/instance_id/instance_id_driver.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/instance_id/instance_id_driver.cc
diff --git a/components/gcm_driver/instance_id/instance_id_driver.cc b/components/gcm_driver/instance_id/instance_id_driver.cc
index e671fef8c07ebcd70dff9b8225bd73ae5b0e6e84..140d5019efd1c92e9fb09fbf444aafea74a283cc 100644
--- a/components/gcm_driver/instance_id/instance_id_driver.cc
+++ b/components/gcm_driver/instance_id/instance_id_driver.cc
@@ -29,8 +29,7 @@ bool InstanceIDDriver::IsInstanceIDEnabled() {
}
InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver)
- : gcm_driver_(gcm_driver),
- instance_id_map_deleter_(&instance_id_map_) {
+ : gcm_driver_(gcm_driver) {
}
InstanceIDDriver::~InstanceIDDriver() {
@@ -41,17 +40,14 @@ InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) {
if (iter != instance_id_map_.end())
return iter->second;
- InstanceID* instance_id = InstanceID::Create(app_id, gcm_driver_);
- instance_id_map_[app_id] = instance_id;
- return instance_id;
+ scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, gcm_driver_);
+ InstanceID* instance_id_ptr = instance_id.get();
+ instance_id_map_.insert(app_id, instance_id.Pass());
+ return instance_id_ptr;
}
void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) {
- auto iter = instance_id_map_.find(app_id);
- if (iter == instance_id_map_.end())
- return;
- delete iter->second;
- instance_id_map_.erase(iter);
+ instance_id_map_.erase(app_id);
}
bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const {
« no previous file with comments | « components/gcm_driver/instance_id/instance_id_driver.h ('k') | components/gcm_driver/instance_id/instance_id_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698