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

Side by Side Diff: extensions/browser/api/networking_private/networking_private_service_client.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_CLI ENT_H_ 5 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_CLI ENT_H_
6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_CLI ENT_H_ 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_CLI ENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/id_map.h" 14 #include "base/id_map.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "base/supports_user_data.h" 19 #include "base/supports_user_data.h"
20 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "components/keyed_service/core/keyed_service.h" 22 #include "components/keyed_service/core/keyed_service.h"
23 #include "components/wifi/wifi_service.h" 23 #include "components/wifi/wifi_service.h"
24 #include "content/public/browser/utility_process_host.h" 24 #include "content/public/browser/utility_process_host.h"
25 #include "content/public/browser/utility_process_host_client.h" 25 #include "content/public/browser/utility_process_host_client.h"
(...skipping 10 matching lines...) Expand all
36 // NetworkingPrivateDelegate, making WiFiService calls on the worker thead. 36 // NetworkingPrivateDelegate, making WiFiService calls on the worker thead.
37 // It also observes |OnNetworkChanged| notifications and posts them to 37 // It also observes |OnNetworkChanged| notifications and posts them to
38 // WiFiService on the worker thread. Created and called from the UI thread. 38 // WiFiService on the worker thread. Created and called from the UI thread.
39 class NetworkingPrivateServiceClient 39 class NetworkingPrivateServiceClient
40 : public NetworkingPrivateDelegate, 40 : public NetworkingPrivateDelegate,
41 net::NetworkChangeNotifier::NetworkChangeObserver { 41 net::NetworkChangeNotifier::NetworkChangeObserver {
42 public: 42 public:
43 // Takes ownership of |wifi_service| which is accessed and deleted on the 43 // Takes ownership of |wifi_service| which is accessed and deleted on the
44 // worker thread. The deletion task is posted from the destructor. 44 // worker thread. The deletion task is posted from the destructor.
45 // |verify_delegate| is passed to NetworkingPrivateDelegate and may be NULL. 45 // |verify_delegate| is passed to NetworkingPrivateDelegate and may be NULL.
46 NetworkingPrivateServiceClient(scoped_ptr<wifi::WiFiService> wifi_service, 46 NetworkingPrivateServiceClient(
47 scoped_ptr<VerifyDelegate> verify_delegate); 47 std::unique_ptr<wifi::WiFiService> wifi_service,
48 std::unique_ptr<VerifyDelegate> verify_delegate);
48 49
49 // KeyedService 50 // KeyedService
50 void Shutdown() override; 51 void Shutdown() override;
51 52
52 // NetworkingPrivateDelegate 53 // NetworkingPrivateDelegate
53 void GetProperties(const std::string& guid, 54 void GetProperties(const std::string& guid,
54 const DictionaryCallback& success_callback, 55 const DictionaryCallback& success_callback,
55 const FailureCallback& failure_callback) override; 56 const FailureCallback& failure_callback) override;
56 void GetManagedProperties(const std::string& guid, 57 void GetManagedProperties(const std::string& guid,
57 const DictionaryCallback& success_callback, 58 const DictionaryCallback& success_callback,
58 const FailureCallback& failure_callback) override; 59 const FailureCallback& failure_callback) override;
59 void GetState(const std::string& guid, 60 void GetState(const std::string& guid,
60 const DictionaryCallback& success_callback, 61 const DictionaryCallback& success_callback,
61 const FailureCallback& failure_callback) override; 62 const FailureCallback& failure_callback) override;
62 void SetProperties(const std::string& guid, 63 void SetProperties(const std::string& guid,
63 scoped_ptr<base::DictionaryValue> properties_dict, 64 std::unique_ptr<base::DictionaryValue> properties_dict,
64 const VoidCallback& success_callback, 65 const VoidCallback& success_callback,
65 const FailureCallback& failure_callback) override; 66 const FailureCallback& failure_callback) override;
66 void CreateNetwork(bool shared, 67 void CreateNetwork(bool shared,
67 scoped_ptr<base::DictionaryValue> properties_dict, 68 std::unique_ptr<base::DictionaryValue> properties_dict,
68 const StringCallback& success_callback, 69 const StringCallback& success_callback,
69 const FailureCallback& failure_callback) override; 70 const FailureCallback& failure_callback) override;
70 void ForgetNetwork(const std::string& guid, 71 void ForgetNetwork(const std::string& guid,
71 const VoidCallback& success_callback, 72 const VoidCallback& success_callback,
72 const FailureCallback& failure_callback) override; 73 const FailureCallback& failure_callback) override;
73 void GetNetworks(const std::string& network_type, 74 void GetNetworks(const std::string& network_type,
74 bool configured_only, 75 bool configured_only,
75 bool visible_only, 76 bool visible_only,
76 int limit, 77 int limit,
77 const NetworkListCallback& success_callback, 78 const NetworkListCallback& success_callback,
(...skipping 19 matching lines...) Expand all
97 const std::string& pin, 98 const std::string& pin,
98 const std::string& puk, 99 const std::string& puk,
99 const VoidCallback& success_callback, 100 const VoidCallback& success_callback,
100 const FailureCallback& failure_callback) override; 101 const FailureCallback& failure_callback) override;
101 void SetCellularSimState(const std::string& guid, 102 void SetCellularSimState(const std::string& guid,
102 bool require_pin, 103 bool require_pin,
103 const std::string& current_pin, 104 const std::string& current_pin,
104 const std::string& new_pin, 105 const std::string& new_pin,
105 const VoidCallback& success_callback, 106 const VoidCallback& success_callback,
106 const FailureCallback& failure_callback) override; 107 const FailureCallback& failure_callback) override;
107 scoped_ptr<base::ListValue> GetEnabledNetworkTypes() override; 108 std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() override;
108 scoped_ptr<DeviceStateList> GetDeviceStateList() override; 109 std::unique_ptr<DeviceStateList> GetDeviceStateList() override;
109 bool EnableNetworkType(const std::string& type) override; 110 bool EnableNetworkType(const std::string& type) override;
110 bool DisableNetworkType(const std::string& type) override; 111 bool DisableNetworkType(const std::string& type) override;
111 bool RequestScan() override; 112 bool RequestScan() override;
112 void AddObserver(NetworkingPrivateDelegateObserver* observer) override; 113 void AddObserver(NetworkingPrivateDelegateObserver* observer) override;
113 void RemoveObserver(NetworkingPrivateDelegateObserver* observer) override; 114 void RemoveObserver(NetworkingPrivateDelegateObserver* observer) override;
114 115
115 // NetworkChangeNotifier::NetworkChangeObserver implementation. 116 // NetworkChangeNotifier::NetworkChangeObserver implementation.
116 void OnNetworkChanged( 117 void OnNetworkChanged(
117 net::NetworkChangeNotifier::ConnectionType type) override; 118 net::NetworkChangeNotifier::ConnectionType type) override;
118 119
(...skipping 16 matching lines...) Expand all
135 136
136 ServiceCallbacksID id; 137 ServiceCallbacksID id;
137 }; 138 };
138 typedef IDMap<ServiceCallbacks, IDMapOwnPointer> ServiceCallbacksMap; 139 typedef IDMap<ServiceCallbacks, IDMapOwnPointer> ServiceCallbacksMap;
139 140
140 ~NetworkingPrivateServiceClient() override; 141 ~NetworkingPrivateServiceClient() override;
141 142
142 // Callback wrappers. 143 // Callback wrappers.
143 void AfterGetProperties(ServiceCallbacksID callback_id, 144 void AfterGetProperties(ServiceCallbacksID callback_id,
144 const std::string& network_guid, 145 const std::string& network_guid,
145 scoped_ptr<base::DictionaryValue> properties, 146 std::unique_ptr<base::DictionaryValue> properties,
146 const std::string* error); 147 const std::string* error);
147 void AfterSetProperties(ServiceCallbacksID callback_id, 148 void AfterSetProperties(ServiceCallbacksID callback_id,
148 const std::string* error); 149 const std::string* error);
149 void AfterCreateNetwork(ServiceCallbacksID callback_id, 150 void AfterCreateNetwork(ServiceCallbacksID callback_id,
150 const std::string* network_guid, 151 const std::string* network_guid,
151 const std::string* error); 152 const std::string* error);
152 void AfterGetVisibleNetworks(ServiceCallbacksID callback_id, 153 void AfterGetVisibleNetworks(ServiceCallbacksID callback_id,
153 scoped_ptr<base::ListValue> networks); 154 std::unique_ptr<base::ListValue> networks);
154 void AfterStartConnect(ServiceCallbacksID callback_id, 155 void AfterStartConnect(ServiceCallbacksID callback_id,
155 const std::string* error); 156 const std::string* error);
156 void AfterStartDisconnect(ServiceCallbacksID callback_id, 157 void AfterStartDisconnect(ServiceCallbacksID callback_id,
157 const std::string* error); 158 const std::string* error);
158 159
159 void OnNetworksChangedEventOnUIThread( 160 void OnNetworksChangedEventOnUIThread(
160 const wifi::WiFiService::NetworkGuidList& network_guid_list); 161 const wifi::WiFiService::NetworkGuidList& network_guid_list);
161 void OnNetworkListChangedEventOnUIThread( 162 void OnNetworkListChangedEventOnUIThread(
162 const wifi::WiFiService::NetworkGuidList& network_guid_list); 163 const wifi::WiFiService::NetworkGuidList& network_guid_list);
163 164
164 // Add new |ServiceCallbacks| to |callbacks_map_|. 165 // Add new |ServiceCallbacks| to |callbacks_map_|.
165 ServiceCallbacks* AddServiceCallbacks(); 166 ServiceCallbacks* AddServiceCallbacks();
166 // Removes ServiceCallbacks for |callback_id| from |callbacks_map_|. 167 // Removes ServiceCallbacks for |callback_id| from |callbacks_map_|.
167 void RemoveServiceCallbacks(ServiceCallbacksID callback_id); 168 void RemoveServiceCallbacks(ServiceCallbacksID callback_id);
168 169
169 // Callbacks to run when callback is called from WiFiService. 170 // Callbacks to run when callback is called from WiFiService.
170 ServiceCallbacksMap callbacks_map_; 171 ServiceCallbacksMap callbacks_map_;
171 // Observers to Network Events. 172 // Observers to Network Events.
172 base::ObserverList<NetworkingPrivateDelegateObserver> 173 base::ObserverList<NetworkingPrivateDelegateObserver>
173 network_events_observers_; 174 network_events_observers_;
174 // Interface to WiFiService. Used and deleted on the worker thread. 175 // Interface to WiFiService. Used and deleted on the worker thread.
175 scoped_ptr<wifi::WiFiService> wifi_service_; 176 std::unique_ptr<wifi::WiFiService> wifi_service_;
176 // Sequence token associated with wifi tasks. 177 // Sequence token associated with wifi tasks.
177 base::SequencedWorkerPool::SequenceToken sequence_token_; 178 base::SequencedWorkerPool::SequenceToken sequence_token_;
178 // Task runner for worker tasks. 179 // Task runner for worker tasks.
179 scoped_refptr<base::SequencedTaskRunner> task_runner_; 180 scoped_refptr<base::SequencedTaskRunner> task_runner_;
180 // Use WeakPtrs for callbacks from |wifi_service_|. 181 // Use WeakPtrs for callbacks from |wifi_service_|.
181 base::WeakPtrFactory<NetworkingPrivateServiceClient> weak_factory_; 182 base::WeakPtrFactory<NetworkingPrivateServiceClient> weak_factory_;
182 183
183 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateServiceClient); 184 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateServiceClient);
184 }; 185 };
185 186
186 } // namespace extensions 187 } // namespace extensions
187 188
188 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_ CLIENT_H_ 189 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_SERVICE_ CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698