blob: 6cc279e86f875ecb891932632c7ad38928378634 [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
10#include "update_engine/dbus_interface.h"
11
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).
37 virtual bool GetConnectionType(DbusGlibInterface* dbus_iface,
38 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_