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

Side by Side Diff: components/wifi/wifi_service.h

Issue 64683014: Mac OS X-specific implementation of Networking Private API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address codereview comments. Created 6 years, 10 months 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
« no previous file with comments | « components/wifi/fake_wifi_service.cc ('k') | components/wifi/wifi_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ 5 #ifndef CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
6 #define CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ 6 #define CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "components/wifi/wifi_export.h" 18 #include "components/wifi/wifi_export.h"
18 19
19 namespace wifi { 20 namespace wifi {
20 21
21 // WiFiService interface used by implementation of chrome.networkingPrivate 22 // WiFiService interface used by implementation of chrome.networkingPrivate
22 // JavaScript extension API. All methods should be called on worker thread. 23 // JavaScript extension API. All methods should be called on worker thread.
23 // It could be created on any (including UI) thread, so nothing expensive should 24 // It could be created on any (including UI) thread, so nothing expensive should
24 // be done in the constructor. 25 // be done in the constructor. See |NetworkingPrivateService| for wrapper
26 // accessible on UI thread.
25 class WIFI_EXPORT WiFiService { 27 class WIFI_EXPORT WiFiService {
26 public: 28 public:
27 typedef std::vector<std::string> NetworkGuidList; 29 typedef std::vector<std::string> NetworkGuidList;
28 typedef base::Callback< 30 typedef base::Callback<
29 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; 31 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback;
30 32
31 virtual ~WiFiService() {} 33 virtual ~WiFiService() {}
32 34
33 // Initialize WiFiService, store |task_runner| for posting worker tasks. 35 // Initialize WiFiService, store |task_runner| for posting worker tasks.
34 virtual void Initialize( 36 virtual void Initialize(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void StartDisconnect(const std::string& network_guid, 100 virtual void StartDisconnect(const std::string& network_guid,
99 std::string* error) = 0; 101 std::string* error) = 0;
100 102
101 // Set observers to run when |NetworksChanged| and |NetworksListChanged| 103 // Set observers to run when |NetworksChanged| and |NetworksListChanged|
102 // events needs to be sent. Notifications are posted on |message_loop_proxy|. 104 // events needs to be sent. Notifications are posted on |message_loop_proxy|.
103 virtual void SetEventObservers( 105 virtual void SetEventObservers(
104 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 106 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
105 const NetworkGuidListCallback& networks_changed_observer, 107 const NetworkGuidListCallback& networks_changed_observer,
106 const NetworkGuidListCallback& network_list_changed_observer) = 0; 108 const NetworkGuidListCallback& network_list_changed_observer) = 0;
107 109
110 // Request update of Connected Network information. Send |NetworksChanged|
111 // event on completion.
112 virtual void RequestConnectedNetworkUpdate() = 0;
113
108 protected: 114 protected:
109 WiFiService() {} 115 WiFiService() {}
110 116
111 typedef int32 Frequency; 117 typedef int32 Frequency;
112 enum FrequencyEnum { 118 enum FrequencyEnum {
113 kFrequencyAny = 0, 119 kFrequencyAny = 0,
114 kFrequencyUnknown = 0, 120 kFrequencyUnknown = 0,
115 kFrequency2400 = 2400, 121 kFrequency2400 = 2400,
116 kFrequency5000 = 5000 122 kFrequency5000 = 5000
117 }; 123 };
118 124
119 typedef std::list<Frequency> FrequencyList; 125 typedef std::set<Frequency> FrequencySet;
120 // Network Properties, used as result of |GetProperties| and 126 // Network Properties, used as result of |GetProperties| and
121 // |GetVisibleNetworks|. 127 // |GetVisibleNetworks|.
122 struct WIFI_EXPORT NetworkProperties { 128 struct WIFI_EXPORT NetworkProperties {
123 NetworkProperties(); 129 NetworkProperties();
124 ~NetworkProperties(); 130 ~NetworkProperties();
125 131
126 std::string connection_state; 132 std::string connection_state;
127 std::string guid; 133 std::string guid;
128 std::string name; 134 std::string name;
129 std::string ssid; 135 std::string ssid;
130 std::string bssid; 136 std::string bssid;
131 std::string type; 137 std::string type;
132 std::string security; 138 std::string security;
133 // |password| field is used to pass wifi password for network creation via 139 // |password| field is used to pass wifi password for network creation via
134 // |CreateNetwork| or connection via |StartConnect|. It does not persist 140 // |CreateNetwork| or connection via |StartConnect|. It does not persist
135 // once operation is completed. 141 // once operation is completed.
136 std::string password; 142 std::string password;
137 // WiFi Signal Strength. 0..100 143 // WiFi Signal Strength. 0..100
138 uint32 signal_strength; 144 uint32 signal_strength;
139 bool auto_connect; 145 bool auto_connect;
140 Frequency frequency; 146 Frequency frequency;
141 FrequencyList frequency_list; 147 FrequencySet frequency_set;
142 148
143 std::string json_extra; // Extra JSON properties for unit tests 149 std::string json_extra; // Extra JSON properties for unit tests
144 150
145 scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const; 151 scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const;
146 // Updates only properties set in |value|. 152 // Updates only properties set in |value|.
147 bool UpdateFromValue(const base::DictionaryValue& value); 153 bool UpdateFromValue(const base::DictionaryValue& value);
148 static std::string MacAddressAsString(const uint8 mac_as_int[6]); 154 static std::string MacAddressAsString(const uint8 mac_as_int[6]);
149 static bool OrderByType(const NetworkProperties& l, 155 static bool OrderByType(const NetworkProperties& l,
150 const NetworkProperties& r); 156 const NetworkProperties& r);
151 }; 157 };
152 158
153 typedef std::list<NetworkProperties> NetworkList; 159 typedef std::list<NetworkProperties> NetworkList;
154 160
155 private: 161 private:
156 DISALLOW_COPY_AND_ASSIGN(WiFiService); 162 DISALLOW_COPY_AND_ASSIGN(WiFiService);
157 }; 163 };
158 164
159 } // namespace wifi 165 } // namespace wifi
160 166
161 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ 167 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
OLDNEW
« no previous file with comments | « components/wifi/fake_wifi_service.cc ('k') | components/wifi/wifi_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698