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

Side by Side Diff: chromeos/network/network_configuration_handler.h

Issue 2689223002: Defer NetworkConfigurationHandler::CreateShillConfiguration callback (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ 6 #define CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.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 "chromeos/chromeos_export.h" 18 #include "chromeos/chromeos_export.h"
19 #include "chromeos/dbus/dbus_method_call_status.h" 19 #include "chromeos/dbus/dbus_method_call_status.h"
20 #include "chromeos/network/network_configuration_observer.h" 20 #include "chromeos/network/network_configuration_observer.h"
21 #include "chromeos/network/network_handler.h" 21 #include "chromeos/network/network_handler.h"
22 #include "chromeos/network/network_handler_callbacks.h" 22 #include "chromeos/network/network_handler_callbacks.h"
23 #include "chromeos/network/network_state_handler_observer.h"
23 24
24 namespace base { 25 namespace base {
25 class DictionaryValue; 26 class DictionaryValue;
26 class ListValue; 27 class ListValue;
27 } 28 }
28 29
29 namespace dbus { 30 namespace dbus {
30 class ObjectPath; 31 class ObjectPath;
31 } 32 }
32 33
(...skipping 15 matching lines...) Expand all
48 // 49 //
49 // Note on callbacks: Because all the functions here are meant to be 50 // Note on callbacks: Because all the functions here are meant to be
50 // asynchronous, they all take a |callback| of some type, and an 51 // asynchronous, they all take a |callback| of some type, and an
51 // |error_callback|. When the operation succeeds, |callback| will be called, and 52 // |error_callback|. When the operation succeeds, |callback| will be called, and
52 // when it doesn't, |error_callback| will be called with information about the 53 // when it doesn't, |error_callback| will be called with information about the
53 // error, including a symbolic name for the error and often some error message 54 // error, including a symbolic name for the error and often some error message
54 // that is suitable for logging. None of the error message text is meant for 55 // that is suitable for logging. None of the error message text is meant for
55 // user consumption. Both |callback| and |error_callback| are permitted to be 56 // user consumption. Both |callback| and |error_callback| are permitted to be
56 // null callbacks. 57 // null callbacks.
57 class CHROMEOS_EXPORT NetworkConfigurationHandler 58 class CHROMEOS_EXPORT NetworkConfigurationHandler
58 : public base::SupportsWeakPtr<NetworkConfigurationHandler> { 59 : public NetworkStateHandlerObserver {
59 public: 60 public:
60 ~NetworkConfigurationHandler(); 61 ~NetworkConfigurationHandler() override;
61 62
62 // Manages the observer list. 63 // Manages the observer list.
63 void AddObserver(NetworkConfigurationObserver* observer); 64 void AddObserver(NetworkConfigurationObserver* observer);
64 void RemoveObserver(NetworkConfigurationObserver* observer); 65 void RemoveObserver(NetworkConfigurationObserver* observer);
65 66
66 // Gets the properties of the network with id |service_path|. See note on 67 // Gets the properties of the network with id |service_path|. See note on
67 // |callback| and |error_callback|, in class description above. 68 // |callback| and |error_callback|, in class description above.
68 void GetShillProperties( 69 void GetShillProperties(
69 const std::string& service_path, 70 const std::string& service_path,
70 const network_handler::DictionaryResultCallback& callback, 71 const network_handler::DictionaryResultCallback& callback,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const network_handler::ErrorCallback& error_callback); 116 const network_handler::ErrorCallback& error_callback);
116 117
117 // Changes the profile for the network |service_path| to |profile_path|. 118 // Changes the profile for the network |service_path| to |profile_path|.
118 // See notes on |source| and callbacks in class description above. 119 // See notes on |source| and callbacks in class description above.
119 void SetNetworkProfile(const std::string& service_path, 120 void SetNetworkProfile(const std::string& service_path,
120 const std::string& profile_path, 121 const std::string& profile_path,
121 NetworkConfigurationObserver::Source source, 122 NetworkConfigurationObserver::Source source,
122 const base::Closure& callback, 123 const base::Closure& callback,
123 const network_handler::ErrorCallback& error_callback); 124 const network_handler::ErrorCallback& error_callback);
124 125
126 // NetworkStateHandlerObserver
127 void NetworkListChanged() override;
128 void OnShuttingDown() override;
129
125 // Construct and initialize an instance for testing. 130 // Construct and initialize an instance for testing.
126 static NetworkConfigurationHandler* InitializeForTest( 131 static NetworkConfigurationHandler* InitializeForTest(
127 NetworkStateHandler* network_state_handler, 132 NetworkStateHandler* network_state_handler,
128 NetworkDeviceHandler* network_device_handler); 133 NetworkDeviceHandler* network_device_handler);
129 134
130 private: 135 private:
131 friend class ClientCertResolverTest; 136 friend class ClientCertResolverTest;
132 friend class NetworkHandler; 137 friend class NetworkHandler;
133 friend class NetworkConfigurationHandlerTest; 138 friend class NetworkConfigurationHandlerTest;
134 friend class NetworkConfigurationHandlerStubTest; 139 friend class NetworkConfigurationHandlerStubTest;
135 class ProfileEntryDeleter; 140 class ProfileEntryDeleter;
136 141
137 NetworkConfigurationHandler(); 142 NetworkConfigurationHandler();
138 void Init(NetworkStateHandler* network_state_handler, 143 void Init(NetworkStateHandler* network_state_handler,
139 NetworkDeviceHandler* network_device_handler); 144 NetworkDeviceHandler* network_device_handler);
140 145
141 void RunCreateNetworkCallback( 146 // Called when a configuration completes. This will wait for the cached
147 // state (NetworkStateHandler) to update before triggering the callback.
148 void ConfigurationCompleted(
142 const std::string& profile_path, 149 const std::string& profile_path,
143 NetworkConfigurationObserver::Source source, 150 NetworkConfigurationObserver::Source source,
144 std::unique_ptr<base::DictionaryValue> configure_properties, 151 std::unique_ptr<base::DictionaryValue> configure_properties,
145 const network_handler::ServiceResultCallback& callback, 152 const network_handler::ServiceResultCallback& callback,
146 const dbus::ObjectPath& service_path); 153 const dbus::ObjectPath& service_path);
147 154
148 // Called from ProfileEntryDeleter instances when they complete causing 155 // Called from ProfileEntryDeleter instances when they complete causing
149 // this class to delete the instance. 156 // this class to delete the instance.
150 void ProfileEntryDeleterCompleted(const std::string& service_path, 157 void ProfileEntryDeleterCompleted(const std::string& service_path,
151 const std::string& guid, 158 const std::string& guid,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void RequestRefreshIPConfigs(const std::string& service_path); 206 void RequestRefreshIPConfigs(const std::string& service_path);
200 207
201 // Unowned associated Network*Handlers (global or test instance). 208 // Unowned associated Network*Handlers (global or test instance).
202 NetworkStateHandler* network_state_handler_; 209 NetworkStateHandler* network_state_handler_;
203 NetworkDeviceHandler* network_device_handler_; 210 NetworkDeviceHandler* network_device_handler_;
204 211
205 // Map of in-progress deleter instances. 212 // Map of in-progress deleter instances.
206 std::map<std::string, std::unique_ptr<ProfileEntryDeleter>> 213 std::map<std::string, std::unique_ptr<ProfileEntryDeleter>>
207 profile_entry_deleters_; 214 profile_entry_deleters_;
208 215
216 // Map of configuration callbacks to run once the service becomes available
217 // in the NetworkStateHandler cache.
218 std::map<std::string, network_handler::ServiceResultCallback>
219 configure_callbacks_;
220
209 base::ObserverList<NetworkConfigurationObserver, true> observers_; 221 base::ObserverList<NetworkConfigurationObserver, true> observers_;
210 222
223 base::WeakPtrFactory<NetworkConfigurationHandler> weak_ptr_factory_;
224
211 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationHandler); 225 DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationHandler);
212 }; 226 };
213 227
214 } // namespace chromeos 228 } // namespace chromeos
215 229
216 #endif // CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_ 230 #endif // CHROMEOS_NETWORK_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/network/network_cert_migrator_unittest.cc ('k') | chromeos/network/network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698