| OLD | NEW |
| 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_MANAGED_STATE_H_ | 5 #ifndef CHROMEOS_NETWORK_MANAGED_STATE_H_ |
| 6 #define CHROMEOS_NETWORK_MANAGED_STATE_H_ | 6 #define CHROMEOS_NETWORK_MANAGED_STATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class Value; | 15 class Value; |
| 16 class DictionaryValue; | 16 class DictionaryValue; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 class DeviceState; | 21 class DeviceState; |
| 22 class FavoriteState; | |
| 23 class NetworkState; | 22 class NetworkState; |
| 24 class NetworkTypePattern; | 23 class NetworkTypePattern; |
| 25 | 24 |
| 26 // Base class for states managed by NetworkStateManger which are associated | 25 // Base class for states managed by NetworkStateManger which are associated |
| 27 // with a Shill path (e.g. service path or device path). | 26 // with a Shill path (e.g. service path or device path). |
| 28 class CHROMEOS_EXPORT ManagedState { | 27 class CHROMEOS_EXPORT ManagedState { |
| 29 public: | 28 public: |
| 30 enum ManagedType { | 29 enum ManagedType { |
| 31 MANAGED_TYPE_NETWORK, | 30 MANAGED_TYPE_NETWORK, |
| 32 MANAGED_TYPE_FAVORITE, | |
| 33 MANAGED_TYPE_DEVICE | 31 MANAGED_TYPE_DEVICE |
| 34 }; | 32 }; |
| 35 | 33 |
| 36 virtual ~ManagedState(); | 34 virtual ~ManagedState(); |
| 37 | 35 |
| 38 // This will construct and return a new instance of the appropriate class | 36 // This will construct and return a new instance of the appropriate class |
| 39 // based on |type|. | 37 // based on |type|. |
| 40 static ManagedState* Create(ManagedType type, const std::string& path); | 38 static ManagedState* Create(ManagedType type, const std::string& path); |
| 41 | 39 |
| 42 // Returns the specific class pointer if this is the correct type, or | 40 // Returns the specific class pointer if this is the correct type, or |
| 43 // NULL if it is not. | 41 // NULL if it is not. |
| 44 NetworkState* AsNetworkState(); | 42 NetworkState* AsNetworkState(); |
| 45 DeviceState* AsDeviceState(); | 43 DeviceState* AsDeviceState(); |
| 46 FavoriteState* AsFavoriteState(); | |
| 47 | 44 |
| 48 // Called by NetworkStateHandler when a property was received. The return | 45 // Called by NetworkStateHandler when a property was received. The return |
| 49 // value indicates if the state changed and is used to reduce the number of | 46 // value indicates if the state changed and is used to reduce the number of |
| 50 // notifications. The only guarantee however is: If the return value is false | 47 // notifications. The only guarantee however is: If the return value is false |
| 51 // then the state wasn't modified. This might happen because of | 48 // then the state wasn't modified. This might happen because of |
| 52 // * |key| was not recognized. | 49 // * |key| was not recognized. |
| 53 // * |value| was not parsed successfully. | 50 // * |value| was not parsed successfully. |
| 54 // * |value| is equal to the cached property value. | 51 // * |value| is equal to the cached property value. |
| 55 // If the return value is true, the state might or might not be modified. | 52 // If the return value is true, the state might or might not be modified. |
| 56 virtual bool PropertyChanged(const std::string& key, | 53 virtual bool PropertyChanged(const std::string& key, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 122 |
| 126 // Tracks when an update has been requested. | 123 // Tracks when an update has been requested. |
| 127 bool update_requested_; | 124 bool update_requested_; |
| 128 | 125 |
| 129 DISALLOW_COPY_AND_ASSIGN(ManagedState); | 126 DISALLOW_COPY_AND_ASSIGN(ManagedState); |
| 130 }; | 127 }; |
| 131 | 128 |
| 132 } // namespace chromeos | 129 } // namespace chromeos |
| 133 | 130 |
| 134 #endif // CHROMEOS_NETWORK_MANAGED_STATE_H_ | 131 #endif // CHROMEOS_NETWORK_MANAGED_STATE_H_ |
| OLD | NEW |