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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "components/wifi/wifi_export.h" | 17 #include "components/wifi/wifi_export.h" |
17 | 18 |
18 namespace wifi { | 19 namespace wifi { |
19 | 20 |
20 // WiFiService interface used by implementation of chrome.networkingPrivate | 21 // WiFiService interface used by implementation of chrome.networkingPrivate |
21 // JavaScript extension API. All methods should be called on worker thread. | 22 // 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 // It could be created on any (including UI) thread, so nothing expensive should |
23 // be done in the constructor. | 24 // be done in the constructor. |
24 class WIFI_EXPORT WiFiService { | 25 class WIFI_EXPORT WiFiService { |
25 public: | 26 public: |
26 typedef std::vector<std::string> NetworkGuidList; | 27 typedef std::vector<std::string> NetworkGuidList; |
27 typedef base::Callback< | 28 typedef base::Callback< |
28 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; | 29 void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback; |
29 | 30 |
30 virtual ~WiFiService() {} | 31 virtual ~WiFiService() {} |
31 | 32 |
| 33 // Initialize WiFiService, store |task_runner| for posting worker tasks. |
| 34 virtual void Initialize( |
| 35 scoped_refptr<base::SequencedTaskRunner> task_runner) = 0; |
| 36 |
| 37 // UnInitialize WiFiService. |
| 38 virtual void UnInitialize() = 0; |
| 39 |
32 // Create instance of |WiFiService| for normal use. | 40 // Create instance of |WiFiService| for normal use. |
33 static WiFiService* Create(); | 41 static WiFiService* Create(); |
34 // Create instance of |WiFiService| for unit test use. | 42 // Create instance of |WiFiService| for unit test use. |
35 static WiFiService* CreateForTest(); | 43 static WiFiService* CreateForTest(); |
36 | 44 |
37 // Get Properties of network identified by |network_guid|. Populates | 45 // Get Properties of network identified by |network_guid|. Populates |
38 // |properties| on success, |error| on failure. | 46 // |properties| on success, |error| on failure. |
39 virtual void GetProperties(const std::string& network_guid, | 47 virtual void GetProperties(const std::string& network_guid, |
40 DictionaryValue* properties, | 48 DictionaryValue* properties, |
41 std::string* error) = 0; | 49 std::string* error) = 0; |
(...skipping 25 matching lines...) Expand all Loading... |
67 virtual void SetEventObservers( | 75 virtual void SetEventObservers( |
68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 76 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
69 const NetworkGuidListCallback& networks_changed_observer, | 77 const NetworkGuidListCallback& networks_changed_observer, |
70 const NetworkGuidListCallback& network_list_changed_observer) = 0; | 78 const NetworkGuidListCallback& network_list_changed_observer) = 0; |
71 | 79 |
72 protected: | 80 protected: |
73 WiFiService() {} | 81 WiFiService() {} |
74 | 82 |
75 typedef int32 Frequency; | 83 typedef int32 Frequency; |
76 enum FrequencyEnum { | 84 enum FrequencyEnum { |
| 85 kFrequencyAny = 0, |
77 kFrequencyUnknown = 0, | 86 kFrequencyUnknown = 0, |
78 kFrequency2400 = 2400, | 87 kFrequency2400 = 2400, |
79 kFrequency5000 = 5000 | 88 kFrequency5000 = 5000 |
80 }; | 89 }; |
81 | 90 |
82 typedef std::list<Frequency> FrequencyList; | 91 typedef std::list<Frequency> FrequencyList; |
83 // Network Properties, used as result of |GetProperties| and | 92 // Network Properties, used as result of |GetProperties| and |
84 // |GetVisibleNetworks|. | 93 // |GetVisibleNetworks|. |
85 struct WIFI_EXPORT NetworkProperties { | 94 struct WIFI_EXPORT NetworkProperties { |
86 NetworkProperties(); | 95 NetworkProperties(); |
(...skipping 23 matching lines...) Expand all Loading... |
110 | 119 |
111 typedef std::list<NetworkProperties> NetworkList; | 120 typedef std::list<NetworkProperties> NetworkList; |
112 | 121 |
113 private: | 122 private: |
114 DISALLOW_COPY_AND_ASSIGN(WiFiService); | 123 DISALLOW_COPY_AND_ASSIGN(WiFiService); |
115 }; | 124 }; |
116 | 125 |
117 } // namespace wifi | 126 } // namespace wifi |
118 | 127 |
119 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ | 128 #endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_ |
OLD | NEW |