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

Unified Diff: components/wifi/wifi_service.h

Issue 54323003: Base infrastructure for Networking Private API on Windows and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address code review comments. Created 7 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
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..cb7f6dbc4ad56b49478f56c6a9c769187ff3af66
--- /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
+// JavaScript extension API. All methods should be called on worker thread.
tbarzic 2013/11/19 00:05:44 Comment that it may be created on any (the UI) thr
mef 2013/11/19 17:37:03 Done.
+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.
tbarzic 2013/11/19 00:05:44 I'd move this after dtor
mef 2013/11/19 17:37:03 Done.
+ static WiFiService* Create();
+ // Create instance of |WiFiService| for unit test use.
+ static WiFiService* CreateForTest();
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698