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

Unified Diff: chromeos/network/network_sms_handler.h

Issue 12669004: Fix NetworkSmsHandler to observe Manager and improve API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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
« no previous file with comments | « chromeos/network/network_handler.cc ('k') | chromeos/network/network_sms_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_sms_handler.h
diff --git a/chromeos/network/network_sms_handler.h b/chromeos/network/network_sms_handler.h
index 5bbe09e8d1431e251eb445d16fd40fa1797e54d5..da4a10e735c5103e38e1515d8aec7c7de275fed2 100644
--- a/chromeos/network/network_sms_handler.h
+++ b/chromeos/network/network_sms_handler.h
@@ -10,14 +10,20 @@
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
-#include "base/values.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_method_call_status.h"
+#include "chromeos/dbus/shill_property_changed_observer.h"
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+class Value;
+}
namespace chromeos {
// Class to watch sms without Libcros.
-class CHROMEOS_EXPORT NetworkSmsHandler {
+class CHROMEOS_EXPORT NetworkSmsHandler : public ShillPropertyChangedObserver {
public:
static const char kNumberKey[];
static const char kTextKey[];
@@ -32,32 +38,51 @@ class CHROMEOS_EXPORT NetworkSmsHandler {
virtual void MessageReceived(const base::DictionaryValue& message) = 0;
};
- NetworkSmsHandler();
- ~NetworkSmsHandler();
-
- // Requests the devices from the netowork manager, sets up observers, and
- // requests the initial list of messages. Any observers that wish to be
- // notified with initial messages should be added before calling this.
- void Init();
+ virtual ~NetworkSmsHandler();
- // Requests an immediate check for new messages.
- void RequestUpdate();
+ // Requests an immediate check for new messages. If |request_existing| is
+ // true then also requests to be notified for any already received messages.
+ void RequestUpdate(bool request_existing);
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
+ // ShillPropertyChangedObserver
+ virtual void OnPropertyChanged(const std::string& name,
+ const base::Value& value) OVERRIDE;
+
private:
+ friend class NetworkHandler;
+ friend class NetworkSmsHandlerTest;
+
class NetworkSmsDeviceHandler;
class ModemManagerNetworkSmsDeviceHandler;
class ModemManager1NetworkSmsDeviceHandler;
- // Called from NetworkSmsDeviceHandler when a message is received.
+ NetworkSmsHandler();
+
+ // Requests the devices from the network manager, sets up observers, and
+ // requests the initial list of messages.
+ void Init();
+
+ // Adds |message| to the list of received messages. If the length of the
+ // list exceeds the maximum number of retained messages, erase the least
+ // recently received message.
+ void AddReceivedMessage(const base::DictionaryValue& message);
+
+ // Notify observers that |message| was received.
void NotifyMessageReceived(const base::DictionaryValue& message);
+ // Called from NetworkSmsDeviceHandler when a message is received.
+ void MessageReceived(const base::DictionaryValue& message);
+
// Callback to handle the manager properties with the list of devices.
void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
const base::DictionaryValue& properties);
+ // Requests properties for each entry in |devices|.
+ void UpdateDevices(const base::ListValue* devices);
+
// Callback to handle the device properties for |device_path|.
// A NetworkSmsDeviceHandler will be instantiated for each cellular device.
void DevicePropertiesCallback(const std::string& device_path,
@@ -66,6 +91,7 @@ class CHROMEOS_EXPORT NetworkSmsHandler {
ObserverList<Observer> observers_;
ScopedVector<NetworkSmsDeviceHandler> device_handlers_;
+ ScopedVector<base::DictionaryValue> received_messages_;
base::WeakPtrFactory<NetworkSmsHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkSmsHandler);
« no previous file with comments | « chromeos/network/network_handler.cc ('k') | chromeos/network/network_sms_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698