Chromium Code Reviews| Index: components/wifi/wifi_service.h |
| diff --git a/components/wifi/wifi_service.h b/components/wifi/wifi_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2c9c0f55140669aef88624888911aebf2c7b79d9 |
| --- /dev/null |
| +++ b/components/wifi/wifi_service.h |
| @@ -0,0 +1,115 @@ |
| +// 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 |
|
tbarzic
2013/11/15 22:56:30
Add a comment about threading restrictions
mef
2013/11/17 20:05:18
Done.
|
| +// JavaScript extension API. |
| +class WIFI_EXPORT WiFiService { |
| + public: |
| + typedef std::vector<std::string> NetworkGuidList; |
| + typedef base::Callback< |
| + void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; |
| + |
| + virtual ~WiFiService() {} |
| + |
| + // 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; |
| + |
| + // Create instance of |WiFiService| for normal use. |
| + static WiFiService* CreateService(); |
|
tbarzic
2013/11/15 22:56:30
I'd rename these two to
Create()
CreateForTest()
mef
2013/11/17 20:05:18
Done.
|
| + // Create instance of |WiFiService| for unit test use. |
| + static WiFiService* CreateServiceMock(); |
| + |
| + protected: |
| + WiFiService() {} |
| + |
| + typedef int32 Frequency; |
| + enum FrequencyEnum { |
| + kFrequencyUnknown = 0, |
| + kFrequency2400 = 2400, |
|
tbarzic
2013/11/15 22:56:30
fyi, cros implementation does not normalize the fr
mef
2013/11/17 20:05:18
Noted.
|
| + 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_ |