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

Side by Side 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 joi's 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
6 #define CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
7
8 #include <list>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/values.h"
16 #include "components/wifi/wifi_export.h"
17
18 namespace wifi {
19
20 // WiFiService interface used by implementation of chrome.networkingPrivate
21 // JavaScript extension API. All methods should be called on worker thread.
22 // It could be created on any (including UI) thread, so nothing expensive should
23 // be done in the constructor.
24 class WIFI_EXPORT WiFiService {
25 public:
26 typedef std::vector<std::string> NetworkGuidList;
27 typedef base::Callback<
28 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback;
29
30 virtual ~WiFiService() {}
31
32 // Create instance of |WiFiService| for normal use.
33 static WiFiService* Create();
34 // Create instance of |WiFiService| for unit test use.
35 static WiFiService* CreateForTest();
36
37 // Get Properties of network identified by |network_guid|. Populates
38 // |properties| on success, |error| on failure.
39 virtual void GetProperties(const std::string& network_guid,
40 DictionaryValue* properties,
41 std::string* error) = 0;
42
43 // Set Properties of network identified by |network_guid|. Populates |error|
44 // on failure.
45 virtual void SetProperties(const std::string& network_guid,
46 scoped_ptr<base::DictionaryValue> properties,
47 std::string* error) = 0;
48
49 // Get list of visible networks. Populates |network_list| on success.
50 virtual void GetVisibleNetworks(ListValue* network_list) = 0;
51
52 // Request network scan. Send |NetworkListChanged| event on completion.
53 virtual void RequestNetworkScan() = 0;
54
55 // Start connect to network identified by |network_guid|. Populates |error|
56 // on failure.
57 virtual void StartConnect(const std::string& network_guid,
58 std::string* error) = 0;
59
60 // Start disconnect from network identified by |network_guid|. Populates
61 // |error| on failure.
62 virtual void StartDisconnect(const std::string& network_guid,
63 std::string* error) = 0;
64
65 // Set observers to run when |NetworksChanged| and |NetworksListChanged|
66 // events needs to be sent. Notifications are posted on |message_loop_proxy|.
67 virtual void SetEventObservers(
68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
69 const NetworkGuidListCallback& networks_changed_observer,
70 const NetworkGuidListCallback& network_list_changed_observer) = 0;
71
72 protected:
73 WiFiService() {}
74
75 typedef int32 Frequency;
76 enum FrequencyEnum {
77 kFrequencyUnknown = 0,
78 kFrequency2400 = 2400,
79 kFrequency5000 = 5000
80 };
81
82 typedef std::list<Frequency> FrequencyList;
83 // Network Properties, used as result of |GetProperties| and
84 // |GetVisibleNetworks|.
85 struct WIFI_EXPORT NetworkProperties {
86 NetworkProperties();
87 ~NetworkProperties();
88
89 std::string connection_state;
90 std::string guid;
91 std::string name;
92 std::string ssid;
93 std::string bssid;
94 std::string type;
95 std::string security;
96 // WiFi Signal Strength. 0..100
97 uint32 signal_strength;
98 bool auto_connect;
99 Frequency frequency;
100 FrequencyList frequency_list;
101
102 std::string json_extra; // Extra JSON properties for unit tests
103
104 scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const;
105 bool UpdateFromValue(const base::DictionaryValue& value);
106 static std::string MacAddressAsString(const uint8 mac_as_int[6]);
107 static bool OrderByType(const NetworkProperties& l,
108 const NetworkProperties& r);
109 };
110
111 typedef std::list<NetworkProperties> NetworkList;
112
113 private:
114 DISALLOW_COPY_AND_ASSIGN(WiFiService);
115 };
116
117 } // namespace wifi
118
119 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698