Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 1 | // 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 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_CONNECTION_MANAGER_H_ |
| 6 | #define UPDATE_ENGINE_CONNECTION_MANAGER_H_ |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 7 | |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 10 | #include <base/macros.h> |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 11 | |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 12 | #include "update_engine/connection_manager_interface.h" |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 13 | #include "update_engine/dbus_proxies.h" |
| 14 | #include "update_engine/shill_proxy_interface.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 15 | |
| 16 | namespace chromeos_update_engine { |
| 17 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 18 | class SystemState; |
| 19 | |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 20 | // This class implements the concrete class that talks with the connection |
| 21 | // manager (shill) over DBus. |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 22 | // TODO(deymo): Remove this class and use ShillProvider from the UpdateManager. |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 23 | class ConnectionManager : public ConnectionManagerInterface { |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 24 | public: |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 25 | // Returns the string representation corresponding to the given |
| 26 | // connection type. |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 27 | static const char* StringForConnectionType(NetworkConnectionType type); |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 28 | |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 29 | // Constructs a new ConnectionManager object initialized with the |
| 30 | // given system state. |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 31 | ConnectionManager(ShillProxyInterface* shill_proxy, |
| 32 | SystemState* system_state); |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 33 | ~ConnectionManager() override = default; |
| 34 | |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 35 | // ConnectionManagerInterface overrides. |
| 36 | bool GetConnectionProperties(NetworkConnectionType* out_type, |
| 37 | NetworkTethering* out_tethering) override; |
Alex Deymo | f6ee016 | 2015-07-31 12:35:22 -0700 | [diff] [blame] | 38 | bool IsUpdateAllowedOver(NetworkConnectionType type, |
| 39 | NetworkTethering tethering) const override; |
Alex Deymo | 6ae9120 | 2014-03-10 19:21:25 -0700 | [diff] [blame] | 40 | |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 41 | private: |
Alex Deymo | 3053450 | 2015-07-20 15:06:33 -0700 | [diff] [blame] | 42 | // Returns (via out_path) the default network path, or empty string if |
| 43 | // there's no network up. Returns true on success. |
| 44 | bool GetDefaultServicePath(std::string* out_path); |
| 45 | |
| 46 | bool GetServicePathProperties(const std::string& path, |
| 47 | NetworkConnectionType* out_type, |
| 48 | NetworkTethering* out_tethering); |
| 49 | |
| 50 | // The mockable interface to access the shill DBus proxies. |
| 51 | ShillProxyInterface* shill_proxy_; |
| 52 | |
| 53 | // The global context for update_engine. |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 54 | SystemState* system_state_; |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 57 | }; |
| 58 | |
| 59 | } // namespace chromeos_update_engine |
| 60 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 61 | #endif // UPDATE_ENGINE_CONNECTION_MANAGER_H_ |