summaryrefslogtreecommitdiffstats
path: root/chromeos/network/network_profile_handler.h
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 21:08:13 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 21:08:13 +0000
commit38c960262439b3618bf1169fd50a3cd768cadc32 (patch)
treeee3a28e95b2eaafc93d38983163f254e659872d3 /chromeos/network/network_profile_handler.h
parentba203410be684238da645b7f8be15ae2541dba04 (diff)
downloadchromium_src-38c960262439b3618bf1169fd50a3cd768cadc32.zip
chromium_src-38c960262439b3618bf1169fd50a3cd768cadc32.tar.gz
chromium_src-38c960262439b3618bf1169fd50a3cd768cadc32.tar.bz2
Adding a NetworkProfileHandler used by ManagedNetworkConfigurationHandler.
This handler tracks Shill's profiles. Currently only the ManagedNetworkConfigurationHandler is making use of this handler but it is also required for upcoming changes to proxy handling in ChromeOS. In the ONC validator only an LOG(ERROR) was fixed to LOG(WARNING) if the flag error_on_missing_field=false. BUG=157696 TEST=managed_network_configuration_handler_unittest.cc, networking_private_apitest.cc Review URL: https://chromiumcodereview.appspot.com/13957012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/network/network_profile_handler.h')
-rw-r--r--chromeos/network/network_profile_handler.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/chromeos/network/network_profile_handler.h b/chromeos/network/network_profile_handler.h
new file mode 100644
index 0000000..9dbc5d4
--- /dev/null
+++ b/chromeos/network/network_profile_handler.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2013 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_PROFILE_HANDLER_H_
+#define CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#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_profile.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace chromeos {
+
+class NetworkProfileObserver;
+
+class CHROMEOS_EXPORT NetworkProfileHandler
+ : public ShillPropertyChangedObserver {
+ public:
+ typedef std::vector<NetworkProfile> ProfileList;
+
+ // Initializes the singleton and registers it for DBus events.
+ static NetworkProfileHandler* Initialize();
+
+ // Returns if the singleton is initialized.
+ static bool IsInitialized();
+
+ // Unregisters the singleton from DBus events and destroys it.
+ static void Shutdown();
+
+ // Initialize() must be called before this.
+ static NetworkProfileHandler* Get();
+
+ void AddObserver(NetworkProfileObserver* observer);
+ void RemoveObserver(NetworkProfileObserver* observer);
+
+ void RequestInitialProfileList();
+ void GetManagerPropertiesCallback(DBusMethodCallStatus call_status,
+ const base::DictionaryValue& properties);
+
+ // ShillPropertyChangedObserver overrides
+ virtual void OnPropertyChanged(const std::string& name,
+ const base::Value& value) OVERRIDE;
+
+ void GetProfilePropertiesCallback(const std::string& profile_path,
+ const base::DictionaryValue& properties);
+
+ const NetworkProfile* GetProfileForPath(
+ const std::string& profile_path) const;
+ const NetworkProfile* GetProfileForUserhash(
+ const std::string& userhash) const;
+
+ protected:
+ // We make the de-/constructor protected to prevent their usage except in
+ // tests by deriving a stub (see NetworkProfileHandlerStub). Outside of tests,
+ // the singleton should be retrieved with the static Get() function.
+ NetworkProfileHandler();
+ virtual ~NetworkProfileHandler();
+
+ void AddProfile(const NetworkProfile& profile);
+ void RemoveProfile(const std::string& profile_path);
+
+ private:
+ ProfileList profiles_;
+ ObserverList<NetworkProfileObserver> observers_;
+
+ protected:
+ // For Shill client callbacks
+ base::WeakPtrFactory<NetworkProfileHandler> weak_ptr_factory_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NetworkProfileHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_NETWORK_NETWORK_PROFILE_HANDLER_H_