blob: 12f15a27f4366fde30fb1e4aba15710fc1b7e988 [file] [log] [blame]
Gilad Arnold55f39b72014-01-28 12:51:45 -08001// 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
14using base::Time;
15
16namespace chromeos_policy_manager {
17
18// TODO(garnold) Adapted from connection_manager.h.
19enum ShillConnType {
20 kShillConnTypeEthernet = 0,
21 kShillConnTypeWifi,
22 kShillConnTypeWimax,
23 kShillConnTypeBluetooth,
24 kShillConnTypeCellular,
25 kShillConnTypeUnknown
26};
27
28// Provider for networking related information.
29class 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
Alex Deymo540d9422014-02-27 11:17:31 -080050 void set_var_is_connected(Variable<bool>* var_is_connected) {
51 var_is_connected_.reset(var_is_connected);
52 }
53
54 void set_var_conn_type(Variable<ShillConnType>* var_conn_type) {
55 var_conn_type_.reset(var_conn_type);
56 }
57
58 void set_var_conn_last_changed(Variable<base::Time>* var_conn_last_changed) {
59 var_conn_last_changed_.reset(var_conn_last_changed);
60 }
Gilad Arnold55f39b72014-01-28 12:51:45 -080061
62 private:
Alex Deymo540d9422014-02-27 11:17:31 -080063 scoped_ptr<Variable<bool>> var_is_connected_;
64 scoped_ptr<Variable<ShillConnType>> var_conn_type_;
65 scoped_ptr<Variable<base::Time>> var_conn_last_changed_;
66
Gilad Arnold55f39b72014-01-28 12:51:45 -080067 DISALLOW_COPY_AND_ASSIGN(ShillProvider);
68};
69
70} // namespace chromeos_policy_manager
71
72#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_SHILL_PROVIDER_H