blob: 58307ff68302efdfc0d94082939bad455045bbc5 [file] [log] [blame]
Jay Srinivasan43488792012-06-19 00:25:31 -07001// Copyright (c) 2012 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_CONNECTION_MANAGER_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_CONNECTION_MANAGER_H_
7
8#include <base/basictypes.h>
9
Gilad Arnold1b9d6ae2014-03-03 13:46:07 -080010#include "update_engine/dbus_wrapper_interface.h"
Jay Srinivasan43488792012-06-19 00:25:31 -070011
12namespace chromeos_update_engine {
13
14enum NetworkConnectionType {
15 kNetEthernet = 0,
16 kNetWifi,
17 kNetWimax,
18 kNetBluetooth,
19 kNetCellular,
20 kNetUnknown
21};
22
23class SystemState;
24
25// This class exposes a generic interface to the connection manager
26// (e.g FlimFlam, Shill, etc.) to consolidate all connection-related
27// logic in update_engine.
28class ConnectionManager {
29 public:
30 // Constructs a new ConnectionManager object initialized with the
31 // given system state.
32 explicit ConnectionManager(SystemState* system_state);
33
34 // Populates |out_type| with the type of the network connection
35 // that we are currently connected. The dbus_iface is used to
36 // query the real connection manager (e.g shill).
Gilad Arnold1b9d6ae2014-03-03 13:46:07 -080037 virtual bool GetConnectionType(DBusWrapperInterface* dbus_iface,
Jay Srinivasan43488792012-06-19 00:25:31 -070038 NetworkConnectionType* out_type) const;
39
40 // Returns true if we're allowed to update the system when we're
41 // connected to the internet through the given network connection type.
42 virtual bool IsUpdateAllowedOver(NetworkConnectionType type) const;
43
44 // Returns the string representation corresponding to the given
45 // connection type.
46 virtual const char* StringForConnectionType(NetworkConnectionType type) const;
47
48 private:
49 // The global context for update_engine
50 SystemState* system_state_;
51
52 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
53};
54
55} // namespace chromeos_update_engine
56
57#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_CONNECTION_MANAGER_H_