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

Side by Side Diff: chromeos/dbus/gsm_sms_client.cc

Issue 1454773002: Play better with C++11 library features from /chromeos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | chromeos/dbus/modem_messaging_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "chromeos/dbus/gsm_sms_client.h" 4 #include "chromeos/dbus/gsm_sms_client.h"
5 5
6 #include <map>
6 #include <utility> 7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/containers/scoped_ptr_map.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "dbus/bus.h" 16 #include "dbus/bus.h"
17 #include "dbus/message.h" 17 #include "dbus/message.h"
18 #include "dbus/object_proxy.h" 18 #include "dbus/object_proxy.h"
19 #include "dbus/values_util.h" 19 #include "dbus/values_util.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 // GsmSMSClient override. 202 // GsmSMSClient override.
203 void RequestUpdate(const std::string& service_name, 203 void RequestUpdate(const std::string& service_name,
204 const dbus::ObjectPath& object_path) override {} 204 const dbus::ObjectPath& object_path) override {}
205 205
206 protected: 206 protected:
207 void Init(dbus::Bus* bus) override { bus_ = bus; } 207 void Init(dbus::Bus* bus) override { bus_ = bus; }
208 208
209 private: 209 private:
210 typedef base::ScopedPtrMap<std::pair<std::string, std::string>, 210 using ProxyMap =
211 scoped_ptr<SMSProxy>> ProxyMap; 211 std::map<std::pair<std::string, std::string>, scoped_ptr<SMSProxy>>;
212 212
213 // Returns a SMSProxy for the given service name and object path. 213 // Returns a SMSProxy for the given service name and object path.
214 SMSProxy* GetProxy(const std::string& service_name, 214 SMSProxy* GetProxy(const std::string& service_name,
215 const dbus::ObjectPath& object_path) { 215 const dbus::ObjectPath& object_path) {
216 const ProxyMap::key_type key(service_name, object_path.value()); 216 const ProxyMap::key_type key(service_name, object_path.value());
217 ProxyMap::const_iterator it = proxies_.find(key); 217 ProxyMap::const_iterator it = proxies_.find(key);
218 if (it != proxies_.end()) 218 if (it != proxies_.end())
219 return it->second; 219 return it->second.get();
220 220
221 // There is no proxy for the service_name and object_path, create it. 221 // There is no proxy for the service_name and object_path, create it.
222 scoped_ptr<SMSProxy> proxy(new SMSProxy(bus_, service_name, object_path)); 222 scoped_ptr<SMSProxy> proxy(new SMSProxy(bus_, service_name, object_path));
223 SMSProxy* proxy_ptr = proxy.get(); 223 SMSProxy* proxy_ptr = proxy.get();
224 proxies_.insert(key, proxy.Pass()); 224 proxies_[key] = std::move(proxy);
225 return proxy_ptr; 225 return proxy_ptr;
226 } 226 }
227 227
228 dbus::Bus* bus_; 228 dbus::Bus* bus_;
229 ProxyMap proxies_; 229 ProxyMap proxies_;
230 230
231 DISALLOW_COPY_AND_ASSIGN(GsmSMSClientImpl); 231 DISALLOW_COPY_AND_ASSIGN(GsmSMSClientImpl);
232 }; 232 };
233 233
234 } // namespace 234 } // namespace
235 235
236 //////////////////////////////////////////////////////////////////////////////// 236 ////////////////////////////////////////////////////////////////////////////////
237 // GsmSMSClient 237 // GsmSMSClient
238 238
239 GsmSMSClient::GsmSMSClient() {} 239 GsmSMSClient::GsmSMSClient() {}
240 240
241 GsmSMSClient::~GsmSMSClient() {} 241 GsmSMSClient::~GsmSMSClient() {}
242 242
243 // static 243 // static
244 GsmSMSClient* GsmSMSClient::Create() { 244 GsmSMSClient* GsmSMSClient::Create() {
245 return new GsmSMSClientImpl(); 245 return new GsmSMSClientImpl();
246 } 246 }
247 247
248 } // namespace chromeos 248 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/modem_messaging_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698