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

Unified Diff: chromeos/dbus/gsm_sms_client.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: Fix Mac compile. 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: chromeos/dbus/gsm_sms_client.cc
diff --git a/chromeos/dbus/gsm_sms_client.cc b/chromeos/dbus/gsm_sms_client.cc
index b311554897ed19cc14a7de55ffef4c32d0c54c39..6c63b69bbdc449c81e20184092dbd85318acee2d 100644
--- a/chromeos/dbus/gsm_sms_client.cc
+++ b/chromeos/dbus/gsm_sms_client.cc
@@ -3,15 +3,14 @@
// found in the LICENSE file.
#include "chromeos/dbus/gsm_sms_client.h"
-#include <map>
#include <utility>
#include <vector>
#include "base/bind.h"
+#include "base/containers/scoped_ptr_map.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "dbus/bus.h"
@@ -162,7 +161,7 @@ class SMSProxy {
// The GsmSMSClient implementation.
class GsmSMSClientImpl : public GsmSMSClient {
public:
- GsmSMSClientImpl() : bus_(NULL), proxies_deleter_(&proxies_) {}
+ GsmSMSClientImpl() : bus_(NULL) {}
// GsmSMSClient override.
void SetSmsReceivedHandler(const std::string& service_name,
@@ -208,25 +207,26 @@ class GsmSMSClientImpl : public GsmSMSClient {
void Init(dbus::Bus* bus) override { bus_ = bus; }
private:
- typedef std::map<std::pair<std::string, std::string>, SMSProxy*> ProxyMap;
+ typedef ScopedPtrMap<std::pair<std::string, std::string>,
+ scoped_ptr<SMSProxy>> ProxyMap;
// Returns a SMSProxy for the given service name and object path.
SMSProxy* GetProxy(const std::string& service_name,
const dbus::ObjectPath& object_path) {
const ProxyMap::key_type key(service_name, object_path.value());
- ProxyMap::iterator it = proxies_.find(key);
+ ProxyMap::const_iterator it = proxies_.find(key);
if (it != proxies_.end())
return it->second;
stevenjb 2015/06/18 15:32:02 Does this compile? It seems like this would now re
Matt Giuca 2015/06/22 05:40:41 Missed this earlier. It actually returns a SMSPro
stevenjb 2015/06/23 17:01:03 For the record, "EW". I see now how ScopedPtrMap::
Matt Giuca 2015/06/24 05:21:34 Yeah, it can't really be solved until we get real
// There is no proxy for the service_name and object_path, create it.
- SMSProxy* proxy = new SMSProxy(bus_, service_name, object_path);
- proxies_.insert(ProxyMap::value_type(key, proxy));
- return proxy;
+ scoped_ptr<SMSProxy> proxy(new SMSProxy(bus_, service_name, object_path));
+ SMSProxy* proxy_ptr = proxy.get();
+ proxies_.insert(key, proxy.Pass());
+ return proxy_ptr;
}
dbus::Bus* bus_;
ProxyMap proxies_;
- STLValueDeleter<ProxyMap> proxies_deleter_;
DISALLOW_COPY_AND_ASSIGN(GsmSMSClientImpl);
};

Powered by Google App Engine
This is Rietveld 408576698