OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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_NETWORKING_PRIVATE_HANDLER_H_ | |
6 #define CHROME_UTILITY_NETWORKING_PRIVATE_HANDLER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "chrome/utility/utility_message_handler.h" | |
15 #include "chrome/utility/wifi/wifi_service.h" | |
16 | |
17 namespace base { | |
18 class DictionaryValue; | |
19 class Thread; | |
20 } | |
21 | |
22 using wifi::WiFiService; | |
23 | |
24 namespace chrome { | |
25 | |
26 // Dispatches IPCs for out of process networkingPrivate API calls. | |
27 class NetworkingPrivateHandler : public UtilityMessageHandler { | |
28 public: | |
29 NetworkingPrivateHandler(); | |
30 virtual ~NetworkingPrivateHandler(); | |
31 | |
32 // IPC::Listener: | |
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
34 // Send IPC message from UtilityThread. | |
35 static bool Send(IPC::Message* message); | |
36 | |
37 private: | |
38 // IPC Message Handlers. | |
39 | |
40 // Use WiFiServiceMock with |parameters| for unit testing. | |
41 void OnUseWiFiServiceMockForTest(const base::DictionaryValue& parameters); | |
42 | |
43 // Common callback from WiFiService when error with |error_name| occurs. | |
44 // Sends |NetworkingPrivateMsg_API_Error| back to browser process. | |
45 // |message_id| is used to by NetworkingPrivateProcessClient to find matching | |
46 // request. | |
47 void OnApiError(int message_id, | |
48 const std::string& error_name, | |
49 scoped_ptr<base::DictionaryValue> error_data); | |
50 | |
51 // Get properties of network identified by |network_guid|. | |
52 void OnGetPropertiesStart(int message_id, const std::string& network_guid); | |
53 | |
54 // Callback from |WiFiService| to send |properties| back to browser process. | |
55 void OnGetPropertiesSucceeded( | |
cbentzel
2013/10/21 21:07:16
Nit: Some of the naming is a little confusing - yo
mef
2013/10/21 23:29:16
Done.
| |
56 int message_id, | |
57 const std::string& network_guid, | |
58 const WiFiService::NetworkProperties& properties); | |
59 | |
60 // Set properties of network identified by |network_guid|. | |
61 void OnSetPropertiesStart(int message_id, | |
62 const std::string& network_guid, | |
63 const base::DictionaryValue& properties); | |
64 | |
65 // Callback from |WiFiService| to report set properties success back to | |
66 // browser process. | |
67 void OnSetPropertiesSucceeded(int message_id, | |
68 const std::string& network_guid); | |
69 | |
70 // Start connect to network identified by |network_guid|. Does not wait for | |
71 // connect to succeed. If another network is connected, it will be remembered | |
72 // and disconnected prior to connect. | |
73 void OnStartConnectStart(int message_id, const std::string& network_guid); | |
74 | |
75 // Callback from |WiFiService| to report start connect success back to | |
76 // browser process. Does not wait for connect to actually succeed. If/When | |
77 // connect succeeds the |NetworksChanged| event will be generated. | |
78 void OnStartConnectSucceeded(int message_id, const std::string& network_guid); | |
79 | |
80 // Start disconnect from network identified by |network_guid|. Does not wait | |
81 // for disconnect to succeed. | |
82 void OnStartDisconnectStart(int message_id, const std::string& network_guid); | |
83 | |
84 // Callback from |WiFiService| to report start disconnect success back to | |
85 // browser process. Does not wait for disconnect to actually succeed. If/When | |
86 // disconnect succeeds the |NetworksChanged| event will be generated. | |
87 void OnStartDisconnectSucceeded(int message_id, | |
88 const std::string& network_guid); | |
89 | |
90 // Request network scan. Does not wait for scan to complete. | |
91 void OnRequestNetworkScan(); | |
92 | |
93 // Callback from |WiFiService| to report that network scan has succeded. | |
94 // Generates |NetworkListChanged| event based on current |network_list|. | |
95 void OnNetworkScanSucceeded(const WiFiService::NetworkList& network_list); | |
96 | |
97 // Get current list of visible networks. | |
98 void OnGetVisibleNetworks(int message_id); | |
99 | |
100 // Callback from |WiFiService| to report list of visible networks. | |
101 void OnGetVisibleNetworksSucceeded( | |
102 int message_id, | |
103 const WiFiService::NetworkList& network_list); | |
104 | |
105 // Send |NetworkListChanged| event with |network_guid_list|. | |
106 void OnNetworkListChangedEvent( | |
107 const WiFiService::NetworkGuidList& network_guid_list); | |
108 | |
109 // Send |NetworksChanged| event with |network_guid_list|. | |
110 void OnNetworksChangedEvent( | |
111 const WiFiService::NetworkGuidList& network_guid_list); | |
112 | |
113 // Platform-specific WiFi service. | |
114 scoped_ptr<wifi::WiFiService> wifi_service_; | |
115 | |
116 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateHandler); | |
117 }; | |
118 | |
119 } // namespace chrome | |
120 | |
121 #endif // CHROME_UTILITY_NETWORKING_PRIVATE_HANDLER_H_ | |
OLD | NEW |