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

Unified Diff: chromeos/network/network_device_handler.h

Issue 11743006: Add NetworkDeviceHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fix Created 7 years, 11 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/chromeos.gyp ('k') | chromeos/network/network_device_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_device_handler.h
diff --git a/chromeos/network/network_device_handler.h b/chromeos/network/network_device_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..66109fce51005c97ab7df9d7bd433b3756cf8019
--- /dev/null
+++ b/chromeos/network/network_device_handler.h
@@ -0,0 +1,103 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_H_
+#define CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_H_
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/dbus_method_call_status.h"
+#include "chromeos/dbus/shill_property_changed_observer.h"
+#include "chromeos/network/network_util.h" // WifiAccessPoint
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+class Value;
+}
+
+namespace chromeos {
+
+class CHROMEOS_EXPORT NetworkDeviceHandler
+ : public ShillPropertyChangedObserver {
+ public:
+ struct Device {
+ Device();
+ ~Device();
+ std::string type;
+ bool powered;
+ bool scanning;
+ int scan_interval;
+ std::map<std::string, WifiAccessPoint> wifi_access_points;
+ };
+ typedef std::map<std::string, Device> DeviceMap;
+
+ class Observer {
+ public:
+ typedef NetworkDeviceHandler::DeviceMap DeviceMap;
+
+ // Called when devices are updated. Passes the updated map of devices.
+ virtual void NetworkDevicesUpdated(const DeviceMap& devices) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ NetworkDeviceHandler();
+ virtual ~NetworkDeviceHandler();
+ void Init();
+
+ // Add/remove observers.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ bool devices_ready() const { return devices_ready_; }
+ const DeviceMap& devices() const { return devices_; }
+
+ // ShillPropertyChangedObserver overrides
+ virtual void OnPropertyChanged(const std::string& key,
+ const base::Value& value) OVERRIDE;
+
+ private:
+ void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+ void DevicePropertyChanged(const base::ListValue* devices);
+ void DevicePropertiesCallback(const std::string& device_path,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+ void NetworkPropertiesCallback(const std::string& device_path,
+ const std::string& network_path,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+ void DeviceNetworkReady(const std::string& device_path,
+ const std::string& network_path);
+ void DeviceReady(const std::string& device_path);
+
+ // True when the device list is up to date.
+ bool devices_ready_;
+
+ // Map of Device structs, valid when |devices_ready_| is true.
+ DeviceMap devices_;
+
+ // Map of pending devices.
+ std::set<std::string> pending_device_paths_;
+
+ // Map of pending networks per device path.
+ std::map<std::string, std::set<std::string> > pending_network_paths_;
+
+ // Observer list
+ ObserverList<Observer> observers_;
+
+ // For Shill client callbacks
+ base::WeakPtrFactory<NetworkDeviceHandler> weak_ptr_factory_;
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_H_
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/network/network_device_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698