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

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

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 8 years, 1 month 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
« no previous file with comments | « chromeos/network/device_state.cc ('k') | chromeos/network/managed_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_NETWORK_MANAGED_STATE_H_
6 #define CHROMEOS_NETWORK_MANAGED_STATE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chromeos/chromeos_export.h"
13
14 namespace base {
15 class Value;
16 }
17
18 namespace chromeos {
19
20 class DeviceState;
21 class NetworkState;
22
23 // Base class for states managed by NetworkStateManger which are associated
24 // with a Shill path (e.g. service path or device path).
25 class ManagedState {
26 public:
27 enum ManagedType {
28 MANAGED_TYPE_NETWORK,
29 MANAGED_TYPE_DEVICE
30 };
31
32 virtual ~ManagedState();
33
34 // This will construct and return a new instance of the approprate class
35 // based on |type|.
36 static ManagedState* Create(ManagedType type, const std::string& path);
37
38 // Returns the specific class pointer if this is the correct type, or
39 // NULL if it is not.
40 NetworkState* AsNetworkState();
41 DeviceState* AsDeviceState();
42
43 // Called by NetworkStateHandler when a property changes. Returns true if
44 // the property was recognized and parsed successfully.
45 virtual bool PropertyChanged(const std::string& key,
46 const base::Value& value) = 0;
47
48 const ManagedType managed_type() const { return managed_type_; }
49 const std::string& path() const { return path_; }
50 const std::string& name() const { return name_; }
51 const std::string& type() const { return type_; }
52 bool is_observed() const { return is_observed_; }
53 void set_is_observed(bool is_observed) { is_observed_ = is_observed; }
54
55 protected:
56 ManagedState(ManagedType type, const std::string& path);
57
58 // Parses common property keys (name, type).
59 bool ManagedStatePropertyChanged(const std::string& key,
60 const base::Value& value);
61
62 // Helper methods that log warnings and return false if parsing failed.
63 bool GetBooleanValue(const std::string& key,
64 const base::Value& value,
65 bool* out_value);
66 bool GetIntegerValue(const std::string& key,
67 const base::Value& value,
68 int* out_value);
69 bool GetStringValue(const std::string& key,
70 const base::Value& value,
71 std::string* out_value);
72
73 private:
74 ManagedType managed_type_;
75
76 // The path (e.g. service path or device path) of the managed state object.
77 std::string path_;
78
79 // Common properties shared by all managed state objects.
80 std::string name_; // flimflam::kNameProperty
81 std::string type_; // flimflam::kTypeProperty
82
83 // Tracks when the state is being observed.
84 bool is_observed_;
85
86 DISALLOW_COPY_AND_ASSIGN(ManagedState);
87 };
88
89 } // namespace chromeos
90
91 #endif // CHROMEOS_NETWORK_MANAGED_STATE_H_
OLDNEW
« no previous file with comments | « chromeos/network/device_state.cc ('k') | chromeos/network/managed_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698