| OLD | NEW |
| 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/sms_client.h" | 4 #include "chromeos/dbus/sms_client.h" |
| 5 | 5 |
| 6 #include <map> | 6 #include <map> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // DBusThreadManager instance. | 30 // DBusThreadManager instance. |
| 31 class SMSClientImpl : public SMSClient { | 31 class SMSClientImpl : public SMSClient { |
| 32 public: | 32 public: |
| 33 SMSClientImpl() : bus_(NULL), weak_ptr_factory_(this) {} | 33 SMSClientImpl() : bus_(NULL), weak_ptr_factory_(this) {} |
| 34 | 34 |
| 35 virtual ~SMSClientImpl() {} | 35 virtual ~SMSClientImpl() {} |
| 36 | 36 |
| 37 // Calls GetAll method. |callback| is called after the method call succeeds. | 37 // Calls GetAll method. |callback| is called after the method call succeeds. |
| 38 virtual void GetAll(const std::string& service_name, | 38 virtual void GetAll(const std::string& service_name, |
| 39 const dbus::ObjectPath& object_path, | 39 const dbus::ObjectPath& object_path, |
| 40 const GetAllCallback& callback) OVERRIDE { | 40 const GetAllCallback& callback) override { |
| 41 dbus::ObjectProxy *proxy = bus_->GetObjectProxy(service_name, object_path); | 41 dbus::ObjectProxy *proxy = bus_->GetObjectProxy(service_name, object_path); |
| 42 dbus::MethodCall method_call(dbus::kDBusPropertiesInterface, | 42 dbus::MethodCall method_call(dbus::kDBusPropertiesInterface, |
| 43 dbus::kDBusPropertiesGetAll); | 43 dbus::kDBusPropertiesGetAll); |
| 44 dbus::MessageWriter writer(&method_call); | 44 dbus::MessageWriter writer(&method_call); |
| 45 writer.AppendString(modemmanager::kModemManager1SmsInterface); | 45 writer.AppendString(modemmanager::kModemManager1SmsInterface); |
| 46 proxy->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 46 proxy->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 47 base::Bind(&SMSClientImpl::OnGetAll, | 47 base::Bind(&SMSClientImpl::OnGetAll, |
| 48 weak_ptr_factory_.GetWeakPtr(), | 48 weak_ptr_factory_.GetWeakPtr(), |
| 49 callback)); | 49 callback)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 virtual void Init(dbus::Bus* bus) OVERRIDE { | 53 virtual void Init(dbus::Bus* bus) override { |
| 54 bus_ = bus; | 54 bus_ = bus; |
| 55 } | 55 } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Handles responses of GetAll method calls. | 58 // Handles responses of GetAll method calls. |
| 59 void OnGetAll(const GetAllCallback& callback, dbus::Response* response) { | 59 void OnGetAll(const GetAllCallback& callback, dbus::Response* response) { |
| 60 if (!response) { | 60 if (!response) { |
| 61 // Must invoke the callback, even if there is no message. | 61 // Must invoke the callback, even if there is no message. |
| 62 base::DictionaryValue empty_dictionary; | 62 base::DictionaryValue empty_dictionary; |
| 63 callback.Run(empty_dictionary); | 63 callback.Run(empty_dictionary); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 93 | 93 |
| 94 SMSClient::~SMSClient() {} | 94 SMSClient::~SMSClient() {} |
| 95 | 95 |
| 96 | 96 |
| 97 // static | 97 // static |
| 98 SMSClient* SMSClient::Create() { | 98 SMSClient* SMSClient::Create() { |
| 99 return new SMSClientImpl(); | 99 return new SMSClientImpl(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace chromeos | 102 } // namespace chromeos |
| OLD | NEW |