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

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

Issue 21030006: NetworkState cleanup, pass properties to InitialPropertiesReceived (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 4 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_H_ 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_
6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ 6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 typedef std::vector<int> FrequencyList; 24 typedef std::vector<int> FrequencyList;
25 25
26 explicit NetworkState(const std::string& path); 26 explicit NetworkState(const std::string& path);
27 virtual ~NetworkState(); 27 virtual ~NetworkState();
28 28
29 // ManagedState overrides 29 // ManagedState overrides
30 // If you change this method, update GetProperties too. 30 // If you change this method, update GetProperties too.
31 virtual bool PropertyChanged(const std::string& key, 31 virtual bool PropertyChanged(const std::string& key,
32 const base::Value& value) OVERRIDE; 32 const base::Value& value) OVERRIDE;
33 virtual void InitialPropertiesReceived() OVERRIDE; 33 virtual void InitialPropertiesReceived(
34 const base::DictionaryValue& properties) OVERRIDE;
34 35
35 // Fills |dictionary| with the state properties. All the properties that are 36 // Fills |dictionary| with the state properties. All the properties that are
36 // accepted by PropertyChanged are stored in |dictionary|, no other values are 37 // accepted by PropertyChanged are stored in |dictionary|, no other values are
37 // stored. 38 // stored.
38 void GetProperties(base::DictionaryValue* dictionary) const; 39 void GetProperties(base::DictionaryValue* dictionary) const;
39 40
40 // Fills |dictionary| with the state properties required to configure a 41 // Fills |dictionary| with the state properties required to configure a
41 // network. 42 // network.
42 void GetConfigProperties(base::DictionaryValue* dictionary) const; 43 void GetConfigProperties(base::DictionaryValue* dictionary) const;
43 44
(...skipping 15 matching lines...) Expand all
59 const std::string& gateway() const { return gateway_; } 60 const std::string& gateway() const { return gateway_; }
60 const std::vector<std::string>& dns_servers() const { return dns_servers_; } 61 const std::vector<std::string>& dns_servers() const { return dns_servers_; }
61 const int prefix_length() const { return prefix_length_; } 62 const int prefix_length() const { return prefix_length_; }
62 // Wireless property accessors 63 // Wireless property accessors
63 int signal_strength() const { return signal_strength_; } 64 int signal_strength() const { return signal_strength_; }
64 bool connectable() const { return connectable_; } 65 bool connectable() const { return connectable_; }
65 // Wifi property accessors 66 // Wifi property accessors
66 bool passphrase_required() const { return passphrase_required_; } 67 bool passphrase_required() const { return passphrase_required_; }
67 const FrequencyList& wifi_frequencies() const { return wifi_frequencies_; } 68 const FrequencyList& wifi_frequencies() const { return wifi_frequencies_; }
68 // Cellular property accessors 69 // Cellular property accessors
69 const std::string& technology() const { return technology_; } 70 const std::string& network_technology() const {
71 return network_technology_;
72 }
70 const std::string& activation_state() const { return activation_state_; } 73 const std::string& activation_state() const { return activation_state_; }
71 const std::string& roaming() const { return roaming_; } 74 const std::string& roaming() const { return roaming_; }
72 bool activate_over_non_cellular_networks() const { 75 bool activate_over_non_cellular_networks() const {
73 return activate_over_non_cellular_networks_; 76 return activate_over_non_cellular_networks_;
74 } 77 }
75 bool cellular_out_of_credits() const { return cellular_out_of_credits_; } 78 bool cellular_out_of_credits() const { return cellular_out_of_credits_; }
76 const std::string& usage_url() const { return usage_url_; } 79 const std::string& usage_url() const { return usage_url_; }
77 const std::string& payment_url() const { return payment_url_; } 80 const std::string& payment_url() const { return payment_url_; }
78 const std::string& post_method() const { return post_method_; } 81 const std::string& post_method() const { return post_method_; }
79 const std::string& post_data() const { return post_data_; } 82 const std::string& post_data() const { return post_data_; }
80 83
84 // Returns true if |connection_state_| is a connected/connecting state.
81 bool IsConnectedState() const; 85 bool IsConnectedState() const;
82 bool IsConnectingState() const; 86 bool IsConnectingState() const;
83 87
88 // Returns true if the ONC source is a device or user policy.
84 bool IsManaged() const; 89 bool IsManaged() const;
85 bool IsShared() const; 90
91 // Returns true if the network properties are stored in the user profile.
pneubeck (no reviews) 2013/07/29 19:13:25 ditto: the -> a
stevenjb 2013/07/29 20:25:47 Done.
92 bool IsPrivate() const;
86 93
87 // Returns a comma separated string of name servers. 94 // Returns a comma separated string of name servers.
88 std::string GetDnsServersAsString() const; 95 std::string GetDnsServersAsString() const;
89 96
90 // Converts the prefix length to a netmaks string. 97 // Converts the prefix length to a netmaks string.
91 std::string GetNetmask() const; 98 std::string GetNetmask() const;
92 99
93 // Returns true if |error_| contains an authentication error. 100 // Returns true if |error_| contains an authentication error.
94 bool HasAuthenticationError() const; 101 bool HasAuthenticationError() const;
95 102
96 // Helpers (used e.g. when a state is cached) 103 // Helpers (used e.g. when a state is cached)
97 static bool StateIsConnected(const std::string& connection_state); 104 static bool StateIsConnected(const std::string& connection_state);
98 static bool StateIsConnecting(const std::string& connection_state); 105 static bool StateIsConnecting(const std::string& connection_state);
99 106
100 // Helper to return a full prefixed version of an IPConfig property 107 // Helper to return a full prefixed version of an IPConfig property
101 // key. 108 // key.
102 static std::string IPConfigProperty(const char* key); 109 static std::string IPConfigProperty(const char* key);
103 110
104 // Sets |out| to the ONCSource specified by the UIData property |value|. 111 // Sets |out| to the ONCSource specified by the UIData property |value|.
105 // Returns true if the source was successfully parsed. 112 // Returns true if the source was successfully parsed.
106 static bool GetOncSource(const base::Value& value, onc::ONCSource* out); 113 static bool GetOncSource(const base::Value& value, onc::ONCSource* out);
107 114
108 private: 115 private:
109 friend class NetworkStateHandler; 116 friend class NetworkStateHandler;
110 friend class NetworkChangeNotifierChromeosUpdateTest; 117 friend class NetworkChangeNotifierChromeosUpdateTest;
111 118
112 // Updates the name from hex_ssid_ if provided, and validates name_. 119 // Updates the name from WiFi.HexSSID if provided, and validates name_.
113 void UpdateName(); 120 void UpdateName(const base::DictionaryValue& properties);
121
122 // Sets user_profile_required_ to true if necessary.
123 void UpdateUserProfileRequired(const base::DictionaryValue& properties);
114 124
115 // TODO(gauravsh): Audit the list of properties that we are caching. We should 125 // TODO(gauravsh): Audit the list of properties that we are caching. We should
116 // only be doing this for commonly accessed properties. crbug.com/252553 126 // only be doing this for commonly accessed properties. crbug.com/252553
117 // Common Network Service properties 127 // Common Network Service properties
118 std::string security_; 128 std::string security_;
119 std::string device_path_; 129 std::string device_path_;
120 std::string guid_; 130 std::string guid_;
121 std::string connection_state_; 131 std::string connection_state_;
122 std::string profile_path_; 132 std::string profile_path_;
123 std::string error_; 133 std::string error_;
124 std::string error_details_; 134 std::string error_details_;
125 bool auto_connect_; 135 bool auto_connect_;
126 bool favorite_; 136 bool favorite_;
127 int priority_; 137 int priority_;
138 bool user_profile_required_;
128 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler 139 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler
129 // provides proxy configuration. crbug/241775 140 // provides proxy configuration. crbug/241775
130 base::DictionaryValue proxy_config_; 141 base::DictionaryValue proxy_config_;
131 onc::ONCSource onc_source_; 142 onc::ONCSource onc_source_;
132 // IPConfig properties. 143 // IPConfig properties.
133 // Note: These do not correspond to actual Shill.Service properties 144 // Note: These do not correspond to actual Shill.Service properties
134 // but are derived from the service's corresponding IPConfig object. 145 // but are derived from the service's corresponding IPConfig object.
135 std::string ip_address_; 146 std::string ip_address_;
136 std::string gateway_; 147 std::string gateway_;
137 std::vector<std::string> dns_servers_; 148 std::vector<std::string> dns_servers_;
138 int prefix_length_; 149 int prefix_length_;
139 // Wireless properties 150 // Wireless properties
140 int signal_strength_; 151 int signal_strength_;
141 bool connectable_; 152 bool connectable_;
142 // Wifi properties 153 // Wifi properties
143 std::string hex_ssid_;
144 std::string country_code_;
145 bool passphrase_required_; 154 bool passphrase_required_;
146 FrequencyList wifi_frequencies_; 155 FrequencyList wifi_frequencies_;
147 // Cellular properties 156 // Cellular properties
148 std::string technology_; 157 std::string network_technology_;
149 std::string activation_state_; 158 std::string activation_state_;
150 std::string roaming_; 159 std::string roaming_;
151 bool activate_over_non_cellular_networks_; 160 bool activate_over_non_cellular_networks_;
152 bool cellular_out_of_credits_; 161 bool cellular_out_of_credits_;
153 // Cellular payment portal properties. 162 // Cellular payment portal properties.
154 std::string usage_url_; 163 std::string usage_url_;
155 std::string payment_url_; 164 std::string payment_url_;
156 std::string post_method_; 165 std::string post_method_;
157 std::string post_data_; 166 std::string post_data_;
158 167
159 DISALLOW_COPY_AND_ASSIGN(NetworkState); 168 DISALLOW_COPY_AND_ASSIGN(NetworkState);
160 }; 169 };
161 170
162 } // namespace chromeos 171 } // namespace chromeos
163 172
164 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ 173 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698