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

Unified Diff: chromeos/network/shill_property_handler.h

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fixes Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/network_state_handler_unittest.cc ('k') | chromeos/network/shill_property_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/shill_property_handler.h
diff --git a/chromeos/network/shill_property_handler.h b/chromeos/network/shill_property_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..81aec853531cd6d28345437eafe05845764025a6
--- /dev/null
+++ b/chromeos/network/shill_property_handler.h
@@ -0,0 +1,172 @@
+// 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_STATE_HANDLER_IMPL_H_
+#define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_IMPL_H_
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+
+#include "base/memory/weak_ptr.h"
+#include "chromeos/dbus/dbus_method_call_status.h"
+#include "chromeos/dbus/shill_property_changed_observer.h"
+#include "chromeos/network/managed_state.h"
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+class Value;
+}
+
+namespace chromeos {
+
+class ShillServiceObserver;
+class ShillManagerClient;
+
+namespace internal {
+
+// This class handles all Shill calls and observers for a Delegate (e.g.
+// NetworkStateHandler). It observes Shill.Manager and requests properties
+// for new devices/networks, calling Delegate methods to track them. It also
+// observes Shill.Service for all services in Shill.Manager.ServiceWatchList
+// and calls Delegate methods with updates.
+// This class must not outlive the ShillManagerClient instance.
+class CHROMEOS_EXPORT ShillPropertyHandler
pneubeck (no reviews) 2012/11/02 09:20:53 It looks odd to me that classes of the internal na
stevenjb 2012/11/02 17:17:14 Tests require it. 'internal' really just indicate
+ : public ShillPropertyChangedObserver {
+ public:
+ typedef std::map<std::string, ShillServiceObserver*> ShillServiceObserverMap;
+
+ class CHROMEOS_EXPORT Delegate {
pneubeck (no reviews) 2012/11/02 09:20:53 Wasn't ShillPropertyHandler the Delegate of Networ
stevenjb 2012/11/02 17:17:14 ShillPropertyHandler is wholly owned and exposed t
+ public:
+ // Called when the entries in a managed list have changed.
+ virtual void UpdateManagedList(ManagedState::ManagedType type,
+ const base::ListValue& entries) = 0;
+
+ // Called when the available technologies are set or have changed.
+ virtual void UpdateAvailableTechnologies(
+ const base::ListValue& technologies) = 0;
+
+ // Called when the enabled technologies are set or have changed.
+ virtual void UpdateEnabledTechnologies(
+ const base::ListValue& technologies) = 0;
+
+ // Called when the properties for a managed state have changed.
+ virtual void UpdateManagedStateProperties(
+ ManagedState::ManagedType type,
+ const std::string& path,
+ const base::DictionaryValue& properties) = 0;
+
+ // Called when a property for a watched network service has changed.
+ virtual void UpdateNetworkServiceProperty(
+ const std::string& service_path,
+ const std::string& key,
+ const base::Value& value) = 0;
+
+ // Called after updating a technology list.
+ virtual void ManagerPropertyChanged() = 0;
+
+ // Called whent the IP address of a service has been updated. Occurs after
+ // UpdateManagedStateProperties is called for the service.
+ virtual void UpdateNetworkServiceIPAddress(
+ const std::string& service_path,
+ const std::string& ip_address) = 0;
+
+ // Called when a managed state list has changed, after properties for any
+ // new entries in the list have been received and
+ // UpdateManagedStateProperties has been called for each new entry.
+ virtual void ManagedStateListChanged(ManagedState::ManagedType type) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
+ explicit ShillPropertyHandler(Delegate* delegate);
+ virtual ~ShillPropertyHandler();
+
+ // Sends an initial property request and sets up the observer.
+ void Init();
+
+ // Asynchronously sets the enabled state for |technology|.
+ // Note: Modifes Manager state. TODO(stevenjb): Add a completion callback.
+ void SetTechnologyEnabled(const std::string& technology, bool enabled);
+
+ // Requests an immediate network scan.
+ void RequestScan() const;
+
+ // Requests all properties for the service or device (called for new items).
+ void RequestProperties(ManagedState::ManagedType type,
+ const std::string& path);
+
+ // Requests the IP config specified by |ip_config_path| for |service_path|.
+ void RequestIPConfig(const std::string& service_path,
+ const std::string& ip_config_path);
+
+ bool IsObservingNetwork(const std::string& service_path) {
+ return observed_networks_.count(service_path) != 0;
+ }
+
+ // ShillPropertyChangedObserver overrides
+ virtual void OnPropertyChanged(const std::string& key,
+ const base::Value& value) OVERRIDE;
+
+ private:
+ // Callback for dbus method fetching properties.
+ void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+ // Called form OnPropertyChanged() and ManagerPropertiesCallback().
+ // Returns true if observers should be notified.
+ bool ManagerPropertyChanged(const std::string& key, const base::Value& value);
+
+ // Calls delegate_->UpdateManagedList and triggers ManagedStateListChanged if
+ // no new property requests have been made.
+ void UpdateManagedList(ManagedState::ManagedType type,
+ const base::ListValue& entries);
+
+ // Updates the Shill service property observers to observe any entries
+ // in the service watch list.
+ void UpdateObservedNetworkServices(const base::ListValue& entries);
+
+ // Called when Shill returns the properties for a service or device.
+ void GetPropertiesCallback(ManagedState::ManagedType type,
+ const std::string& path,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+
+ // Callback invoked when a watched service property changes. Calls
+ // network->PropertyChanged(key, value) and signals observers.
+ void NetworkServicePropertyChangedCallback(const std::string& path,
+ const std::string& key,
+ const base::Value& value);
+
+ // Callback for getting the IPConfig property of a Network. Handled here
+ // instead of in NetworkState so that all asynchronous requests are done
+ // in a single place (also simplifies NetworkState considerably).
+ void GetIPConfigCallback(const std::string& service_path,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+
+ // Pointer to containing class (owns this)
+ Delegate* delegate_;
+
+ // Convenience pointer for ShillManagerClient
+ ShillManagerClient* shill_manager_;
+
+ // Pending update count for each managed state type
+ std::map<ManagedState::ManagedType, int> pending_updates_;
+
+ // List of network services with Shill property changed observers
+ ShillServiceObserverMap observed_networks_;
+
+ // For Shill client callbacks
+ base::WeakPtrFactory<ShillPropertyHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandler);
+};
+
+} // namespace internal
+} // namespace chromeos
+
+#endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_IMPL_H_
« no previous file with comments | « chromeos/network/network_state_handler_unittest.cc ('k') | chromeos/network/shill_property_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698