summaryrefslogtreecommitdiffstats
path: root/components/wifi/wifi_service.h
diff options
context:
space:
mode:
authormef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 12:44:41 +0000
committermef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 12:44:41 +0000
commit1b6888ad29c5bc31fa3faff3aaa27008af1e7c4a (patch)
tree686154ebd3f55ad1a39fdcabfa342942b8d6c5c2 /components/wifi/wifi_service.h
parent1385954a60937c198519acc45c04242adb4123e5 (diff)
downloadchromium_src-1b6888ad29c5bc31fa3faff3aaa27008af1e7c4a.zip
chromium_src-1b6888ad29c5bc31fa3faff3aaa27008af1e7c4a.tar.gz
chromium_src-1b6888ad29c5bc31fa3faff3aaa27008af1e7c4a.tar.bz2
Base infrastructure for Networking Private API on Windows and Mac.
Based on https://codereview.chromium.org/22295002/, but moves WiFiService to components/ and runs it in browser process instead of utility process. Windows implementation is in http://crrev.com/68503019. BUG=267667 Review URL: https://codereview.chromium.org/54323003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/wifi/wifi_service.h')
-rw-r--r--components/wifi/wifi_service.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/components/wifi/wifi_service.h b/components/wifi/wifi_service.h
new file mode 100644
index 0000000..e29d936
--- /dev/null
+++ b/components/wifi/wifi_service.h
@@ -0,0 +1,119 @@
+// Copyright 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 CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
+#define CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "base/values.h"
+#include "components/wifi/wifi_export.h"
+
+namespace wifi {
+
+// WiFiService interface used by implementation of chrome.networkingPrivate
+// JavaScript extension API. All methods should be called on worker thread.
+// It could be created on any (including UI) thread, so nothing expensive should
+// be done in the constructor.
+class WIFI_EXPORT WiFiService {
+ public:
+ typedef std::vector<std::string> NetworkGuidList;
+ typedef base::Callback<
+ void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback;
+
+ virtual ~WiFiService() {}
+
+ // Create instance of |WiFiService| for normal use.
+ static WiFiService* Create();
+ // Create instance of |WiFiService| for unit test use.
+ static WiFiService* CreateForTest();
+
+ // Get Properties of network identified by |network_guid|. Populates
+ // |properties| on success, |error| on failure.
+ virtual void GetProperties(const std::string& network_guid,
+ DictionaryValue* properties,
+ std::string* error) = 0;
+
+ // Set Properties of network identified by |network_guid|. Populates |error|
+ // on failure.
+ virtual void SetProperties(const std::string& network_guid,
+ scoped_ptr<base::DictionaryValue> properties,
+ std::string* error) = 0;
+
+ // Get list of visible networks. Populates |network_list| on success.
+ virtual void GetVisibleNetworks(ListValue* network_list) = 0;
+
+ // Request network scan. Send |NetworkListChanged| event on completion.
+ virtual void RequestNetworkScan() = 0;
+
+ // Start connect to network identified by |network_guid|. Populates |error|
+ // on failure.
+ virtual void StartConnect(const std::string& network_guid,
+ std::string* error) = 0;
+
+ // Start disconnect from network identified by |network_guid|. Populates
+ // |error| on failure.
+ virtual void StartDisconnect(const std::string& network_guid,
+ std::string* error) = 0;
+
+ // Set observers to run when |NetworksChanged| and |NetworksListChanged|
+ // events needs to be sent. Notifications are posted on |message_loop_proxy|.
+ virtual void SetEventObservers(
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
+ const NetworkGuidListCallback& networks_changed_observer,
+ const NetworkGuidListCallback& network_list_changed_observer) = 0;
+
+ protected:
+ WiFiService() {}
+
+ typedef int32 Frequency;
+ enum FrequencyEnum {
+ kFrequencyUnknown = 0,
+ kFrequency2400 = 2400,
+ kFrequency5000 = 5000
+ };
+
+ typedef std::list<Frequency> FrequencyList;
+ // Network Properties, used as result of |GetProperties| and
+ // |GetVisibleNetworks|.
+ struct WIFI_EXPORT NetworkProperties {
+ NetworkProperties();
+ ~NetworkProperties();
+
+ std::string connection_state;
+ std::string guid;
+ std::string name;
+ std::string ssid;
+ std::string bssid;
+ std::string type;
+ std::string security;
+ // WiFi Signal Strength. 0..100
+ uint32 signal_strength;
+ bool auto_connect;
+ Frequency frequency;
+ FrequencyList frequency_list;
+
+ std::string json_extra; // Extra JSON properties for unit tests
+
+ scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const;
+ bool UpdateFromValue(const base::DictionaryValue& value);
+ static std::string MacAddressAsString(const uint8 mac_as_int[6]);
+ static bool OrderByType(const NetworkProperties& l,
+ const NetworkProperties& r);
+ };
+
+ typedef std::list<NetworkProperties> NetworkList;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WiFiService);
+};
+
+} // namespace wifi
+
+#endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_