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/modem_messaging_client.h" | 4 #include "chromeos/dbus/modem_messaging_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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // org.freedesktop.ModemManager1.Messaging object. | 24 // org.freedesktop.ModemManager1.Messaging object. |
25 class ModemMessagingProxy { | 25 class ModemMessagingProxy { |
26 public: | 26 public: |
27 typedef ModemMessagingClient::SmsReceivedHandler SmsReceivedHandler; | 27 typedef ModemMessagingClient::SmsReceivedHandler SmsReceivedHandler; |
28 typedef ModemMessagingClient::ListCallback ListCallback; | 28 typedef ModemMessagingClient::ListCallback ListCallback; |
29 typedef ModemMessagingClient::DeleteCallback DeleteCallback; | 29 typedef ModemMessagingClient::DeleteCallback DeleteCallback; |
30 | 30 |
31 ModemMessagingProxy(dbus::Bus* bus, | 31 ModemMessagingProxy(dbus::Bus* bus, |
32 const std::string& service_name, | 32 const std::string& service_name, |
33 const dbus::ObjectPath& object_path) | 33 const dbus::ObjectPath& object_path) |
34 : bus_(bus), | 34 : proxy_(bus->GetObjectProxy(service_name, object_path)), |
35 proxy_(bus->GetObjectProxy(service_name, object_path)), | |
36 service_name_(service_name), | 35 service_name_(service_name), |
37 weak_ptr_factory_(this) { | 36 weak_ptr_factory_(this) { |
38 proxy_->ConnectToSignal( | 37 proxy_->ConnectToSignal( |
39 modemmanager::kModemManager1MessagingInterface, | 38 modemmanager::kModemManager1MessagingInterface, |
40 modemmanager::kSMSAddedSignal, | 39 modemmanager::kSMSAddedSignal, |
41 base::Bind(&ModemMessagingProxy::OnSmsAdded, | 40 base::Bind(&ModemMessagingProxy::OnSmsAdded, |
42 weak_ptr_factory_.GetWeakPtr()), | 41 weak_ptr_factory_.GetWeakPtr()), |
43 base::Bind(&ModemMessagingProxy::OnSignalConnected, | 42 base::Bind(&ModemMessagingProxy::OnSignalConnected, |
44 weak_ptr_factory_.GetWeakPtr())); | 43 weak_ptr_factory_.GetWeakPtr())); |
45 } | 44 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 113 } |
115 | 114 |
116 // Handles the result of signal connection setup. | 115 // Handles the result of signal connection setup. |
117 void OnSignalConnected(const std::string& interface, | 116 void OnSignalConnected(const std::string& interface, |
118 const std::string& signal, | 117 const std::string& signal, |
119 bool succeeded) { | 118 bool succeeded) { |
120 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " | 119 LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " " |
121 << signal << " failed."; | 120 << signal << " failed."; |
122 } | 121 } |
123 | 122 |
124 dbus::Bus* bus_; | |
125 dbus::ObjectProxy* proxy_; | 123 dbus::ObjectProxy* proxy_; |
126 std::string service_name_; | 124 std::string service_name_; |
127 SmsReceivedHandler sms_received_handler_; | 125 SmsReceivedHandler sms_received_handler_; |
128 | 126 |
129 // Note: This should remain the last member so it'll be destroyed and | 127 // Note: This should remain the last member so it'll be destroyed and |
130 // invalidate its weak pointers before any other members are destroyed. | 128 // invalidate its weak pointers before any other members are destroyed. |
131 base::WeakPtrFactory<ModemMessagingProxy> weak_ptr_factory_; | 129 base::WeakPtrFactory<ModemMessagingProxy> weak_ptr_factory_; |
132 | 130 |
133 DISALLOW_COPY_AND_ASSIGN(ModemMessagingProxy); | 131 DISALLOW_COPY_AND_ASSIGN(ModemMessagingProxy); |
134 }; | 132 }; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ModemMessagingClient::~ModemMessagingClient() {} | 205 ModemMessagingClient::~ModemMessagingClient() {} |
208 | 206 |
209 | 207 |
210 // static | 208 // static |
211 ModemMessagingClient* ModemMessagingClient::Create() { | 209 ModemMessagingClient* ModemMessagingClient::Create() { |
212 return new ModemMessagingClientImpl(); | 210 return new ModemMessagingClientImpl(); |
213 } | 211 } |
214 | 212 |
215 | 213 |
216 } // namespace chromeos | 214 } // namespace chromeos |
OLD | NEW |