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

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

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to feedback 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
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 #include "chromeos/network/network_state.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
pneubeck (no reviews) 2012/10/25 14:42:17 logging.h unused missing include service_constants
stevenjb 2012/10/25 22:05:22 logging.h removed (although we'll probably need it
9
10 namespace chromeos {
11
12 NetworkState::NetworkState(const std::string& path)
13 : ManagedState(MANAGED_TYPE_NETWORK, path),
14 strength_(0) {
15 }
16
17 bool NetworkState::PropertyChanged(const std::string& key,
18 const base::Value& value) {
19 if (key == flimflam::kSignalStrengthProperty) {
20 return value.GetAsInteger(&strength_);
21 } else if (key == flimflam::kStateProperty) {
22 return value.GetAsString(&state_);
23 } else if (key == flimflam::kErrorProperty) {
24 return value.GetAsString(&error_);
25 } else if (key == flimflam::kActivationStateProperty) {
26 return value.GetAsString(&activation_);
27 } else if (key == flimflam::kRoamingStateProperty) {
28 return value.GetAsString(&roaming_);
29 } else if (key == flimflam::kNameProperty) {
30 return value.GetAsString(&name_);
31 } else if (key == flimflam::kTypeProperty) {
32 return value.GetAsString(&type_);
33 } else if (key == flimflam::kSecurityProperty) {
34 return value.GetAsString(&security_);
35 } else if (key == flimflam::kNetworkTechnologyProperty) {
36 return value.GetAsString(&technology_);
37 } else if (key == flimflam::kDeviceProperty) {
38 return value.GetAsString(&device_path_);
39 }
40 return true;
41 }
42
43 bool NetworkState::IsConnectedState() const {
44 return StateIsConnected(state_);
45 }
46
47 bool NetworkState::IsConnectingState() const {
48 return StateIsConnecting(state_);
49 }
50
51 // static
52 bool NetworkState::StateIsConnected(const std::string& state) {
53 return (state == flimflam::kStateReady ||
54 state == flimflam::kStateOnline ||
55 state == flimflam::kStatePortal);
56 }
57
58 // static
59 bool NetworkState::StateIsConnecting(const std::string& state) {
60 return (state == flimflam::kStateAssociation ||
61 state == flimflam::kStateConfiguration ||
62 state == flimflam::kStateCarrier);
63 }
64
65 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698