Gilad Arnold | 55f39b7 | 2014-01-28 12:51:45 -0800 | [diff] [blame] | 1 | // Copyright (c) 2014 The Chromium OS 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_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_SHILL_PROVIDER_H |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_SHILL_PROVIDER_H |
| 7 | |
| 8 | #include <base/memory/scoped_ptr.h> |
| 9 | #include <base/time.h> |
| 10 | |
| 11 | #include "update_engine/policy_manager/provider.h" |
| 12 | #include "update_engine/policy_manager/variable.h" |
| 13 | |
| 14 | using base::Time; |
| 15 | |
| 16 | namespace chromeos_policy_manager { |
| 17 | |
| 18 | // TODO(garnold) Adapted from connection_manager.h. |
| 19 | enum ShillConnType { |
| 20 | kShillConnTypeEthernet = 0, |
| 21 | kShillConnTypeWifi, |
| 22 | kShillConnTypeWimax, |
| 23 | kShillConnTypeBluetooth, |
| 24 | kShillConnTypeCellular, |
| 25 | kShillConnTypeUnknown |
| 26 | }; |
| 27 | |
| 28 | // Provider for networking related information. |
| 29 | class ShillProvider : public Provider { |
| 30 | public: |
| 31 | // Returns whether we currently have network connectivity. |
| 32 | Variable<bool>* var_is_connected() const { |
| 33 | return var_is_connected_.get(); |
| 34 | } |
| 35 | |
| 36 | // Returns the current network connection type. Unknown if not connected. |
| 37 | Variable<ShillConnType>* var_conn_type() const { |
| 38 | return var_conn_type_.get(); |
| 39 | } |
| 40 | |
| 41 | // Returns the time when network connection last changed; initialized to |
| 42 | // current time. |
| 43 | Variable<base::Time>* var_conn_last_changed() const { |
| 44 | return var_conn_last_changed_.get(); |
| 45 | } |
| 46 | |
| 47 | protected: |
| 48 | ShillProvider() {} |
| 49 | |
| 50 | scoped_ptr<Variable<bool> > var_is_connected_; |
| 51 | scoped_ptr<Variable<ShillConnType> > var_conn_type_; |
| 52 | scoped_ptr<Variable<base::Time> > var_conn_last_changed_; |
| 53 | |
| 54 | private: |
| 55 | DISALLOW_COPY_AND_ASSIGN(ShillProvider); |
| 56 | }; |
| 57 | |
| 58 | } // namespace chromeos_policy_manager |
| 59 | |
| 60 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_SHILL_PROVIDER_H |