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

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

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests and rebased. Created 7 years, 3 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_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; 22 class FavoriteState;
23 class NetworkState; 23 class NetworkState;
24 class NetworkTypePattern;
24 25
25 // Base class for states managed by NetworkStateManger which are associated 26 // Base class for states managed by NetworkStateManger which are associated
26 // with a Shill path (e.g. service path or device path). 27 // with a Shill path (e.g. service path or device path).
27 class ManagedState { 28 class CHROMEOS_EXPORT ManagedState {
28 public: 29 public:
29 enum ManagedType { 30 enum ManagedType {
30 MANAGED_TYPE_NETWORK, 31 MANAGED_TYPE_NETWORK,
31 MANAGED_TYPE_FAVORITE, 32 MANAGED_TYPE_FAVORITE,
32 MANAGED_TYPE_DEVICE 33 MANAGED_TYPE_DEVICE
33 }; 34 };
34 35
35 virtual ~ManagedState(); 36 virtual ~ManagedState();
36 37
37 // This will construct and return a new instance of the appropriate class 38 // This will construct and return a new instance of the appropriate class
(...skipping 29 matching lines...) Expand all
67 const std::string& path() const { return path_; } 68 const std::string& path() const { return path_; }
68 const std::string& name() const { return name_; } 69 const std::string& name() const { return name_; }
69 const std::string& type() const { return type_; } 70 const std::string& type() const { return type_; }
70 bool update_received() const { return update_received_; } 71 bool update_received() const { return update_received_; }
71 void set_update_received() { update_received_ = true; } 72 void set_update_received() { update_received_ = true; }
72 bool update_requested() const { return update_requested_; } 73 bool update_requested() const { return update_requested_; }
73 void set_update_requested(bool update_requested) { 74 void set_update_requested(bool update_requested) {
74 update_requested_ = update_requested; 75 update_requested_ = update_requested;
75 } 76 }
76 77
78 bool Matches(const NetworkTypePattern& pattern) const;
79
77 protected: 80 protected:
78 ManagedState(ManagedType type, const std::string& path); 81 ManagedState(ManagedType type, const std::string& path);
79 82
80 // Parses common property keys (name, type). 83 // Parses common property keys (name, type).
81 bool ManagedStatePropertyChanged(const std::string& key, 84 bool ManagedStatePropertyChanged(const std::string& key,
82 const base::Value& value); 85 const base::Value& value);
83 86
84 // Helper methods that log warnings and return true if parsing succeeded and 87 // Helper methods that log warnings and return true if parsing succeeded and
85 // the new value does not match the existing output value. 88 // the new value does not match the existing output value.
86 bool GetBooleanValue(const std::string& key, 89 bool GetBooleanValue(const std::string& key,
(...skipping 28 matching lines...) Expand all
115 118
116 // Tracks when an update has been requested. 119 // Tracks when an update has been requested.
117 bool update_requested_; 120 bool update_requested_;
118 121
119 DISALLOW_COPY_AND_ASSIGN(ManagedState); 122 DISALLOW_COPY_AND_ASSIGN(ManagedState);
120 }; 123 };
121 124
122 } // namespace chromeos 125 } // namespace chromeos
123 126
124 #endif // CHROMEOS_NETWORK_MANAGED_STATE_H_ 127 #endif // CHROMEOS_NETWORK_MANAGED_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698