OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ |
7 | 7 |
8 #include "net/base/network_change_notifier.h" | 8 #include "net/base/network_change_notifier.h" |
9 | 9 |
10 namespace offline_pages { | 10 namespace offline_pages { |
11 | 11 |
12 // Device network and power conditions. | 12 // Device network and power conditions. |
13 class DeviceConditions { | 13 class DeviceConditions { |
14 public: | 14 public: |
15 DeviceConditions( | 15 DeviceConditions( |
16 bool power_connected, | 16 bool power_connected, |
17 int battery_percentage, | 17 int battery_percentage, |
18 net::NetworkChangeNotifier::ConnectionType net_connection_type) | 18 net::NetworkChangeNotifier::ConnectionType net_connection_type) |
19 : power_connected_(power_connected), | 19 : power_connected_(power_connected), |
20 battery_percentage_(battery_percentage), | 20 battery_percentage_(battery_percentage), |
21 net_connection_type_(net_connection_type) {} | 21 net_connection_type_(net_connection_type) {} |
22 | 22 |
23 DeviceConditions() | |
dougarnett
2016/07/18 21:45:44
why would we want default ctor to have weakest set
Pete Williamson
2016/07/18 22:52:09
Ideally, the default ctor is only used when constr
dougarnett
2016/07/19 00:20:44
Indeed, since it is public it was a concern of def
Pete Williamson
2016/07/19 19:48:08
Changed to power on, 75% battery, and unmetered ne
| |
24 : power_connected_(false), battery_percentage_(0), | |
25 net_connection_type_(net::NetworkChangeNotifier::CONNECTION_NONE) {} | |
26 | |
27 DeviceConditions(const DeviceConditions& other) | |
28 : power_connected_(other.power_connected_), | |
29 battery_percentage_(other.battery_percentage_), | |
30 net_connection_type_(other.net_connection_type_) {} | |
31 | |
23 // Returns whether power is connected. | 32 // Returns whether power is connected. |
24 bool IsPowerConnected() const { return power_connected_; } | 33 bool IsPowerConnected() const { return power_connected_; } |
25 | 34 |
26 // Returns percentage of remaining battery power (0-100). | 35 // Returns percentage of remaining battery power (0-100). |
27 int GetBatteryPercentage() const { return battery_percentage_; } | 36 int GetBatteryPercentage() const { return battery_percentage_; } |
28 | 37 |
29 // Returns the current type of network connection, if any. | 38 // Returns the current type of network connection, if any. |
30 net::NetworkChangeNotifier::ConnectionType GetNetConnectionType() const { | 39 net::NetworkChangeNotifier::ConnectionType GetNetConnectionType() const { |
31 return net_connection_type_; | 40 return net_connection_type_; |
32 } | 41 } |
33 | 42 |
34 private: | 43 private: |
35 const bool power_connected_; | 44 const bool power_connected_; |
36 const int battery_percentage_; | 45 const int battery_percentage_; |
37 const net::NetworkChangeNotifier::ConnectionType net_connection_type_; | 46 const net::NetworkChangeNotifier::ConnectionType net_connection_type_; |
38 }; | 47 }; |
39 | 48 |
40 } // namespace offline_pages | 49 } // namespace offline_pages |
41 | 50 |
42 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ | 51 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_DEVICE_CONDITIONS_H_ |
OLD | NEW |