| OLD | NEW |
| 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 or. |
| 24 // posted to worker pool using SequencedTaskRunner |task_runner_|. |
| 23 // It could be created on any (including UI) thread, so nothing expensive should | 25 // It could be created on any (including UI) thread, so nothing expensive should |
| 24 // be done in the constructor. | 26 // be done in the constructor. See |NetworkingPrivateService| for wrapper |
| 27 // accessible on UI thread. |
| 25 class WIFI_EXPORT WiFiService { | 28 class WIFI_EXPORT WiFiService { |
| 26 public: | 29 public: |
| 27 typedef std::vector<std::string> NetworkGuidList; | 30 typedef std::vector<std::string> NetworkGuidList; |
| 28 typedef base::Callback< | 31 typedef base::Callback< |
| 29 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; | 32 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; |
| 30 | 33 |
| 31 virtual ~WiFiService() {} | 34 virtual ~WiFiService() {} |
| 32 | 35 |
| 33 // Initialize WiFiService, store |task_runner| for posting worker tasks. | 36 // Initialize WiFiService, store |task_runner| for posting worker tasks. |
| 34 virtual void Initialize( | 37 virtual void Initialize( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 WiFiService() {} | 112 WiFiService() {} |
| 110 | 113 |
| 111 typedef int32 Frequency; | 114 typedef int32 Frequency; |
| 112 enum FrequencyEnum { | 115 enum FrequencyEnum { |
| 113 kFrequencyAny = 0, | 116 kFrequencyAny = 0, |
| 114 kFrequencyUnknown = 0, | 117 kFrequencyUnknown = 0, |
| 115 kFrequency2400 = 2400, | 118 kFrequency2400 = 2400, |
| 116 kFrequency5000 = 5000 | 119 kFrequency5000 = 5000 |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 typedef std::list<Frequency> FrequencyList; | 122 typedef std::set<Frequency> FrequencySet; |
| 120 // Network Properties, used as result of |GetProperties| and | 123 // Network Properties, used as result of |GetProperties| and |
| 121 // |GetVisibleNetworks|. | 124 // |GetVisibleNetworks|. |
| 122 struct WIFI_EXPORT NetworkProperties { | 125 struct WIFI_EXPORT NetworkProperties { |
| 123 NetworkProperties(); | 126 NetworkProperties(); |
| 124 ~NetworkProperties(); | 127 ~NetworkProperties(); |
| 125 | 128 |
| 126 std::string connection_state; | 129 std::string connection_state; |
| 127 std::string guid; | 130 std::string guid; |
| 128 std::string name; | 131 std::string name; |
| 129 std::string ssid; | 132 std::string ssid; |
| 130 std::string bssid; | 133 std::string bssid; |
| 131 std::string type; | 134 std::string type; |
| 132 std::string security; | 135 std::string security; |
| 133 // |password| field is used to pass wifi password for network creation via | 136 // |password| field is used to pass wifi password for network creation via |
| 134 // |CreateNetwork| or connection via |StartConnect|. It does not persist | 137 // |CreateNetwork| or connection via |StartConnect|. It does not persist |
| 135 // once operation is completed. | 138 // once operation is completed. |
| 136 std::string password; | 139 std::string password; |
| 137 // WiFi Signal Strength. 0..100 | 140 // WiFi Signal Strength. 0..100 |
| 138 uint32 signal_strength; | 141 uint32 signal_strength; |
| 139 bool auto_connect; | 142 bool auto_connect; |
| 140 Frequency frequency; | 143 Frequency frequency; |
| 141 FrequencyList frequency_list; | 144 FrequencySet frequency_set; |
| 142 | 145 |
| 143 std::string json_extra; // Extra JSON properties for unit tests | 146 std::string json_extra; // Extra JSON properties for unit tests |
| 144 | 147 |
| 145 scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const; | 148 scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const; |
| 146 // Updates only properties set in |value|. | 149 // Updates only properties set in |value|. |
| 147 bool UpdateFromValue(const base::DictionaryValue& value); | 150 bool UpdateFromValue(const base::DictionaryValue& value); |
| 148 static std::string MacAddressAsString(const uint8 mac_as_int[6]); | 151 static std::string MacAddressAsString(const uint8 mac_as_int[6]); |
| 149 static bool OrderByType(const NetworkProperties& l, | 152 static bool OrderByType(const NetworkProperties& l, |
| 150 const NetworkProperties& r); | 153 const NetworkProperties& r); |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 typedef std::list<NetworkProperties> NetworkList; | 156 typedef std::list<NetworkProperties> NetworkList; |
| 154 | 157 |
| 155 private: | 158 private: |
| 156 DISALLOW_COPY_AND_ASSIGN(WiFiService); | 159 DISALLOW_COPY_AND_ASSIGN(WiFiService); |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 } // namespace wifi | 162 } // namespace wifi |
| 160 | 163 |
| 161 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ | 164 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ |
| OLD | NEW |