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

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

Issue 275543005: Use GUID instead of ServicePath in networkingPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 | Annotate | Revision Log
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_STATE_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Class for tracking the list of visible networks and their properties. 42 // Class for tracking the list of visible networks and their properties.
43 // 43 //
44 // This class maps essential properties from the connection manager (Shill) for 44 // This class maps essential properties from the connection manager (Shill) for
45 // each visible network. It is not used to change the properties of services or 45 // each visible network. It is not used to change the properties of services or
46 // devices, only global (manager) properties. 46 // devices, only global (manager) properties.
47 // 47 //
48 // All getters return the currently cached properties. This class is expected to 48 // All getters return the currently cached properties. This class is expected to
49 // keep properties up to date by managing the appropriate Shill observers. 49 // keep properties up to date by managing the appropriate Shill observers.
50 // It will invoke its own more specific observer methods when the specified 50 // It will invoke its own more specific observer methods when the specified
51 // changes occur. 51 // changes occur.
52 //
53 // Some notes about NetworkState, FavoriteState, and GUIDs:
54 // * A FavoriteState exists for all network services stored in a profile, and
55 // all "visible" networks (physically connected networks like ethernet and
56 // cellular or in-range wifi networks). If the network is stored in a profile,
57 // FavoriteState.IsInProfile() will return true.
58 // * A NetworkState exists for "visible" networks only. There will always be a
59 // corresponding FavoriteState with the same service_path() property.
60 // * All networks saved to a profile will have a saved GUID that is persistent
61 // across sessions.
62 // * Networks that are not saved to a profile will have a GUID assigned when
63 // the initial properties are received. The GUID will be consistent for
64 // the duration of a session, even if the network drops out and returns.
65 // * Both FavoriteState and NetworkState store the GUID. It will always be the
66 // same for the same network (i.e. entries with the same service_path()).
52 67
53 class CHROMEOS_EXPORT NetworkStateHandler 68 class CHROMEOS_EXPORT NetworkStateHandler
54 : public internal::ShillPropertyHandler::Listener { 69 : public internal::ShillPropertyHandler::Listener {
55 public: 70 public:
56 typedef std::vector<ManagedState*> ManagedStateList; 71 typedef std::vector<ManagedState*> ManagedStateList;
57 typedef std::vector<const NetworkState*> NetworkStateList; 72 typedef std::vector<const NetworkState*> NetworkStateList;
58 typedef std::vector<const DeviceState*> DeviceStateList; 73 typedef std::vector<const DeviceState*> DeviceStateList;
59 typedef std::vector<const FavoriteState*> FavoriteStateList; 74 typedef std::vector<const FavoriteState*> FavoriteStateList;
60 75
61 enum TechnologyState { 76 enum TechnologyState {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // favorite is visible and retrieve the complete properties (and vice-versa). 183 // favorite is visible and retrieve the complete properties (and vice-versa).
169 void GetFavoriteList(FavoriteStateList* list) const; 184 void GetFavoriteList(FavoriteStateList* list) const;
170 185
171 // Like GetFavoriteList() but only returns favorites with matching |type|. 186 // Like GetFavoriteList() but only returns favorites with matching |type|.
172 void GetFavoriteListByType(const NetworkTypePattern& type, 187 void GetFavoriteListByType(const NetworkTypePattern& type,
173 FavoriteStateList* list) const; 188 FavoriteStateList* list) const;
174 189
175 // Finds and returns a favorite state by |service_path| or NULL if not found. 190 // Finds and returns a favorite state by |service_path| or NULL if not found.
176 const FavoriteState* GetFavoriteState(const std::string& service_path) const; 191 const FavoriteState* GetFavoriteState(const std::string& service_path) const;
177 192
193 // Finds the FavoriteState associated with |guid|. Note: The FavoriteState
194 // may or may not be in a profile (IsProfile() may be false), and may or may
pneubeck (no reviews) 2014/05/12 13:37:07 it's a bit unlucky that the name is so similar to
stevenjb 2014/05/13 01:19:00 GetFavoriteState -> GetFravoriteStateFromServicePa
pneubeck (no reviews) 2014/05/13 08:43:54 yes, that's much better.
195 // not be visible.
196 const FavoriteState* GetFavoriteStateFromGuid(const std::string& guid) const;
197
178 // Requests a network scan. This may trigger updates to the network 198 // Requests a network scan. This may trigger updates to the network
179 // list, which will trigger the appropriate observer calls. 199 // list, which will trigger the appropriate observer calls.
180 void RequestScan() const; 200 void RequestScan() const;
181 201
182 // Request a scan if not scanning and run |callback| when the Scanning state 202 // Request a scan if not scanning and run |callback| when the Scanning state
183 // for any Device of network type |type| completes. 203 // for any Device of network type |type| completes.
184 void WaitForScan(const std::string& type, const base::Closure& callback); 204 void WaitForScan(const std::string& type, const base::Closure& callback);
185 205
186 // Request a network scan then signal Shill to connect to the best available 206 // Request a network scan then signal Shill to connect to the best available
187 // networks when completed. 207 // networks when completed.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 virtual void DefaultNetworkServiceChanged( 301 virtual void DefaultNetworkServiceChanged(
282 const std::string& service_path) OVERRIDE; 302 const std::string& service_path) OVERRIDE;
283 303
284 // Called after construction. Called explicitly by tests after adding 304 // Called after construction. Called explicitly by tests after adding
285 // test observers. 305 // test observers.
286 void InitShillPropertyHandler(); 306 void InitShillPropertyHandler();
287 307
288 private: 308 private:
289 typedef std::list<base::Closure> ScanCallbackList; 309 typedef std::list<base::Closure> ScanCallbackList;
290 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; 310 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap;
311 typedef std::map<std::string, std::string> SpecifierGuidMap;
291 friend class NetworkStateHandlerTest; 312 friend class NetworkStateHandlerTest;
292 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); 313 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub);
293 314
294 // NetworkState specific method for UpdateManagedStateProperties which 315 // NetworkState specific method for UpdateManagedStateProperties which
295 // notifies observers. 316 // notifies observers.
296 void UpdateNetworkStateProperties(NetworkState* network, 317 void UpdateNetworkStateProperties(NetworkState* network,
297 const base::DictionaryValue& properties); 318 const base::DictionaryValue& properties);
298 319
320 // Ensure a valid GUID for FavoriteState and update the NetworkState GUID from
321 // the corresponding FavoriteState if necessary.
322 void UpdateGuid(ManagedState* managed);
323
299 // Sends DeviceListChanged() to observers and logs an event. 324 // Sends DeviceListChanged() to observers and logs an event.
300 void NotifyDeviceListChanged(); 325 void NotifyDeviceListChanged();
301 326
302 // Non-const getters for managed entries. These are const so that they can 327 // Non-const getters for managed entries. These are const so that they can
303 // be called by Get[Network|Device]State, even though they return non-const 328 // be called by Get[Network|Device]State, even though they return non-const
304 // pointers. 329 // pointers.
305 DeviceState* GetModifiableDeviceState(const std::string& device_path) const; 330 DeviceState* GetModifiableDeviceState(const std::string& device_path) const;
306 NetworkState* GetModifiableNetworkState( 331 NetworkState* GetModifiableNetworkState(
307 const std::string& service_path) const; 332 const std::string& service_path) const;
333 FavoriteState* GetModifiableFavoriteState(
334 const std::string& service_path) const;
308 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list, 335 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list,
309 const std::string& path) const; 336 const std::string& path) const;
310 337
311 // Gets the list specified by |type|. 338 // Gets the list specified by |type|.
312 ManagedStateList* GetManagedList(ManagedState::ManagedType type); 339 ManagedStateList* GetManagedList(ManagedState::ManagedType type);
313 340
314 // Helper function to notify observers. Calls CheckDefaultNetworkChanged(). 341 // Helper function to notify observers. Calls CheckDefaultNetworkChanged().
315 void OnNetworkConnectionStateChanged(NetworkState* network); 342 void OnNetworkConnectionStateChanged(NetworkState* network);
316 343
317 // Notifies observers when the default network or its properties change. 344 // Notifies observers when the default network or its properties change.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 377
351 // Keeps track of the default network for notifying observers when it changes. 378 // Keeps track of the default network for notifying observers when it changes.
352 std::string default_network_path_; 379 std::string default_network_path_;
353 380
354 // List of interfaces on which portal check is enabled. 381 // List of interfaces on which portal check is enabled.
355 std::string check_portal_list_; 382 std::string check_portal_list_;
356 383
357 // Callbacks to run when a scan for the technology type completes. 384 // Callbacks to run when a scan for the technology type completes.
358 ScanCompleteCallbackMap scan_complete_callbacks_; 385 ScanCompleteCallbackMap scan_complete_callbacks_;
359 386
387 // Map of network specifiers to guids.
pneubeck (no reviews) 2014/05/12 13:37:07 According to your class comment, you should ensure
stevenjb 2014/05/13 01:19:00 Done.
388 SpecifierGuidMap specifier_guid_map_;
389
360 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); 390 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler);
361 }; 391 };
362 392
363 } // namespace chromeos 393 } // namespace chromeos
364 394
365 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 395 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698